4 * This should eventually move to userland.
7 #include <linux/types.h>
8 #include <linux/file.h>
10 #include <linux/sunrpc/svc.h>
11 #include <linux/nfsd/nfsd.h>
12 #include <linux/nfsd/syscall.h>
13 #include <linux/cred.h>
14 #include <linux/sched.h>
15 #include <linux/linkage.h>
16 #include <linux/namei.h>
17 #include <linux/mount.h>
18 #include <linux/syscalls.h>
19 #include <asm/uaccess.h>
22 * open a file on nfsd fs
25 static struct file
*do_open(char *name
, int flags
)
31 mnt
= do_kern_mount("nfsd", 0, "nfsd", NULL
);
33 return (struct file
*)mnt
;
35 error
= vfs_path_lookup(mnt
->mnt_root
, mnt
, name
, 0, &nd
);
36 mntput(mnt
); /* drop do_kern_mount reference */
38 return ERR_PTR(error
);
41 error
= may_open(&nd
,MAY_READ
|MAY_WRITE
,FMODE_READ
|FMODE_WRITE
);
43 error
= may_open(&nd
, MAY_WRITE
, FMODE_WRITE
);
46 return dentry_open(nd
.path
.dentry
, nd
.path
.mnt
, flags
,
50 return ERR_PTR(error
);
54 char *name
; int wsize
; int rsize
;
58 .wsize
= sizeof(struct nfsctl_svc
)
60 [NFSCTL_ADDCLIENT
] = {
62 .wsize
= sizeof(struct nfsctl_client
)
64 [NFSCTL_DELCLIENT
] = {
66 .wsize
= sizeof(struct nfsctl_client
)
70 .wsize
= sizeof(struct nfsctl_export
)
74 .wsize
= sizeof(struct nfsctl_export
)
78 .wsize
= sizeof(struct nfsctl_fdparm
),
83 .wsize
= sizeof(struct nfsctl_fsparm
),
84 .rsize
= sizeof(struct knfsd_fh
)
89 asmlinkage
sys_nfsservctl(int cmd
, struct nfsctl_arg __user
*arg
, void __user
*res
)
92 void __user
*p
= &arg
->u
;
96 if (copy_from_user(&version
, &arg
->ca_version
, sizeof(int)))
99 if (version
!= NFSCTL_VERSION
)
102 if (cmd
< 0 || cmd
>= ARRAY_SIZE(map
) || !map
[cmd
].name
)
105 file
= do_open(map
[cmd
].name
, map
[cmd
].rsize
? O_RDWR
: O_WRONLY
);
107 return PTR_ERR(file
);
108 err
= file
->f_op
->write(file
, p
, map
[cmd
].wsize
, &file
->f_pos
);
109 if (err
>= 0 && map
[cmd
].rsize
)
110 err
= file
->f_op
->read(file
, res
, map
[cmd
].rsize
, &file
->f_pos
);
This page took 0.050238 seconds and 6 git commands to generate.