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 $
31 #include "opt_compat.h"
33 #include <sys/param.h>
34 #include <sys/systm.h>
36 #include <sys/dirent.h>
37 #include <sys/fcntl.h>
39 #include <sys/filedesc.h>
41 #include <sys/malloc.h>
42 #include <sys/mount.h>
44 #include <sys/sysproto.h>
46 #include <sys/vnode.h>
48 #include <ufs/ufs/quota.h>
49 #include <ufs/ufs/ufsmount.h>
51 #include <machine/../linux/linux.h>
52 #include <machine/../linux/linux_proto.h>
53 #include <compat/linux/linux_util.h>
57 linux_creat(struct proc *p, struct linux_creat_args *args)
67 CHECKALTCREAT(p, &sg, args->path);
71 printf(ARGS(creat, "%s, %d"), args->path, args->mode);
73 bsd_open_args.path = args->path;
74 bsd_open_args.mode = args->mode;
75 bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC;
76 return open(p, &bsd_open_args);
81 linux_open(struct proc *p, struct linux_open_args *args)
93 if (args->flags & LINUX_O_CREAT)
94 CHECKALTCREAT(p, &sg, args->path);
96 CHECKALTEXIST(p, &sg, args->path);
100 printf(ARGS(open, "%s, 0x%x, 0x%x"),
101 args->path, args->flags, args->mode);
103 bsd_open_args.flags = 0;
104 if (args->flags & LINUX_O_RDONLY)
105 bsd_open_args.flags |= O_RDONLY;
106 if (args->flags & LINUX_O_WRONLY)
107 bsd_open_args.flags |= O_WRONLY;
108 if (args->flags & LINUX_O_RDWR)
109 bsd_open_args.flags |= O_RDWR;
110 if (args->flags & LINUX_O_NDELAY)
111 bsd_open_args.flags |= O_NONBLOCK;
112 if (args->flags & LINUX_O_APPEND)
113 bsd_open_args.flags |= O_APPEND;
114 if (args->flags & LINUX_O_SYNC)
115 bsd_open_args.flags |= O_FSYNC;
116 if (args->flags & LINUX_O_NONBLOCK)
117 bsd_open_args.flags |= O_NONBLOCK;
118 if (args->flags & LINUX_FASYNC)
119 bsd_open_args.flags |= O_ASYNC;
120 if (args->flags & LINUX_O_CREAT)
121 bsd_open_args.flags |= O_CREAT;
122 if (args->flags & LINUX_O_TRUNC)
123 bsd_open_args.flags |= O_TRUNC;
124 if (args->flags & LINUX_O_EXCL)
125 bsd_open_args.flags |= O_EXCL;
126 if (args->flags & LINUX_O_NOCTTY)
127 bsd_open_args.flags |= O_NOCTTY;
128 bsd_open_args.path = args->path;
129 bsd_open_args.mode = args->mode;
131 error = open(p, &bsd_open_args);
132 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
133 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
134 struct filedesc *fdp = p->p_fd;
135 struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
137 if (fp->f_type == DTYPE_VNODE)
138 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
142 printf(LMSG("open returns error %d"), error);
148 linux_lseek(struct proc *p, struct linux_lseek_args *args)
151 struct lseek_args /* {
161 printf(ARGS(lseek, "%d, %ld, %d"),
162 args->fdes, (long)args->off, args->whence);
164 tmp_args.fd = args->fdes;
165 tmp_args.offset = (off_t)args->off;
166 tmp_args.whence = args->whence;
167 error = lseek(p, &tmp_args);
173 linux_llseek(struct proc *p, struct linux_llseek_args *args)
175 struct lseek_args bsd_args;
181 printf(ARGS(llseek, "%d, %d:%d, %d"),
182 args->fd, args->ohigh, args->olow, args->whence);
184 off = (args->olow) | (((off_t) args->ohigh) << 32);
186 bsd_args.fd = args->fd;
187 bsd_args.offset = off;
188 bsd_args.whence = args->whence;
190 if ((error = lseek(p, &bsd_args)))
193 if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
199 #endif /*!__alpha__*/
203 linux_readdir(struct proc *p, struct linux_readdir_args *args)
205 struct linux_getdents_args lda;
208 lda.dent = args->dent;
210 return linux_getdents(p, &lda);
212 #endif /*!__alpha__*/
215 * Note that linux_getdents(2) and linux_getdents64(2) have the same
216 * arguments. They only differ in the definition of struct dirent they
217 * operate on. We use this to common the code, with the exception of
218 * accessing struct dirent. Note that linux_readdir(2) is implemented
219 * by means of linux_getdents(2). In this case we never operate on
220 * struct dirent64 and thus don't need to handle it...
227 char d_name[LINUX_NAME_MAX + 1];
235 char d_name[LINUX_NAME_MAX + 1];
238 #define LINUX_RECLEN(de,namlen) \
239 ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + 1))
241 #define LINUX_DIRBLKSIZ 512
244 getdents_common(struct proc *p, struct linux_getdents64_args *args,
247 register struct dirent *bdp;
249 caddr_t inp, buf; /* BSD-format */
250 int len, reclen; /* BSD-format */
251 caddr_t outp; /* Linux-format */
252 int resid, linuxreclen=0; /* Linux-format */
258 struct l_dirent linux_dirent;
259 struct l_dirent64 linux_dirent64;
260 int buflen, error, eofflag, nbytes, justone;
261 u_long *cookies = NULL, *cookiep;
264 if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0)
267 if ((fp->f_flag & FREAD) == 0)
270 vp = (struct vnode *) fp->f_data;
271 if (vp->v_type != VDIR)
274 if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
277 nbytes = args->count;
279 /* readdir(2) case. Always struct dirent. */
282 nbytes = sizeof(linux_dirent);
289 buflen = max(LINUX_DIRBLKSIZ, nbytes);
290 buflen = min(buflen, MAXBSIZE);
291 buf = malloc(buflen, M_TEMP, M_WAITOK);
292 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
296 aiov.iov_len = buflen;
297 auio.uio_iov = &aiov;
299 auio.uio_rw = UIO_READ;
300 auio.uio_segflg = UIO_SYSSPACE;
302 auio.uio_resid = buflen;
303 auio.uio_offset = off;
306 free(cookies, M_TEMP);
310 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
315 outp = (caddr_t)args->dirent;
317 if ((len = buflen - auio.uio_resid) <= 0)
324 * When using cookies, the vfs has the option of reading from
325 * a different offset than that supplied (UFS truncates the
326 * offset to a block boundary to make sure that it never reads
327 * partway through a directory entry, even if the directory
328 * has been compacted).
330 while (len > 0 && ncookies > 0 && *cookiep <= off) {
331 bdp = (struct dirent *) inp;
332 len -= bdp->d_reclen;
333 inp += bdp->d_reclen;
340 if (cookiep && ncookies == 0)
342 bdp = (struct dirent *) inp;
343 reclen = bdp->d_reclen;
349 if (bdp->d_fileno == 0) {
361 linuxreclen = (is64bit)
362 ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen)
363 : LINUX_RECLEN(&linux_dirent, bdp->d_namlen);
365 if (reclen > len || resid < linuxreclen) {
371 /* readdir(2) case. */
372 linux_dirent.d_ino = (l_long)bdp->d_fileno;
373 linux_dirent.d_off = (l_off_t)linuxreclen;
374 linux_dirent.d_reclen = (l_ushort)bdp->d_namlen;
375 strcpy(linux_dirent.d_name, bdp->d_name);
376 error = copyout(&linux_dirent, outp, linuxreclen);
379 linux_dirent64.d_ino = bdp->d_fileno;
380 linux_dirent64.d_off = (cookiep)
382 : (l_off_t)(off + reclen);
383 linux_dirent64.d_reclen =
384 (l_ushort)linuxreclen;
385 linux_dirent64.d_type = bdp->d_type;
386 strcpy(linux_dirent64.d_name, bdp->d_name);
387 error = copyout(&linux_dirent64, outp,
390 linux_dirent.d_ino = bdp->d_fileno;
391 linux_dirent.d_off = (cookiep)
393 : (l_off_t)(off + reclen);
394 linux_dirent.d_reclen = (l_ushort)linuxreclen;
395 strcpy(linux_dirent.d_name, bdp->d_name);
396 error = copyout(&linux_dirent, outp,
411 resid -= linuxreclen;
417 if (outp == (caddr_t)args->dirent)
422 nbytes = resid + linuxreclen;
425 p->p_retval[0] = nbytes - resid;
429 free(cookies, M_TEMP);
431 VOP_UNLOCK(vp, 0, p);
437 linux_getdents(struct proc *p, struct linux_getdents_args *args)
441 if (ldebug(getdents))
442 printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
445 return (getdents_common(p, (struct linux_getdents64_args*)args, 0));
449 linux_getdents64(struct proc *p, struct linux_getdents64_args *args)
453 if (ldebug(getdents64))
454 printf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
457 return (getdents_common(p, args, 1));
461 * These exist mainly for hooks for doing /compat/linux translation.
465 linux_access(struct proc *p, struct linux_access_args *args)
467 struct access_args bsd;
470 sg = stackgap_init();
471 CHECKALTEXIST(p, &sg, args->path);
475 printf(ARGS(access, "%s, %d"), args->path, args->flags);
477 bsd.path = args->path;
478 bsd.flags = args->flags;
480 return access(p, &bsd);
484 linux_unlink(struct proc *p, struct linux_unlink_args *args)
486 struct unlink_args bsd;
489 sg = stackgap_init();
490 CHECKALTEXIST(p, &sg, args->path);
494 printf(ARGS(unlink, "%s"), args->path);
496 bsd.path = args->path;
498 return unlink(p, &bsd);
502 linux_chdir(struct proc *p, struct linux_chdir_args *args)
504 struct chdir_args bsd;
507 sg = stackgap_init();
508 CHECKALTEXIST(p, &sg, args->path);
512 printf(ARGS(chdir, "%s"), args->path);
514 bsd.path = args->path;
516 return chdir(p, &bsd);
520 linux_chmod(struct proc *p, struct linux_chmod_args *args)
522 struct chmod_args bsd;
525 sg = stackgap_init();
526 CHECKALTEXIST(p, &sg, args->path);
530 printf(ARGS(chmod, "%s, %d"), args->path, args->mode);
532 bsd.path = args->path;
533 bsd.mode = args->mode;
535 return chmod(p, &bsd);
539 linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
541 struct mkdir_args bsd;
544 sg = stackgap_init();
545 CHECKALTCREAT(p, &sg, args->path);
549 printf(ARGS(mkdir, "%s, %d"), args->path, args->mode);
551 bsd.path = args->path;
552 bsd.mode = args->mode;
554 return mkdir(p, &bsd);
558 linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
560 struct rmdir_args bsd;
563 sg = stackgap_init();
564 CHECKALTEXIST(p, &sg, args->path);
568 printf(ARGS(rmdir, "%s"), args->path);
570 bsd.path = args->path;
572 return rmdir(p, &bsd);
576 linux_rename(struct proc *p, struct linux_rename_args *args)
578 struct rename_args bsd;
581 sg = stackgap_init();
582 CHECKALTEXIST(p, &sg, args->from);
583 CHECKALTCREAT(p, &sg, args->to);
587 printf(ARGS(rename, "%s, %s"), args->from, args->to);
589 bsd.from = args->from;
592 return rename(p, &bsd);
596 linux_symlink(struct proc *p, struct linux_symlink_args *args)
598 struct symlink_args bsd;
601 sg = stackgap_init();
602 CHECKALTEXIST(p, &sg, args->path);
603 CHECKALTCREAT(p, &sg, args->to);
607 printf(ARGS(symlink, "%s, %s"), args->path, args->to);
609 bsd.path = args->path;
612 return symlink(p, &bsd);
616 linux_readlink(struct proc *p, struct linux_readlink_args *args)
618 struct readlink_args bsd;
621 sg = stackgap_init();
622 CHECKALTEXIST(p, &sg, args->name);
625 if (ldebug(readlink))
626 printf(ARGS(readlink, "%s, %p, %d"),
627 args->name, (void *)args->buf, args->count);
629 bsd.path = args->name;
631 bsd.count = args->count;
633 return readlink(p, &bsd);
637 linux_truncate(struct proc *p, struct linux_truncate_args *args)
639 struct truncate_args bsd;
642 sg = stackgap_init();
643 CHECKALTEXIST(p, &sg, args->path);
646 if (ldebug(truncate))
647 printf(ARGS(truncate, "%s, %ld"), args->path,
650 bsd.path = args->path;
651 bsd.length = args->length;
653 return truncate(p, &bsd);
657 linux_link(struct proc *p, struct linux_link_args *args)
659 struct link_args bsd;
662 sg = stackgap_init();
663 CHECKALTEXIST(p, &sg, args->path);
664 CHECKALTCREAT(p, &sg, args->to);
668 printf(ARGS(link, "%s, %s"), args->path, args->to);
671 bsd.path = args->path;
674 return link(p, &bsd);
679 linux_fdatasync(p, uap)
681 struct linux_fdatasync_args *uap;
683 struct fsync_args bsd;
686 return fsync(p, &bsd);
688 #endif /*!__alpha__*/
693 struct linux_pread_args *uap;
695 struct pread_args bsd;
699 bsd.nbyte = uap->nbyte;
700 bsd.offset = uap->offset;
701 return pread(p, &bsd);
707 struct linux_pwrite_args *uap;
709 struct pwrite_args bsd;
713 bsd.nbyte = uap->nbyte;
714 bsd.offset = uap->offset;
715 return pwrite(p, &bsd);
719 linux_oldumount(struct proc *p, struct linux_oldumount_args *args)
721 struct linux_umount_args args2;
723 args2.path = args->path;
725 return (linux_umount(p, &args2));
729 linux_umount(struct proc *p, struct linux_umount_args *args)
731 struct unmount_args bsd;
733 bsd.path = args->path;
734 bsd.flags = args->flags; /* XXX correct? */
735 return (unmount(p, &bsd));
739 * fcntl family of syscalls
751 linux_to_bsd_flock(struct l_flock *linux_flock, struct flock *bsd_flock)
753 switch (linux_flock->l_type) {
755 bsd_flock->l_type = F_RDLCK;
758 bsd_flock->l_type = F_WRLCK;
761 bsd_flock->l_type = F_UNLCK;
764 bsd_flock->l_type = -1;
767 bsd_flock->l_whence = linux_flock->l_whence;
768 bsd_flock->l_start = (off_t)linux_flock->l_start;
769 bsd_flock->l_len = (off_t)linux_flock->l_len;
770 bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
774 bsd_to_linux_flock(struct flock *bsd_flock, struct l_flock *linux_flock)
776 switch (bsd_flock->l_type) {
778 linux_flock->l_type = LINUX_F_RDLCK;
781 linux_flock->l_type = LINUX_F_WRLCK;
784 linux_flock->l_type = LINUX_F_UNLCK;
787 linux_flock->l_whence = bsd_flock->l_whence;
788 linux_flock->l_start = (l_off_t)bsd_flock->l_start;
789 linux_flock->l_len = (l_off_t)bsd_flock->l_len;
790 linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
793 #if defined(__i386__)
803 linux_to_bsd_flock64(struct l_flock64 *linux_flock, struct flock *bsd_flock)
805 switch (linux_flock->l_type) {
807 bsd_flock->l_type = F_RDLCK;
810 bsd_flock->l_type = F_WRLCK;
813 bsd_flock->l_type = F_UNLCK;
816 bsd_flock->l_type = -1;
819 bsd_flock->l_whence = linux_flock->l_whence;
820 bsd_flock->l_start = (off_t)linux_flock->l_start;
821 bsd_flock->l_len = (off_t)linux_flock->l_len;
822 bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
826 bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
828 switch (bsd_flock->l_type) {
830 linux_flock->l_type = LINUX_F_RDLCK;
833 linux_flock->l_type = LINUX_F_WRLCK;
836 linux_flock->l_type = LINUX_F_UNLCK;
839 linux_flock->l_whence = bsd_flock->l_whence;
840 linux_flock->l_start = (l_loff_t)bsd_flock->l_start;
841 linux_flock->l_len = (l_loff_t)bsd_flock->l_len;
842 linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
844 #endif /* __i386__ */
846 #if defined(__alpha__)
847 #define linux_fcntl64_args linux_fcntl_args
851 fcntl_common(struct proc *p, struct linux_fcntl64_args *args)
853 struct l_flock linux_flock;
854 struct flock *bsd_flock;
855 struct fcntl_args fcntl_args;
856 struct filedesc *fdp;
861 sg = stackgap_init();
862 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
864 fcntl_args.fd = args->fd;
868 fcntl_args.cmd = F_DUPFD;
869 fcntl_args.arg = args->arg;
870 return (fcntl(p, &fcntl_args));
873 fcntl_args.cmd = F_GETFD;
874 return (fcntl(p, &fcntl_args));
877 fcntl_args.cmd = F_SETFD;
878 fcntl_args.arg = args->arg;
879 return (fcntl(p, &fcntl_args));
882 fcntl_args.cmd = F_GETFL;
883 error = fcntl(p, &fcntl_args);
884 result = p->p_retval[0];
886 if (result & O_RDONLY)
887 p->p_retval[0] |= LINUX_O_RDONLY;
888 if (result & O_WRONLY)
889 p->p_retval[0] |= LINUX_O_WRONLY;
891 p->p_retval[0] |= LINUX_O_RDWR;
892 if (result & O_NDELAY)
893 p->p_retval[0] |= LINUX_O_NONBLOCK;
894 if (result & O_APPEND)
895 p->p_retval[0] |= LINUX_O_APPEND;
896 if (result & O_FSYNC)
897 p->p_retval[0] |= LINUX_O_SYNC;
898 if (result & O_ASYNC)
899 p->p_retval[0] |= LINUX_FASYNC;
904 if (args->arg & LINUX_O_NDELAY)
905 fcntl_args.arg |= O_NONBLOCK;
906 if (args->arg & LINUX_O_APPEND)
907 fcntl_args.arg |= O_APPEND;
908 if (args->arg & LINUX_O_SYNC)
909 fcntl_args.arg |= O_FSYNC;
910 if (args->arg & LINUX_FASYNC)
911 fcntl_args.arg |= O_ASYNC;
912 fcntl_args.cmd = F_SETFL;
913 return (fcntl(p, &fcntl_args));
916 error = copyin((caddr_t)args->arg, &linux_flock,
917 sizeof(linux_flock));
920 linux_to_bsd_flock(&linux_flock, bsd_flock);
921 fcntl_args.fd = args->fd;
922 fcntl_args.cmd = F_GETLK;
923 fcntl_args.arg = (long)bsd_flock;
924 error = fcntl(p, &fcntl_args);
927 bsd_to_linux_flock(bsd_flock, &linux_flock);
928 return (copyout(&linux_flock, (caddr_t)args->arg,
929 sizeof(linux_flock)));
932 error = copyin((caddr_t)args->arg, &linux_flock,
933 sizeof(linux_flock));
936 linux_to_bsd_flock(&linux_flock, bsd_flock);
937 fcntl_args.fd = args->fd;
938 fcntl_args.cmd = F_SETLK;
939 fcntl_args.arg = (long)bsd_flock;
940 return (fcntl(p, &fcntl_args));
943 error = copyin((caddr_t)args->arg, &linux_flock,
944 sizeof(linux_flock));
947 linux_to_bsd_flock(&linux_flock, bsd_flock);
948 fcntl_args.fd = args->fd;
949 fcntl_args.cmd = F_SETLKW;
950 fcntl_args.arg = (long)bsd_flock;
951 return (fcntl(p, &fcntl_args));
954 fcntl_args.cmd = F_GETOWN;
955 return (fcntl(p, &fcntl_args));
959 * XXX some Linux applications depend on F_SETOWN having no
960 * significant effect for pipes (SIGIO is not delivered for
961 * pipes under Linux-2.2.35 at least).
964 if ((u_int)args->fd >= fdp->fd_nfiles ||
965 (fp = fdp->fd_ofiles[args->fd]) == NULL)
967 if (fp->f_type == DTYPE_PIPE)
970 fcntl_args.cmd = F_SETOWN;
971 fcntl_args.arg = args->arg;
972 return (fcntl(p, &fcntl_args));
979 linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
981 struct linux_fcntl64_args args64;
985 printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
988 args64.fd = args->fd;
989 args64.cmd = args->cmd;
990 args64.arg = args->arg;
991 return (fcntl_common(p, &args64));
994 #if defined(__i386__)
996 linux_fcntl64(struct proc *p, struct linux_fcntl64_args *args)
998 struct fcntl_args fcntl_args;
999 struct l_flock64 linux_flock;
1000 struct flock *bsd_flock;
1004 sg = stackgap_init();
1005 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
1008 if (ldebug(fcntl64))
1009 printf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd);
1012 switch (args->cmd) {
1013 case LINUX_F_GETLK64:
1014 error = copyin((caddr_t)args->arg, &linux_flock,
1015 sizeof(linux_flock));
1018 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1019 fcntl_args.fd = args->fd;
1020 fcntl_args.cmd = F_GETLK;
1021 fcntl_args.arg = (long)bsd_flock;
1022 error = fcntl(p, &fcntl_args);
1025 bsd_to_linux_flock64(bsd_flock, &linux_flock);
1026 return (copyout(&linux_flock, (caddr_t)args->arg,
1027 sizeof(linux_flock)));
1029 case LINUX_F_SETLK64:
1030 error = copyin((caddr_t)args->arg, &linux_flock,
1031 sizeof(linux_flock));
1034 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1035 fcntl_args.fd = args->fd;
1036 fcntl_args.cmd = F_SETLK;
1037 fcntl_args.arg = (long)bsd_flock;
1038 return (fcntl(p, &fcntl_args));
1040 case LINUX_F_SETLKW64:
1041 error = copyin((caddr_t)args->arg, &linux_flock,
1042 sizeof(linux_flock));
1045 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1046 fcntl_args.fd = args->fd;
1047 fcntl_args.cmd = F_SETLKW;
1048 fcntl_args.arg = (long)bsd_flock;
1049 return (fcntl(p, &fcntl_args));
1052 return (fcntl_common(p, args));
1054 #endif /* __i386__ */
1057 linux_chown(struct proc *p, struct linux_chown_args *args)
1059 struct chown_args bsd;
1062 sg = stackgap_init();
1063 CHECKALTEXIST(p, &sg, args->path);
1067 printf(ARGS(chown, "%s, %d, %d"), args->path, args->uid,
1071 bsd.path = args->path;
1072 bsd.uid = args->uid;
1073 bsd.gid = args->gid;
1074 return (chown(p, &bsd));
1078 linux_lchown(struct proc *p, struct linux_lchown_args *args)
1080 struct lchown_args bsd;
1083 sg = stackgap_init();
1084 CHECKALTEXIST(p, &sg, args->path);
1088 printf(ARGS(lchown, "%s, %d, %d"), args->path, args->uid,
1092 bsd.path = args->path;
1093 bsd.uid = args->uid;
1094 bsd.gid = args->gid;
1095 return (lchown(p, &bsd));