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.3 2003/06/23 17:55:26 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 linux_creat_args *args)
68 CHECKALTCREAT(&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(&bsd_open_args);
82 linux_open(struct linux_open_args *args)
95 if (args->flags & LINUX_O_CREAT)
96 CHECKALTCREAT(&sg, args->path);
98 CHECKALTEXIST(&sg, args->path);
102 printf(ARGS(open, "%s, 0x%x, 0x%x"),
103 args->path, args->flags, args->mode);
105 bsd_open_args.flags = 0;
106 if (args->flags & LINUX_O_RDONLY)
107 bsd_open_args.flags |= O_RDONLY;
108 if (args->flags & LINUX_O_WRONLY)
109 bsd_open_args.flags |= O_WRONLY;
110 if (args->flags & LINUX_O_RDWR)
111 bsd_open_args.flags |= O_RDWR;
112 if (args->flags & LINUX_O_NDELAY)
113 bsd_open_args.flags |= O_NONBLOCK;
114 if (args->flags & LINUX_O_APPEND)
115 bsd_open_args.flags |= O_APPEND;
116 if (args->flags & LINUX_O_SYNC)
117 bsd_open_args.flags |= O_FSYNC;
118 if (args->flags & LINUX_O_NONBLOCK)
119 bsd_open_args.flags |= O_NONBLOCK;
120 if (args->flags & LINUX_FASYNC)
121 bsd_open_args.flags |= O_ASYNC;
122 if (args->flags & LINUX_O_CREAT)
123 bsd_open_args.flags |= O_CREAT;
124 if (args->flags & LINUX_O_TRUNC)
125 bsd_open_args.flags |= O_TRUNC;
126 if (args->flags & LINUX_O_EXCL)
127 bsd_open_args.flags |= O_EXCL;
128 if (args->flags & LINUX_O_NOCTTY)
129 bsd_open_args.flags |= O_NOCTTY;
130 bsd_open_args.path = args->path;
131 bsd_open_args.mode = args->mode;
133 error = open(&bsd_open_args);
135 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
136 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
137 struct filedesc *fdp = p->p_fd;
138 struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
140 if (fp->f_type == DTYPE_VNODE)
141 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
145 printf(LMSG("open returns error %d"), error);
151 linux_lseek(struct linux_lseek_args *args)
154 struct lseek_args /* {
164 printf(ARGS(lseek, "%d, %ld, %d"),
165 args->fdes, (long)args->off, args->whence);
167 tmp_args.fd = args->fdes;
168 tmp_args.offset = (off_t)args->off;
169 tmp_args.whence = args->whence;
170 error = lseek(&tmp_args);
176 linux_llseek(struct linux_llseek_args *args)
178 struct proc *p = curproc;
179 struct lseek_args bsd_args;
185 printf(ARGS(llseek, "%d, %d:%d, %d"),
186 args->fd, args->ohigh, args->olow, args->whence);
188 off = (args->olow) | (((off_t) args->ohigh) << 32);
190 bsd_args.fd = args->fd;
191 bsd_args.offset = off;
192 bsd_args.whence = args->whence;
194 if ((error = lseek(&bsd_args)))
197 if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
203 #endif /*!__alpha__*/
207 linux_readdir(struct linux_readdir_args *args)
209 struct linux_getdents_args lda;
212 lda.dent = args->dent;
214 return linux_getdents(&lda);
216 #endif /*!__alpha__*/
219 * Note that linux_getdents(2) and linux_getdents64(2) have the same
220 * arguments. They only differ in the definition of struct dirent they
221 * operate on. We use this to common the code, with the exception of
222 * accessing struct dirent. Note that linux_readdir(2) is implemented
223 * by means of linux_getdents(2). In this case we never operate on
224 * struct dirent64 and thus don't need to handle it...
231 char d_name[LINUX_NAME_MAX + 1];
239 char d_name[LINUX_NAME_MAX + 1];
242 #define LINUX_RECLEN(de,namlen) \
243 ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + 1))
245 #define LINUX_DIRBLKSIZ 512
248 getdents_common(struct linux_getdents64_args *args, int is64bit)
250 struct proc *p = curproc;
253 caddr_t inp, buf; /* BSD-format */
254 int len, reclen; /* BSD-format */
255 caddr_t outp; /* Linux-format */
256 int resid, linuxreclen=0; /* Linux-format */
262 struct l_dirent linux_dirent;
263 struct l_dirent64 linux_dirent64;
264 int buflen, error, eofflag, nbytes, justone;
265 u_long *cookies = NULL, *cookiep;
268 if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0)
271 if ((fp->f_flag & FREAD) == 0)
274 vp = (struct vnode *) fp->f_data;
275 if (vp->v_type != VDIR)
278 if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
281 nbytes = args->count;
283 /* readdir(2) case. Always struct dirent. */
286 nbytes = sizeof(linux_dirent);
293 buflen = max(LINUX_DIRBLKSIZ, nbytes);
294 buflen = min(buflen, MAXBSIZE);
295 buf = malloc(buflen, M_TEMP, M_WAITOK);
296 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
300 aiov.iov_len = buflen;
301 auio.uio_iov = &aiov;
303 auio.uio_rw = UIO_READ;
304 auio.uio_segflg = UIO_SYSSPACE;
306 auio.uio_resid = buflen;
307 auio.uio_offset = off;
310 free(cookies, M_TEMP);
314 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
319 outp = (caddr_t)args->dirent;
321 if ((len = buflen - auio.uio_resid) <= 0)
328 * When using cookies, the vfs has the option of reading from
329 * a different offset than that supplied (UFS truncates the
330 * offset to a block boundary to make sure that it never reads
331 * partway through a directory entry, even if the directory
332 * has been compacted).
334 while (len > 0 && ncookies > 0 && *cookiep <= off) {
335 bdp = (struct dirent *) inp;
336 len -= bdp->d_reclen;
337 inp += bdp->d_reclen;
344 if (cookiep && ncookies == 0)
346 bdp = (struct dirent *) inp;
347 reclen = bdp->d_reclen;
353 if (bdp->d_fileno == 0) {
365 linuxreclen = (is64bit)
366 ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen)
367 : LINUX_RECLEN(&linux_dirent, bdp->d_namlen);
369 if (reclen > len || resid < linuxreclen) {
375 /* readdir(2) case. */
376 linux_dirent.d_ino = (l_long)bdp->d_fileno;
377 linux_dirent.d_off = (l_off_t)linuxreclen;
378 linux_dirent.d_reclen = (l_ushort)bdp->d_namlen;
379 strcpy(linux_dirent.d_name, bdp->d_name);
380 error = copyout(&linux_dirent, outp, linuxreclen);
383 linux_dirent64.d_ino = bdp->d_fileno;
384 linux_dirent64.d_off = (cookiep)
386 : (l_off_t)(off + reclen);
387 linux_dirent64.d_reclen =
388 (l_ushort)linuxreclen;
389 linux_dirent64.d_type = bdp->d_type;
390 strcpy(linux_dirent64.d_name, bdp->d_name);
391 error = copyout(&linux_dirent64, outp,
394 linux_dirent.d_ino = bdp->d_fileno;
395 linux_dirent.d_off = (cookiep)
397 : (l_off_t)(off + reclen);
398 linux_dirent.d_reclen = (l_ushort)linuxreclen;
399 strcpy(linux_dirent.d_name, bdp->d_name);
400 error = copyout(&linux_dirent, outp,
415 resid -= linuxreclen;
421 if (outp == (caddr_t)args->dirent)
426 nbytes = resid + linuxreclen;
429 p->p_retval[0] = nbytes - resid;
433 free(cookies, M_TEMP);
435 VOP_UNLOCK(vp, 0, p);
441 linux_getdents(struct linux_getdents_args *args)
444 if (ldebug(getdents))
445 printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
447 return (getdents_common((struct linux_getdents64_args*)args, 0));
451 linux_getdents64(struct linux_getdents64_args *args)
454 if (ldebug(getdents64))
455 printf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
457 return (getdents_common(args, 1));
461 * These exist mainly for hooks for doing /compat/linux translation.
465 linux_access(struct linux_access_args *args)
467 struct access_args bsd;
470 sg = stackgap_init();
471 CHECKALTEXIST(&sg, args->path);
475 printf(ARGS(access, "%s, %d"), args->path, args->flags);
477 bsd.path = args->path;
478 bsd.flags = args->flags;
484 linux_unlink(struct linux_unlink_args *args)
486 struct unlink_args bsd;
489 sg = stackgap_init();
490 CHECKALTEXIST(&sg, args->path);
494 printf(ARGS(unlink, "%s"), args->path);
496 bsd.path = args->path;
502 linux_chdir(struct linux_chdir_args *args)
504 struct chdir_args bsd;
507 sg = stackgap_init();
508 CHECKALTEXIST(&sg, args->path);
512 printf(ARGS(chdir, "%s"), args->path);
514 bsd.path = args->path;
520 linux_chmod(struct linux_chmod_args *args)
522 struct chmod_args bsd;
525 sg = stackgap_init();
526 CHECKALTEXIST(&sg, args->path);
530 printf(ARGS(chmod, "%s, %d"), args->path, args->mode);
532 bsd.path = args->path;
533 bsd.mode = args->mode;
539 linux_mkdir(struct linux_mkdir_args *args)
541 struct mkdir_args bsd;
544 sg = stackgap_init();
545 CHECKALTCREAT(&sg, args->path);
549 printf(ARGS(mkdir, "%s, %d"), args->path, args->mode);
551 bsd.path = args->path;
552 bsd.mode = args->mode;
558 linux_rmdir(struct linux_rmdir_args *args)
560 struct rmdir_args bsd;
563 sg = stackgap_init();
564 CHECKALTEXIST(&sg, args->path);
568 printf(ARGS(rmdir, "%s"), args->path);
570 bsd.path = args->path;
576 linux_rename(struct linux_rename_args *args)
578 struct rename_args bsd;
581 sg = stackgap_init();
582 CHECKALTEXIST(&sg, args->from);
583 CHECKALTCREAT(&sg, args->to);
587 printf(ARGS(rename, "%s, %s"), args->from, args->to);
589 bsd.from = args->from;
596 linux_symlink(struct linux_symlink_args *args)
598 struct symlink_args bsd;
601 sg = stackgap_init();
602 CHECKALTEXIST(&sg, args->path);
603 CHECKALTCREAT(&sg, args->to);
607 printf(ARGS(symlink, "%s, %s"), args->path, args->to);
609 bsd.path = args->path;
612 return symlink(&bsd);
616 linux_readlink(struct linux_readlink_args *args)
618 struct readlink_args bsd;
621 sg = stackgap_init();
622 CHECKALTEXIST(&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(&bsd);
637 linux_truncate(struct linux_truncate_args *args)
639 struct truncate_args bsd;
642 sg = stackgap_init();
643 CHECKALTEXIST(&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(&bsd);
657 linux_link(struct linux_link_args *args)
659 struct link_args bsd;
662 sg = stackgap_init();
663 CHECKALTEXIST(&sg, args->path);
664 CHECKALTCREAT(&sg, args->to);
668 printf(ARGS(link, "%s, %s"), args->path, args->to);
671 bsd.path = args->path;
679 linux_fdatasync(struct linux_fdatasync_args *uap)
681 struct fsync_args bsd;
686 #endif /*!__alpha__*/
689 linux_pread(struct linux_pread_args *uap)
691 struct pread_args bsd;
695 bsd.nbyte = uap->nbyte;
696 bsd.offset = uap->offset;
701 linux_pwrite(struct linux_pwrite_args *uap)
703 struct pwrite_args bsd;
707 bsd.nbyte = uap->nbyte;
708 bsd.offset = uap->offset;
713 linux_oldumount(struct linux_oldumount_args *args)
715 struct linux_umount_args args2;
717 args2.path = args->path;
719 return (linux_umount(&args2));
723 linux_umount(struct linux_umount_args *args)
725 struct unmount_args bsd;
727 bsd.path = args->path;
728 bsd.flags = args->flags; /* XXX correct? */
729 return (unmount(&bsd));
733 * fcntl family of syscalls
745 linux_to_bsd_flock(struct l_flock *linux_flock, struct flock *bsd_flock)
747 switch (linux_flock->l_type) {
749 bsd_flock->l_type = F_RDLCK;
752 bsd_flock->l_type = F_WRLCK;
755 bsd_flock->l_type = F_UNLCK;
758 bsd_flock->l_type = -1;
761 bsd_flock->l_whence = linux_flock->l_whence;
762 bsd_flock->l_start = (off_t)linux_flock->l_start;
763 bsd_flock->l_len = (off_t)linux_flock->l_len;
764 bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
768 bsd_to_linux_flock(struct flock *bsd_flock, struct l_flock *linux_flock)
770 switch (bsd_flock->l_type) {
772 linux_flock->l_type = LINUX_F_RDLCK;
775 linux_flock->l_type = LINUX_F_WRLCK;
778 linux_flock->l_type = LINUX_F_UNLCK;
781 linux_flock->l_whence = bsd_flock->l_whence;
782 linux_flock->l_start = (l_off_t)bsd_flock->l_start;
783 linux_flock->l_len = (l_off_t)bsd_flock->l_len;
784 linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
787 #if defined(__i386__)
797 linux_to_bsd_flock64(struct l_flock64 *linux_flock, struct flock *bsd_flock)
799 switch (linux_flock->l_type) {
801 bsd_flock->l_type = F_RDLCK;
804 bsd_flock->l_type = F_WRLCK;
807 bsd_flock->l_type = F_UNLCK;
810 bsd_flock->l_type = -1;
813 bsd_flock->l_whence = linux_flock->l_whence;
814 bsd_flock->l_start = (off_t)linux_flock->l_start;
815 bsd_flock->l_len = (off_t)linux_flock->l_len;
816 bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
820 bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
822 switch (bsd_flock->l_type) {
824 linux_flock->l_type = LINUX_F_RDLCK;
827 linux_flock->l_type = LINUX_F_WRLCK;
830 linux_flock->l_type = LINUX_F_UNLCK;
833 linux_flock->l_whence = bsd_flock->l_whence;
834 linux_flock->l_start = (l_loff_t)bsd_flock->l_start;
835 linux_flock->l_len = (l_loff_t)bsd_flock->l_len;
836 linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid;
838 #endif /* __i386__ */
840 #if defined(__alpha__)
841 #define linux_fcntl64_args linux_fcntl_args
845 fcntl_common(struct linux_fcntl64_args *args)
847 struct proc *p = curproc;
848 struct l_flock linux_flock;
849 struct flock *bsd_flock;
850 struct fcntl_args fcntl_args;
851 struct filedesc *fdp;
856 sg = stackgap_init();
857 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
859 fcntl_args.fd = args->fd;
863 fcntl_args.cmd = F_DUPFD;
864 fcntl_args.arg = args->arg;
865 return (fcntl(&fcntl_args));
868 fcntl_args.cmd = F_GETFD;
869 return (fcntl(&fcntl_args));
872 fcntl_args.cmd = F_SETFD;
873 fcntl_args.arg = args->arg;
874 return (fcntl(&fcntl_args));
877 fcntl_args.cmd = F_GETFL;
878 error = fcntl(&fcntl_args);
879 result = p->p_retval[0];
881 if (result & O_RDONLY)
882 p->p_retval[0] |= LINUX_O_RDONLY;
883 if (result & O_WRONLY)
884 p->p_retval[0] |= LINUX_O_WRONLY;
886 p->p_retval[0] |= LINUX_O_RDWR;
887 if (result & O_NDELAY)
888 p->p_retval[0] |= LINUX_O_NONBLOCK;
889 if (result & O_APPEND)
890 p->p_retval[0] |= LINUX_O_APPEND;
891 if (result & O_FSYNC)
892 p->p_retval[0] |= LINUX_O_SYNC;
893 if (result & O_ASYNC)
894 p->p_retval[0] |= LINUX_FASYNC;
899 if (args->arg & LINUX_O_NDELAY)
900 fcntl_args.arg |= O_NONBLOCK;
901 if (args->arg & LINUX_O_APPEND)
902 fcntl_args.arg |= O_APPEND;
903 if (args->arg & LINUX_O_SYNC)
904 fcntl_args.arg |= O_FSYNC;
905 if (args->arg & LINUX_FASYNC)
906 fcntl_args.arg |= O_ASYNC;
907 fcntl_args.cmd = F_SETFL;
908 return (fcntl(&fcntl_args));
911 error = copyin((caddr_t)args->arg, &linux_flock,
912 sizeof(linux_flock));
915 linux_to_bsd_flock(&linux_flock, bsd_flock);
916 fcntl_args.fd = args->fd;
917 fcntl_args.cmd = F_GETLK;
918 fcntl_args.arg = (long)bsd_flock;
919 error = fcntl(&fcntl_args);
922 bsd_to_linux_flock(bsd_flock, &linux_flock);
923 return (copyout(&linux_flock, (caddr_t)args->arg,
924 sizeof(linux_flock)));
927 error = copyin((caddr_t)args->arg, &linux_flock,
928 sizeof(linux_flock));
931 linux_to_bsd_flock(&linux_flock, bsd_flock);
932 fcntl_args.fd = args->fd;
933 fcntl_args.cmd = F_SETLK;
934 fcntl_args.arg = (long)bsd_flock;
935 return (fcntl(&fcntl_args));
938 error = copyin((caddr_t)args->arg, &linux_flock,
939 sizeof(linux_flock));
942 linux_to_bsd_flock(&linux_flock, bsd_flock);
943 fcntl_args.fd = args->fd;
944 fcntl_args.cmd = F_SETLKW;
945 fcntl_args.arg = (long)bsd_flock;
946 return (fcntl(&fcntl_args));
949 fcntl_args.cmd = F_GETOWN;
950 return (fcntl(&fcntl_args));
954 * XXX some Linux applications depend on F_SETOWN having no
955 * significant effect for pipes (SIGIO is not delivered for
956 * pipes under Linux-2.2.35 at least).
959 if ((u_int)args->fd >= fdp->fd_nfiles ||
960 (fp = fdp->fd_ofiles[args->fd]) == NULL)
962 if (fp->f_type == DTYPE_PIPE)
965 fcntl_args.cmd = F_SETOWN;
966 fcntl_args.arg = args->arg;
967 return (fcntl(&fcntl_args));
974 linux_fcntl(struct linux_fcntl_args *args)
976 struct linux_fcntl64_args args64;
980 printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
983 args64.fd = args->fd;
984 args64.cmd = args->cmd;
985 args64.arg = args->arg;
986 return (fcntl_common(&args64));
989 #if defined(__i386__)
991 linux_fcntl64(struct linux_fcntl64_args *args)
993 struct fcntl_args fcntl_args;
994 struct l_flock64 linux_flock;
995 struct flock *bsd_flock;
999 sg = stackgap_init();
1000 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
1003 if (ldebug(fcntl64))
1004 printf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd);
1007 switch (args->cmd) {
1008 case LINUX_F_GETLK64:
1009 error = copyin((caddr_t)args->arg, &linux_flock,
1010 sizeof(linux_flock));
1013 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1014 fcntl_args.fd = args->fd;
1015 fcntl_args.cmd = F_GETLK;
1016 fcntl_args.arg = (long)bsd_flock;
1017 error = fcntl(&fcntl_args);
1020 bsd_to_linux_flock64(bsd_flock, &linux_flock);
1021 return (copyout(&linux_flock, (caddr_t)args->arg,
1022 sizeof(linux_flock)));
1024 case LINUX_F_SETLK64:
1025 error = copyin((caddr_t)args->arg, &linux_flock,
1026 sizeof(linux_flock));
1029 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1030 fcntl_args.fd = args->fd;
1031 fcntl_args.cmd = F_SETLK;
1032 fcntl_args.arg = (long)bsd_flock;
1033 return (fcntl(&fcntl_args));
1035 case LINUX_F_SETLKW64:
1036 error = copyin((caddr_t)args->arg, &linux_flock,
1037 sizeof(linux_flock));
1040 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1041 fcntl_args.fd = args->fd;
1042 fcntl_args.cmd = F_SETLKW;
1043 fcntl_args.arg = (long)bsd_flock;
1044 return (fcntl(&fcntl_args));
1047 return (fcntl_common(args));
1049 #endif /* __i386__ */
1052 linux_chown(struct linux_chown_args *args)
1054 struct chown_args bsd;
1057 sg = stackgap_init();
1058 CHECKALTEXIST(&sg, args->path);
1062 printf(ARGS(chown, "%s, %d, %d"), args->path, args->uid,
1066 bsd.path = args->path;
1067 bsd.uid = args->uid;
1068 bsd.gid = args->gid;
1069 return (chown(&bsd));
1073 linux_lchown(struct linux_lchown_args *args)
1075 struct lchown_args bsd;
1078 sg = stackgap_init();
1079 CHECKALTEXIST(&sg, args->path);
1083 printf(ARGS(lchown, "%s, %d, %d"), args->path, args->uid,
1087 bsd.path = args->path;
1088 bsd.uid = args->uid;
1089 bsd.gid = args->gid;
1090 return (lchown(&bsd));