summaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_file.c
diff options
context:
space:
mode:
authorMax Khon <fjoe@FreeBSD.org>2003-01-06 09:19:43 +0000
committerMax Khon <fjoe@FreeBSD.org>2003-01-06 09:19:43 +0000
commit64f3af4796fdd6097bfff804eb84580d083dbe62 (patch)
treeb7d6d3f434082c707d72816761e6ca2db372ae55 /sys/compat/linux/linux_file.c
parentad554752f12ad3c6468aa50fab80052f7fd732c9 (diff)
Notes
Diffstat (limited to 'sys/compat/linux/linux_file.c')
-rw-r--r--sys/compat/linux/linux_file.c90
1 files changed, 43 insertions, 47 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 997b41cb1e4d..e8b3a877a8ac 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -850,10 +850,16 @@ bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
static int
fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
{
+ struct l_flock linux_flock;
+ struct flock *bsd_flock;
struct fcntl_args fcntl_args;
struct filedesc *fdp;
struct file *fp;
int error, result;
+ caddr_t sg;
+
+ sg = stackgap_init();
+ bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
fcntl_args.fd = args->fd;
@@ -906,50 +912,6 @@ fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
fcntl_args.cmd = F_SETFL;
return (fcntl(p, &fcntl_args));
- case LINUX_F_GETOWN:
- fcntl_args.cmd = F_GETOWN;
- return (fcntl(p, &fcntl_args));
-
- case LINUX_F_SETOWN:
- /*
- * XXX some Linux applications depend on F_SETOWN having no
- * significant effect for pipes (SIGIO is not delivered for
- * pipes under Linux-2.2.35 at least).
- */
- fdp = p->p_fd;
- if ((u_int)args->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[args->fd]) == NULL)
- return (EBADF);
- if (fp->f_type == DTYPE_PIPE)
- return (EINVAL);
-
- fcntl_args.cmd = F_SETOWN;
- fcntl_args.arg = args->arg;
- return (fcntl(p, &fcntl_args));
- }
-
- return (EINVAL);
-}
-
-int
-linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
-{
- struct linux_fcntl64_args args64;
- struct fcntl_args fcntl_args;
- struct l_flock linux_flock;
- struct flock *bsd_flock;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
-
-#ifdef DEBUG
- if (ldebug(fcntl))
- printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
-#endif
-
- switch (args->cmd) {
case LINUX_F_GETLK:
error = copyin((caddr_t)args->arg, &linux_flock,
sizeof(linux_flock));
@@ -987,8 +949,42 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
fcntl_args.cmd = F_SETLKW;
fcntl_args.arg = (long)bsd_flock;
return (fcntl(p, &fcntl_args));
+
+ case LINUX_F_GETOWN:
+ fcntl_args.cmd = F_GETOWN;
+ return (fcntl(p, &fcntl_args));
+
+ case LINUX_F_SETOWN:
+ /*
+ * XXX some Linux applications depend on F_SETOWN having no
+ * significant effect for pipes (SIGIO is not delivered for
+ * pipes under Linux-2.2.35 at least).
+ */
+ fdp = p->p_fd;
+ if ((u_int)args->fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[args->fd]) == NULL)
+ return (EBADF);
+ if (fp->f_type == DTYPE_PIPE)
+ return (EINVAL);
+
+ fcntl_args.cmd = F_SETOWN;
+ fcntl_args.arg = args->arg;
+ return (fcntl(p, &fcntl_args));
}
+ return (EINVAL);
+}
+
+int
+linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
+{
+ struct linux_fcntl64_args args64;
+
+#ifdef DEBUG
+ if (ldebug(fcntl))
+ printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
+#endif
+
args64.fd = args->fd;
args64.cmd = args->cmd;
args64.arg = args->arg;
@@ -1014,7 +1010,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
#endif
switch (args->cmd) {
- case LINUX_F_GETLK:
+ case LINUX_F_GETLK64:
error = copyin((caddr_t)args->arg, &linux_flock,
sizeof(linux_flock));
if (error)
@@ -1030,7 +1026,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
return (copyout(&linux_flock, (caddr_t)args->arg,
sizeof(linux_flock)));
- case LINUX_F_SETLK:
+ case LINUX_F_SETLK64:
error = copyin((caddr_t)args->arg, &linux_flock,
sizeof(linux_flock));
if (error)
@@ -1041,7 +1037,7 @@ linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
fcntl_args.arg = (long)bsd_flock;
return (fcntl(p, &fcntl_args));
- case LINUX_F_SETLKW:
+ case LINUX_F_SETLKW64:
error = copyin((caddr_t)args->arg, &linux_flock,
sizeof(linux_flock));
if (error)