2 * Copyright (c) 1994-1995 Søren Schmidt
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software withough specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.41.2.6 2003/01/06 09:19:43 fjoe Exp $
29 * $DragonFly: src/sys/emulation/linux/linux_file.c,v 1.2 2003/06/17 04:28:19 dillon Exp $
32 #include "opt_compat.h"
34 #include <sys/param.h>
35 #include <sys/systm.h>
37 #include <sys/dirent.h>
38 #include <sys/fcntl.h>
40 #include <sys/filedesc.h>
42 #include <sys/malloc.h>
43 #include <sys/mount.h>
45 #include <sys/sysproto.h>
47 #include <sys/vnode.h>
49 #include <ufs/ufs/quota.h>
50 #include <ufs/ufs/ufsmount.h>
52 #include <machine/../linux/linux.h>
53 #include <machine/../linux/linux_proto.h>
54 #include <compat/linux/linux_util.h>
58 linux_creat(struct proc *p, struct linux_creat_args *args)
68 CHECKALTCREAT(p, &sg, args->path);
72 printf(ARGS(creat, "%s, %d"), args->path, args->mode);
74 bsd_open_args.path = args->path;
75 bsd_open_args.mode = args->mode;
76 bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC;
77 return open(p, &bsd_open_args);
82 linux_open(struct proc *p, struct linux_open_args *args)
94 if (args->flags & LINUX_O_CREAT)
95 CHECKALTCREAT(p, &sg, args->path);
97 CHECKALTEXIST(p, &sg, args->path);
101 printf(ARGS(open, "%s, 0x%x, 0x%x"),
102 args->path, args->flags, args->mode);
104 bsd_open_args.flags = 0;
105 if (args->flags & LINUX_O_RDONLY)
106 bsd_open_args.flags |= O_RDONLY;
107 if (args->flags & LINUX_O_WRONLY)
108 bsd_open_args.flags |= O_WRONLY;
109 if (args->flags & LINUX_O_RDWR)
110 bsd_open_args.flags |= O_RDWR;
111 if (args->flags & LINUX_O_NDELAY)
112 bsd_open_args.flags |= O_NONBLOCK;
113 if (args->flags & LINUX_O_APPEND)
114 bsd_open_args.flags |= O_APPEND;
115 if (args->flags & LINUX_O_SYNC)
116 bsd_open_args.flags |= O_FSYNC;
117 if (args->flags & LINUX_O_NONBLOCK)
118 bsd_open_args.flags |= O_NONBLOCK;
119 if (args->flags & LINUX_FASYNC)
120 bsd_open_args.flags |= O_ASYNC;
121 if (args->flags & LINUX_O_CREAT)
122 bsd_open_args.flags |= O_CREAT;
123 if (args->flags & LINUX_O_TRUNC)
124 bsd_open_args.flags |= O_TRUNC;
125 if (args->flags & LINUX_O_EXCL)
126 bsd_open_args.flags |= O_EXCL;
127 if (args->flags & LINUX_O_NOCTTY)
128 bsd_open_args.flags |= O_NOCTTY;
129 bsd_open_args.path = args->path;
130 bsd_open_args.mode = args->mode;
132 error = open(p, &bsd_open_args);
133 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
134 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
135 struct filedesc *fdp = p->p_fd;
136 struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
138 if (fp->f_type == DTYPE_VNODE)
139 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
143 printf(LMSG("open returns error %d"), error);
149 linux_lseek(struct proc *p, struct linux_lseek_args *args)
152 struct lseek_args /* {
162 printf(ARGS(lseek, "%d, %ld, %d"),
163 args->fdes, (long)args->off, args->whence);
165 tmp_args.fd = args->fdes;
166 tmp_args.offset = (off_t)args->off;
167 tmp_args.whence = args->whence;
168 error = lseek(p, &tmp_args);
174 linux_llseek(struct proc *p, struct linux_llseek_args *args)
176 struct lseek_args bsd_args;
182 printf(ARGS(llseek, "%d, %d:%d, %d"),
183 args->fd, args->ohigh, args->olow, args->whence);
185 off = (args->olow) | (((off_t) args->ohigh) << 32);
187 bsd_args.fd = args->fd;
188 bsd_args.offset = off;
189 bsd_args.whence = args->whence;
191 if ((error = lseek(p, &bsd_args)))
194 if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
200 #endif /*!__alpha__*/
204 linux_readdir(struct proc *p, struct linux_readdir_args *args)
206 struct linux_getdents_args lda;
209 lda.dent = args->dent;
211 return linux_getdents(p, &lda);
213 #endif /*!__alpha__*/
216 * Note that linux_getdents(2) and linux_getdents64(2) have the same
217 * arguments. They only differ in the definition of struct dirent they
218 * operate on. We use this to common the code, with the exception of
219 * accessing struct dirent. Note that linux_readdir(2) is implemented
220 * by means of linux_getdents(2). In this case we never operate on
221 * struct dirent64 and thus don't need to handle it...
228 char d_name[LINUX_NAME_MAX + 1];
236 char d_name[LINUX_NAME_MAX + 1];
239 #define LINUX_RECLEN(de,namlen) \
240 ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + 1))
242 #define LINUX_DIRBLKSIZ 512
245 getdents_common(struct proc *p, struct linux_getdents64_args *args,
248 register struct dirent *bdp;
250 caddr_t inp, buf; /* BSD-format */
251 int len, reclen; /* BSD-format */
252 caddr_t outp; /* Linux-format */
253 int resid, linuxreclen=0; /* Linux-format */
259 struct l_dirent linux_dirent;
260 struct l_dirent64 linux_dirent64;
261 int buflen, error, eofflag, nbytes, justone;
262 u_long *cookies = NULL, *cookiep;
265 if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0)
268 if ((fp->f_flag & FREAD) == 0)
271 vp = (struct vnode *) fp->f_data;
272 if (vp->v_type != VDIR)
275 if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
278 nbytes = args->count;
280 /* readdir(2) case. Always struct dirent. */
283 nbytes = sizeof(linux_dirent);
290 buflen = max(LINUX_DIRBLKSIZ, nbytes);
291 buflen = min(buflen, MAXBSIZE);
292 buf = malloc(buflen, M_TEMP, M_WAITOK);
293 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
297 aiov.iov_len = buflen;
298 auio.uio_iov = &aiov;
300 auio.uio_rw = UIO_READ;
301 auio.uio_segflg = UIO_SYSSPACE;
303 auio.uio_resid = buflen;
304 auio.uio_offset = off;
307 free(cookies, M_TEMP);
311 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
316 outp = (caddr_t)args->dirent;
318 if ((len = buflen - auio.uio_resid) <= 0)
325 * When using cookies, the vfs has the option of reading from
326 * a different offset than that supplied (UFS truncates the
327 * offset to a block boundary to make sure that it never reads
328 * partway through a directory entry, even if the directory
329 * has been compacted).
331 while (len > 0 && ncookies > 0 && *cookiep <= off) {
332 bdp = (struct dirent *) inp;
333 len -= bdp->d_reclen;
334 inp += bdp->d_reclen;
341 if (cookiep && ncookies == 0)
343 bdp = (struct dirent *) inp;
344 reclen = bdp->d_reclen;
350 if (bdp->d_fileno == 0) {
362 linuxreclen = (is64bit)
363 ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen)
364 : LINUX_RECLEN(&linux_dirent, bdp->d_namlen);
366 if (reclen > len || resid < linuxreclen) {
372 /* readdir(2) case. */
373 linux_dirent.d_ino = (l_long)bdp->d_fileno;
374 linux_dirent.d_off = (l_off_t)linuxreclen;
375 linux_dirent.d_reclen = (l_ushort)bdp->d_namlen;
376 strcpy(linux_dirent.d_name, bdp->d_name);
377 error = copyout(&linux_dirent, outp, linuxreclen);
380 linux_dirent64.d_ino = bdp->d_fileno;
381 linux_dirent64.d_off = (cookiep)
383 : (l_off_t)(off + reclen);
384 linux_dirent64.d_reclen =
385 (l_ushort)linuxreclen;
386 linux_dirent64.d_type = bdp->d_type;
387 strcpy(linux_dirent64.d_name, bdp->d_name);
388 error = copyout(&linux_dirent64, outp,
391 linux_dirent.d_ino = bdp->d_fileno;
392 linux_dirent.d_off = (cookiep)
394 : (l_off_t)(off + reclen);
395 linux_dirent.d_reclen = (l_ushort)linuxreclen;
396 strcpy(linux_dirent.d_name, bdp->d_name);
397 error = copyout(&linux_dirent, outp,
412 resid -= linuxreclen;
418 if (outp == (caddr_t)args->dirent)
423 nbytes = resid + linuxreclen;
426 p->p_retval[0] = nbytes - resid;
430 free(cookies, M_TEMP);
432 VOP_UNLOCK(vp, 0, p);
438 linux_getdents(struct proc *p, struct linux_getdents_args *args)
442 if (ldebug(getdents))
443 printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
446 return (getdents_common(p, (struct linux_getdents64_args*)args, 0));
450 linux_getdents64(struct proc *p, struct linux_getdents64_args *args)
454 if (ldebug(getdents64))
455 printf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
458 return (getdents_common(p, args, 1));
462 * These exist mainly for hooks for doing /compat/linux translation.
466 linux_access(struct proc *p, struct linux_access_args *args)
468 struct access_args bsd;
471 sg = stackgap_init();
472 CHECKALTEXIST(p, &sg, args->path);
476 printf(ARGS(access, "%s, %d"), args->path, args->flags);
478 bsd.path = args->path;
479 bsd.flags = args->flags;
481 return access(p, &bsd);
485 linux_unlink(struct proc *p, struct linux_unlink_args *args)
487 struct unlink_args bsd;
490 sg = stackgap_init();
491 CHECKALTEXIST(p, &sg, args->path);
495 printf(ARGS(unlink, "%s"), args->path);
497 bsd.path = args->path;
499 return unlink(p, &bsd);
503 linux_chdir(struct proc *p, struct linux_chdir_args *args)
505 struct chdir_args bsd;
508 sg = stackgap_init();
509 CHECKALTEXIST(p, &sg, args->path);
513 printf(ARGS(chdir, "%s"), args->path);
515 bsd.path = args->path;
517 return chdir(p, &bsd);
521 linux_chmod(struct proc *p, struct linux_chmod_args *args)
523 struct chmod_args bsd;
526 sg = stackgap_init();
527 CHECKALTEXIST(p, &sg, args->path);
531 printf(ARGS(chmod, "%s, %d"), args->path, args->mode);
533 bsd.path = args->path;
534 bsd.mode = args->mode;
536 return chmod(p, &bsd);
540 linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
542 struct mkdir_args bsd;
545 sg = stackgap_init();
546 CHECKALTCREAT(p, &sg, args->path);
550 printf(ARGS(mkdir, "%s, %d"), args->path, args->mode);
552 bsd.path = args->path;
553 bsd.mode = args->mode;
555 return mkdir(p, &bsd);
559 linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
561 struct rmdir_args bsd;
564 sg = stackgap_init();
565 CHECKALTEXIST(p, &sg, args->path);
569 printf(ARGS(rmdir, "%s"), args->path);
571 bsd.path = args->path;
573 return rmdir(p, &bsd);
577 linux_rename(struct proc *p, struct linux_rename_args *args)
579 struct rename_args bsd;
582 sg = stackgap_init();
583 CHECKALTEXIST(p, &sg, args->from);
584 CHECKALTCREAT(p, &sg, args->to);
588 printf(ARGS(rename, "%s, %s"), args->from, args->to);
590 bsd.from = args->from;
593 return rename(p, &bsd);
597 linux_symlink(struct proc *p, struct linux_symlink_args *args)
599 struct symlink_args bsd;
602 sg = stackgap_init();
603 CHECKALTEXIST(p, &sg, args->path);
604 CHECKALTCREAT(p, &sg, args->to);
608 printf(ARGS(symlink, "%s, %s"), args->path, args->to);
610 bsd.path = args->path;
613 return symlink(p, &bsd);
617 linux_readlink(struct proc *p, struct linux_readlink_args *args)
619 struct readlink_args bsd;
622 sg = stackgap_init();
623 CHECKALTEXIST(p, &sg, args->name);
626 if (ldebug(readlink))
627 printf(ARGS(readlink, "%s, %p, %d"),
628 args->name, (void *)args->buf, args->count);
630 bsd.path = args->name;
632 bsd.count = args->count;
634 return readlink(p, &bsd);
638 linux_truncate(struct proc *p, struct linux_truncate_args *args)
640 struct truncate_args bsd;
643 sg = stackgap_init();
644 CHECKALTEXIST(p, &sg, args->path);
647 if (ldebug(truncate))
648 printf(ARGS(truncate, "%s, %ld"), args->path,
651 bsd.path = args->path;
652 bsd.length = args->length;
654 return truncate(p, &bsd);
658 linux_link(struct proc *p, struct linux_link_args *args)
660 struct link_args bsd;
663 sg = stackgap_init();
664 CHECKALTEXIST(p, &sg, args->path);
665 CHECKALTCREAT(p, &sg, args->to);
669 printf(ARGS(link, "%s, %s"), args->path, args->to);
672 bsd.path = args->path;
675 return link(p, &bsd);
680 linux_fdatasync(p, uap)
682 struct linux_fdatasync_args *uap;
684 struct fsync_args bsd;
687 return fsync(p, &bsd);
689 #endif /*!__alpha__*/
694 struct linux_pread_args *uap;
696 struct pread_args bsd;
700 bsd.nbyte = uap->nbyte;
701 bsd.offset = uap->offset;
702 return pread(p, &bsd);
708 struct linux_pwrite_args *uap;
710 struct pwrite_args bsd;
714 bsd.nbyte = uap->nbyte;
715 bsd.offset = uap->offset;
716 return pwrite(p, &bsd);
720 linux_oldumount(struct proc *p, struct linux_oldumount_args *args)
722 struct linux_umount_args args2;
724 args2.path = args->path;
726 return (linux_umount(p, &args2));
730 linux_umount(struct proc *p, struct linux_umount_args *args)
732 struct unmount_args bsd;
734 bsd.path = args->path;
735 bsd.flags = args->flags; /* XXX correct? */
736 return (unmount(p, &bsd));
740 * fcntl family of syscalls
752 linux_to_bsd_flock(struct l_flock *linux_flock, struct flock *bsd_flock)
754 switch (linux_flock->l_type) {
756 bsd_flock->l_type = F_RDLCK;
759 bsd_flock->l_type = F_WRLCK;
762 bsd_flock->l_type = F_UNLCK;
765 bsd_flock->l_type = -1;
768 bsd_flock->l_whence = linux_flock->l_whence;
769 bsd_flock->l_start = (off_t)linux_flock->l_start;
770 bsd_flock->l_len = (off_t)linux_flock->l_len;
771 bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
775 bsd_to_linux_flock(struct flock *bsd_flock, struct l_flock *linux_flock)
777 switch (bsd_flock->l_type) {
779 linux_flock->l_type = LINUX_F_RDLCK;
782 linux_flock->l_type = LINUX_F_WRLCK;
785 linux_flock->l_type = LINUX_F_UNLCK;
788 linux_flock->l_whence = bsd_flock->l_whence;
789 linux_flock->l_start = (l_off_t)bsd_flock->l_start;
790 linux_flock->l_len = (l_off_t)bsd_flock->l_len;
791 linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
794 #if defined(__i386__)
804 linux_to_bsd_flock64(struct l_flock64 *linux_flock, struct flock *bsd_flock)
806 switch (linux_flock->l_type) {
808 bsd_flock->l_type = F_RDLCK;
811 bsd_flock->l_type = F_WRLCK;
814 bsd_flock->l_type = F_UNLCK;
817 bsd_flock->l_type = -1;
820 bsd_flock->l_whence = linux_flock->l_whence;
821 bsd_flock->l_start = (off_t)linux_flock->l_start;
822 bsd_flock->l_len = (off_t)linux_flock->l_len;
823 bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
827 bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
829 switch (bsd_flock->l_type) {
831 linux_flock->l_type = LINUX_F_RDLCK;
834 linux_flock->l_type = LINUX_F_WRLCK;
837 linux_flock->l_type = LINUX_F_UNLCK;
840 linux_flock->l_whence = bsd_flock->l_whence;
841 linux_flock->l_start = (l_loff_t)bsd_flock->l_start;
842 linux_flock->l_len = (l_loff_t)bsd_flock->l_len;
843 linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
845 #endif /* __i386__ */
847 #if defined(__alpha__)
848 #define linux_fcntl64_args linux_fcntl_args
852 fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
854 struct l_flock linux_flock;
855 struct flock *bsd_flock;
856 struct fcntl_args fcntl_args;
857 struct filedesc *fdp;
862 sg = stackgap_init();
863 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
865 fcntl_args.fd = args->fd;
869 fcntl_args.cmd = F_DUPFD;
870 fcntl_args.arg = args->arg;
871 return (fcntl(p, &fcntl_args));
874 fcntl_args.cmd = F_GETFD;
875 return (fcntl(p, &fcntl_args));
878 fcntl_args.cmd = F_SETFD;
879 fcntl_args.arg = args->arg;
880 return (fcntl(p, &fcntl_args));
883 fcntl_args.cmd = F_GETFL;
884 error = fcntl(p, &fcntl_args);
885 result = p->p_retval[0];
887 if (result & O_RDONLY)
888 p->p_retval[0] |= LINUX_O_RDONLY;
889 if (result & O_WRONLY)
890 p->p_retval[0] |= LINUX_O_WRONLY;
892 p->p_retval[0] |= LINUX_O_RDWR;
893 if (result & O_NDELAY)
894 p->p_retval[0] |= LINUX_O_NONBLOCK;
895 if (result & O_APPEND)
896 p->p_retval[0] |= LINUX_O_APPEND;
897 if (result & O_FSYNC)
898 p->p_retval[0] |= LINUX_O_SYNC;
899 if (result & O_ASYNC)
900 p->p_retval[0] |= LINUX_FASYNC;
905 if (args->arg & LINUX_O_NDELAY)
906 fcntl_args.arg |= O_NONBLOCK;
907 if (args->arg & LINUX_O_APPEND)
908 fcntl_args.arg |= O_APPEND;
909 if (args->arg & LINUX_O_SYNC)
910 fcntl_args.arg |= O_FSYNC;
911 if (args->arg & LINUX_FASYNC)
912 fcntl_args.arg |= O_ASYNC;
913 fcntl_args.cmd = F_SETFL;
914 return (fcntl(p, &fcntl_args));
917 error = copyin((caddr_t)args->arg, &linux_flock,
918 sizeof(linux_flock));
921 linux_to_bsd_flock(&linux_flock, bsd_flock);
922 fcntl_args.fd = args->fd;
923 fcntl_args.cmd = F_GETLK;
924 fcntl_args.arg = (long)bsd_flock;
925 error = fcntl(p, &fcntl_args);
928 bsd_to_linux_flock(bsd_flock, &linux_flock);
929 return (copyout(&linux_flock, (caddr_t)args->arg,
930 sizeof(linux_flock)));
933 error = copyin((caddr_t)args->arg, &linux_flock,
934 sizeof(linux_flock));
937 linux_to_bsd_flock(&linux_flock, bsd_flock);
938 fcntl_args.fd = args->fd;
939 fcntl_args.cmd = F_SETLK;
940 fcntl_args.arg = (long)bsd_flock;
941 return (fcntl(p, &fcntl_args));
944 error = copyin((caddr_t)args->arg, &linux_flock,
945 sizeof(linux_flock));
948 linux_to_bsd_flock(&linux_flock, bsd_flock);
949 fcntl_args.fd = args->fd;
950 fcntl_args.cmd = F_SETLKW;
951 fcntl_args.arg = (long)bsd_flock;
952 return (fcntl(p, &fcntl_args));
955 fcntl_args.cmd = F_GETOWN;
956 return (fcntl(p, &fcntl_args));
960 * XXX some Linux applications depend on F_SETOWN having no
961 * significant effect for pipes (SIGIO is not delivered for
962 * pipes under Linux-2.2.35 at least).
965 if ((u_int)args->fd >= fdp->fd_nfiles ||
966 (fp = fdp->fd_ofiles[args->fd]) == NULL)
968 if (fp->f_type == DTYPE_PIPE)
971 fcntl_args.cmd = F_SETOWN;
972 fcntl_args.arg = args->arg;
973 return (fcntl(p, &fcntl_args));
980 linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
982 struct linux_fcntl64_args args64;
986 printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
989 args64.fd = args->fd;
990 args64.cmd = args->cmd;
991 args64.arg = args->arg;
992 return (fcntl_common(p, &args64));
995 #if defined(__i386__)
997 linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
999 struct fcntl_args fcntl_args;
1000 struct l_flock64 linux_flock;
1001 struct flock *bsd_flock;
1005 sg = stackgap_init();
1006 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
1009 if (ldebug(fcntl64))
1010 printf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd);
1013 switch (args->cmd) {
1014 case LINUX_F_GETLK64:
1015 error = copyin((caddr_t)args->arg, &linux_flock,
1016 sizeof(linux_flock));
1019 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1020 fcntl_args.fd = args->fd;
1021 fcntl_args.cmd = F_GETLK;
1022 fcntl_args.arg = (long)bsd_flock;
1023 error = fcntl(p, &fcntl_args);
1026 bsd_to_linux_flock64(bsd_flock, &linux_flock);
1027 return (copyout(&linux_flock, (caddr_t)args->arg,
1028 sizeof(linux_flock)));
1030 case LINUX_F_SETLK64:
1031 error = copyin((caddr_t)args->arg, &linux_flock,
1032 sizeof(linux_flock));
1035 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1036 fcntl_args.fd = args->fd;
1037 fcntl_args.cmd = F_SETLK;
1038 fcntl_args.arg = (long)bsd_flock;
1039 return (fcntl(p, &fcntl_args));
1041 case LINUX_F_SETLKW64:
1042 error = copyin((caddr_t)args->arg, &linux_flock,
1043 sizeof(linux_flock));
1046 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1047 fcntl_args.fd = args->fd;
1048 fcntl_args.cmd = F_SETLKW;
1049 fcntl_args.arg = (long)bsd_flock;
1050 return (fcntl(p, &fcntl_args));
1053 return (fcntl_common(p, args));
1055 #endif /* __i386__ */
1058 linux_chown(struct proc *p, struct linux_chown_args *args)
1060 struct chown_args bsd;
1063 sg = stackgap_init();
1064 CHECKALTEXIST(p, &sg, args->path);
1068 printf(ARGS(chown, "%s, %d, %d"), args->path, args->uid,
1072 bsd.path = args->path;
1073 bsd.uid = args->uid;
1074 bsd.gid = args->gid;
1075 return (chown(p, &bsd));
1079 linux_lchown(struct proc *p, struct linux_lchown_args *args)
1081 struct lchown_args bsd;
1084 sg = stackgap_init();
1085 CHECKALTEXIST(p, &sg, args->path);
1089 printf(ARGS(lchown, "%s, %d, %d"), args->path, args->uid,
1093 bsd.path = args->path;
1094 bsd.uid = args->uid;
1095 bsd.gid = args->gid;
1096 return (lchown(p, &bsd));