Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
9789cfe
Documentation
arch
block
crypto
drivers
firmware
fs
9p
adfs
affs
afs
autofs
autofs4
befs
bfs
cifs
coda
configfs
cramfs
debugfs
devpts
dlm
ecryptfs
efs
exportfs
ext2
ext3
ext4
fat
freevxfs
fuse
gfs2
hfs
hfsplus
hostfs
hpfs
hppfs
hugetlbfs
isofs
jbd
jbd2
jffs2
jfs
lockd
minix
ncpfs
nfs
nfs_common
nfsd
nls
ntfs
ocfs2
omfs
openpromfs
partitions
proc
qnx4
ramfs
reiserfs
romfs
smbfs
sysfs
sysv
ubifs
udf
ufs
xfs
Kconfig
Kconfig.binfmt
Makefile
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
binfmt_som.c
bio-integrity.c
bio.c
block_dev.c
buffer.c
char_dev.c
compat.c
compat_binfmt_elf.c
compat_ioctl.c
dcache.c
dcookies.c
direct-io.c
dnotify.c
dquot.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c
fcntl.c
fifo.c
file.c
file_table.c
filesystems.c
fs-writeback.c
generic_acl.c
inode.c
inotify.c
inotify_user.c
internal.h
ioctl.c
ioprio.c
libfs.c
locks.c
mbcache.c
mpage.c
namei.c
namespace.c
nfsctl.c
no-block.c
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
quota.c
quota_v1.c
quota_v2.c
read_write.c
read_write.h
readdir.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
super.c
sync.c
timerfd.c
utimes.c
xattr.c
xattr_acl.c
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
fs
/
nfsctl.c
Blame
Blame
Latest commit
History
History
115 lines (102 loc) · 2.45 KB
Breadcrumbs
linux
/
fs
/
nfsctl.c
Top
File metadata and controls
Code
Blame
115 lines (102 loc) · 2.45 KB
Raw
/* * fs/nfsctl.c * * This should eventually move to userland. * */ #include <linux/types.h> #include <linux/file.h> #include <linux/fs.h> #include <linux/sunrpc/svc.h> #include <linux/nfsd/nfsd.h> #include <linux/nfsd/syscall.h> #include <linux/cred.h> #include <linux/sched.h> #include <linux/linkage.h> #include <linux/namei.h> #include <linux/mount.h> #include <linux/syscalls.h> #include <asm/uaccess.h> /* * open a file on nfsd fs */ static struct file *do_open(char *name, int flags) { struct nameidata nd; struct vfsmount *mnt; int error; mnt = do_kern_mount("nfsd", 0, "nfsd", NULL); if (IS_ERR(mnt)) return (struct file *)mnt; error = vfs_path_lookup(mnt->mnt_root, mnt, name, 0, &nd); mntput(mnt); /* drop do_kern_mount reference */ if (error) return ERR_PTR(error); if (flags == O_RDWR) error = may_open(&nd,MAY_READ|MAY_WRITE,FMODE_READ|FMODE_WRITE); else error = may_open(&nd, MAY_WRITE, FMODE_WRITE); if (!error) return dentry_open(nd.path.dentry, nd.path.mnt, flags, current_cred()); path_put(&nd.path); return ERR_PTR(error); } static struct { char *name; int wsize; int rsize; } map[] = { [NFSCTL_SVC] = { .name = ".svc", .wsize = sizeof(struct nfsctl_svc) }, [NFSCTL_ADDCLIENT] = { .name = ".add", .wsize = sizeof(struct nfsctl_client) }, [NFSCTL_DELCLIENT] = { .name = ".del", .wsize = sizeof(struct nfsctl_client) }, [NFSCTL_EXPORT] = { .name = ".export", .wsize = sizeof(struct nfsctl_export) }, [NFSCTL_UNEXPORT] = { .name = ".unexport", .wsize = sizeof(struct nfsctl_export) }, [NFSCTL_GETFD] = { .name = ".getfd", .wsize = sizeof(struct nfsctl_fdparm), .rsize = NFS_FHSIZE }, [NFSCTL_GETFS] = { .name = ".getfs", .wsize = sizeof(struct nfsctl_fsparm), .rsize = sizeof(struct knfsd_fh) }, }; long asmlinkage sys_nfsservctl(int cmd, struct nfsctl_arg __user *arg, void __user *res) { struct file *file; void __user *p = &arg->u; int version; int err; if (copy_from_user(&version, &arg->ca_version, sizeof(int))) return -EFAULT; if (version != NFSCTL_VERSION) return -EINVAL; if (cmd < 0 || cmd >= ARRAY_SIZE(map) || !map[cmd].name) return -EINVAL; file = do_open(map[cmd].name, map[cmd].rsize ? O_RDWR : O_WRONLY); if (IS_ERR(file)) return PTR_ERR(file); err = file->f_op->write(file, p, map[cmd].wsize, &file->f_pos); if (err >= 0 && map[cmd].rsize) err = file->f_op->read(file, res, map[cmd].rsize, &file->f_pos); if (err >= 0) err = 0; fput(file); return err; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
You can’t perform that action at this time.