4 * This should eventually move to userland.
7 #include <linux/types.h>
8 #include <linux/file.h>
10 #include <linux/nfsd/syscall.h>
11 #include <linux/cred.h>
12 #include <linux/sched.h>
13 #include <linux/linkage.h>
14 #include <linux/namei.h>
15 #include <linux/mount.h>
16 #include <linux/syscalls.h>
17 #include <asm/uaccess.h>
20 * open a file on nfsd fs
23 static struct file
*do_open(char *name
, int flags
)
28 mnt
= do_kern_mount("nfsd", 0, "nfsd", NULL
);
30 return (struct file
*)mnt
;
32 file
= file_open_root(mnt
->mnt_root
, mnt
, name
, flags
);
34 mntput(mnt
); /* drop do_kern_mount reference */
39 char *name
; int wsize
; int rsize
;
43 .wsize
= sizeof(struct nfsctl_svc
)
45 [NFSCTL_ADDCLIENT
] = {
47 .wsize
= sizeof(struct nfsctl_client
)
49 [NFSCTL_DELCLIENT
] = {
51 .wsize
= sizeof(struct nfsctl_client
)
55 .wsize
= sizeof(struct nfsctl_export
)
59 .wsize
= sizeof(struct nfsctl_export
)
63 .wsize
= sizeof(struct nfsctl_fdparm
),
68 .wsize
= sizeof(struct nfsctl_fsparm
),
69 .rsize
= sizeof(struct knfsd_fh
)
73 SYSCALL_DEFINE3(nfsservctl
, int, cmd
, struct nfsctl_arg __user
*, arg
,
77 void __user
*p
= &arg
->u
;
81 if (copy_from_user(&version
, &arg
->ca_version
, sizeof(int)))
84 if (version
!= NFSCTL_VERSION
)
87 if (cmd
< 0 || cmd
>= ARRAY_SIZE(map
) || !map
[cmd
].name
)
90 file
= do_open(map
[cmd
].name
, map
[cmd
].rsize
? O_RDWR
: O_WRONLY
);
93 err
= file
->f_op
->write(file
, p
, map
[cmd
].wsize
, &file
->f_pos
);
94 if (err
>= 0 && map
[cmd
].rsize
)
95 err
= file
->f_op
->read(file
, res
, map
[cmd
].rsize
, &file
->f_pos
);