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.5 2003/06/26 05:55:10 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 <sys/file2.h>
54 #include <machine/../linux/linux.h>
55 #include <machine/../linux/linux_proto.h>
56 #include <compat/linux/linux_util.h>
60 linux_creat(struct linux_creat_args *args)
70 CHECKALTCREAT(&sg, args->path);
74 printf(ARGS(creat, "%s, %d"), args->path, args->mode);
76 bsd_open_args.path = args->path;
77 bsd_open_args.mode = args->mode;
78 bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC;
79 return open(&bsd_open_args);
84 linux_open(struct linux_open_args *args)
93 struct thread *td = curthread;
94 struct proc *p = td->td_proc;
100 if (args->flags & LINUX_O_CREAT)
101 CHECKALTCREAT(&sg, args->path);
103 CHECKALTEXIST(&sg, args->path);
107 printf(ARGS(open, "%s, 0x%x, 0x%x"),
108 args->path, args->flags, args->mode);
110 bsd_open_args.flags = 0;
111 if (args->flags & LINUX_O_RDONLY)
112 bsd_open_args.flags |= O_RDONLY;
113 if (args->flags & LINUX_O_WRONLY)
114 bsd_open_args.flags |= O_WRONLY;
115 if (args->flags & LINUX_O_RDWR)
116 bsd_open_args.flags |= O_RDWR;
117 if (args->flags & LINUX_O_NDELAY)
118 bsd_open_args.flags |= O_NONBLOCK;
119 if (args->flags & LINUX_O_APPEND)
120 bsd_open_args.flags |= O_APPEND;
121 if (args->flags & LINUX_O_SYNC)
122 bsd_open_args.flags |= O_FSYNC;
123 if (args->flags & LINUX_O_NONBLOCK)
124 bsd_open_args.flags |= O_NONBLOCK;
125 if (args->flags & LINUX_FASYNC)
126 bsd_open_args.flags |= O_ASYNC;
127 if (args->flags & LINUX_O_CREAT)
128 bsd_open_args.flags |= O_CREAT;
129 if (args->flags & LINUX_O_TRUNC)
130 bsd_open_args.flags |= O_TRUNC;
131 if (args->flags & LINUX_O_EXCL)
132 bsd_open_args.flags |= O_EXCL;
133 if (args->flags & LINUX_O_NOCTTY)
134 bsd_open_args.flags |= O_NOCTTY;
135 bsd_open_args.path = args->path;
136 bsd_open_args.mode = args->mode;
138 error = open(&bsd_open_args);
139 if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
140 SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
141 struct filedesc *fdp = p->p_fd;
142 struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
144 if (fp->f_type == DTYPE_VNODE)
145 fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td);
149 printf(LMSG("open returns error %d"), error);
155 linux_lseek(struct linux_lseek_args *args)
158 struct lseek_args /* {
168 printf(ARGS(lseek, "%d, %ld, %d"),
169 args->fdes, (long)args->off, args->whence);
171 tmp_args.fd = args->fdes;
172 tmp_args.offset = (off_t)args->off;
173 tmp_args.whence = args->whence;
174 error = lseek(&tmp_args);
180 linux_llseek(struct linux_llseek_args *args)
182 struct proc *p = curproc;
183 struct lseek_args bsd_args;
189 printf(ARGS(llseek, "%d, %d:%d, %d"),
190 args->fd, args->ohigh, args->olow, args->whence);
192 off = (args->olow) | (((off_t) args->ohigh) << 32);
194 bsd_args.fd = args->fd;
195 bsd_args.offset = off;
196 bsd_args.whence = args->whence;
198 if ((error = lseek(&bsd_args)))
201 if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
207 #endif /*!__alpha__*/
211 linux_readdir(struct linux_readdir_args *args)
213 struct linux_getdents_args lda;
216 lda.dent = args->dent;
218 return linux_getdents(&lda);
220 #endif /*!__alpha__*/
223 * Note that linux_getdents(2) and linux_getdents64(2) have the same
224 * arguments. They only differ in the definition of struct dirent they
225 * operate on. We use this to common the code, with the exception of
226 * accessing struct dirent. Note that linux_readdir(2) is implemented
227 * by means of linux_getdents(2). In this case we never operate on
228 * struct dirent64 and thus don't need to handle it...
235 char d_name[LINUX_NAME_MAX + 1];
243 char d_name[LINUX_NAME_MAX + 1];
246 #define LINUX_RECLEN(de,namlen) \
247 ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + 1))
249 #define LINUX_DIRBLKSIZ 512
252 getdents_common(struct linux_getdents64_args *args, int is64bit)
254 struct thread *td = curthread;
255 struct proc *p = td->td_proc;
258 caddr_t inp, buf; /* BSD-format */
259 int len, reclen; /* BSD-format */
260 caddr_t outp; /* Linux-format */
261 int resid, linuxreclen=0; /* Linux-format */
267 struct l_dirent linux_dirent;
268 struct l_dirent64 linux_dirent64;
269 int buflen, error, eofflag, nbytes, justone;
270 u_long *cookies = NULL, *cookiep;
275 if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0)
278 if ((fp->f_flag & FREAD) == 0)
281 vp = (struct vnode *) fp->f_data;
282 if (vp->v_type != VDIR)
285 if ((error = VOP_GETATTR(vp, &va, td)))
288 nbytes = args->count;
290 /* readdir(2) case. Always struct dirent. */
293 nbytes = sizeof(linux_dirent);
300 buflen = max(LINUX_DIRBLKSIZ, nbytes);
301 buflen = min(buflen, MAXBSIZE);
302 buf = malloc(buflen, M_TEMP, M_WAITOK);
303 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
307 aiov.iov_len = buflen;
308 auio.uio_iov = &aiov;
310 auio.uio_rw = UIO_READ;
311 auio.uio_segflg = UIO_SYSSPACE;
313 auio.uio_resid = buflen;
314 auio.uio_offset = off;
317 free(cookies, M_TEMP);
321 if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
326 outp = (caddr_t)args->dirent;
328 if ((len = buflen - auio.uio_resid) <= 0)
335 * When using cookies, the vfs has the option of reading from
336 * a different offset than that supplied (UFS truncates the
337 * offset to a block boundary to make sure that it never reads
338 * partway through a directory entry, even if the directory
339 * has been compacted).
341 while (len > 0 && ncookies > 0 && *cookiep <= off) {
342 bdp = (struct dirent *) inp;
343 len -= bdp->d_reclen;
344 inp += bdp->d_reclen;
351 if (cookiep && ncookies == 0)
353 bdp = (struct dirent *) inp;
354 reclen = bdp->d_reclen;
360 if (bdp->d_fileno == 0) {
372 linuxreclen = (is64bit)
373 ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen)
374 : LINUX_RECLEN(&linux_dirent, bdp->d_namlen);
376 if (reclen > len || resid < linuxreclen) {
382 /* readdir(2) case. */
383 linux_dirent.d_ino = (l_long)bdp->d_fileno;
384 linux_dirent.d_off = (l_off_t)linuxreclen;
385 linux_dirent.d_reclen = (l_ushort)bdp->d_namlen;
386 strcpy(linux_dirent.d_name, bdp->d_name);
387 error = copyout(&linux_dirent, outp, linuxreclen);
390 linux_dirent64.d_ino = bdp->d_fileno;
391 linux_dirent64.d_off = (cookiep)
393 : (l_off_t)(off + reclen);
394 linux_dirent64.d_reclen =
395 (l_ushort)linuxreclen;
396 linux_dirent64.d_type = bdp->d_type;
397 strcpy(linux_dirent64.d_name, bdp->d_name);
398 error = copyout(&linux_dirent64, outp,
401 linux_dirent.d_ino = bdp->d_fileno;
402 linux_dirent.d_off = (cookiep)
404 : (l_off_t)(off + reclen);
405 linux_dirent.d_reclen = (l_ushort)linuxreclen;
406 strcpy(linux_dirent.d_name, bdp->d_name);
407 error = copyout(&linux_dirent, outp,
422 resid -= linuxreclen;
428 if (outp == (caddr_t)args->dirent)
433 nbytes = resid + linuxreclen;
436 p->p_retval[0] = nbytes - resid;
440 free(cookies, M_TEMP);
442 VOP_UNLOCK(vp, 0, td);
448 linux_getdents(struct linux_getdents_args *args)
451 if (ldebug(getdents))
452 printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
454 return (getdents_common((struct linux_getdents64_args*)args, 0));
458 linux_getdents64(struct linux_getdents64_args *args)
461 if (ldebug(getdents64))
462 printf(ARGS(getdents64, "%d, *, %d"), args->fd, args->count);
464 return (getdents_common(args, 1));
468 * These exist mainly for hooks for doing /compat/linux translation.
472 linux_access(struct linux_access_args *args)
474 struct access_args bsd;
477 sg = stackgap_init();
478 CHECKALTEXIST(&sg, args->path);
482 printf(ARGS(access, "%s, %d"), args->path, args->flags);
484 bsd.path = args->path;
485 bsd.flags = args->flags;
491 linux_unlink(struct linux_unlink_args *args)
493 struct unlink_args bsd;
496 sg = stackgap_init();
497 CHECKALTEXIST(&sg, args->path);
501 printf(ARGS(unlink, "%s"), args->path);
503 bsd.path = args->path;
509 linux_chdir(struct linux_chdir_args *args)
511 struct chdir_args bsd;
514 sg = stackgap_init();
515 CHECKALTEXIST(&sg, args->path);
519 printf(ARGS(chdir, "%s"), args->path);
521 bsd.path = args->path;
527 linux_chmod(struct linux_chmod_args *args)
529 struct chmod_args bsd;
532 sg = stackgap_init();
533 CHECKALTEXIST(&sg, args->path);
537 printf(ARGS(chmod, "%s, %d"), args->path, args->mode);
539 bsd.path = args->path;
540 bsd.mode = args->mode;
546 linux_mkdir(struct linux_mkdir_args *args)
548 struct mkdir_args bsd;
551 sg = stackgap_init();
552 CHECKALTCREAT(&sg, args->path);
556 printf(ARGS(mkdir, "%s, %d"), args->path, args->mode);
558 bsd.path = args->path;
559 bsd.mode = args->mode;
565 linux_rmdir(struct linux_rmdir_args *args)
567 struct rmdir_args bsd;
570 sg = stackgap_init();
571 CHECKALTEXIST(&sg, args->path);
575 printf(ARGS(rmdir, "%s"), args->path);
577 bsd.path = args->path;
583 linux_rename(struct linux_rename_args *args)
585 struct rename_args bsd;
588 sg = stackgap_init();
589 CHECKALTEXIST(&sg, args->from);
590 CHECKALTCREAT(&sg, args->to);
594 printf(ARGS(rename, "%s, %s"), args->from, args->to);
596 bsd.from = args->from;
603 linux_symlink(struct linux_symlink_args *args)
605 struct symlink_args bsd;
608 sg = stackgap_init();
609 CHECKALTEXIST(&sg, args->path);
610 CHECKALTCREAT(&sg, args->to);
614 printf(ARGS(symlink, "%s, %s"), args->path, args->to);
616 bsd.path = args->path;
619 return symlink(&bsd);
623 linux_readlink(struct linux_readlink_args *args)
625 struct readlink_args bsd;
628 sg = stackgap_init();
629 CHECKALTEXIST(&sg, args->name);
632 if (ldebug(readlink))
633 printf(ARGS(readlink, "%s, %p, %d"),
634 args->name, (void *)args->buf, args->count);
636 bsd.path = args->name;
638 bsd.count = args->count;
640 return readlink(&bsd);
644 linux_truncate(struct linux_truncate_args *args)
646 struct truncate_args bsd;
649 sg = stackgap_init();
650 CHECKALTEXIST(&sg, args->path);
653 if (ldebug(truncate))
654 printf(ARGS(truncate, "%s, %ld"), args->path,
657 bsd.path = args->path;
658 bsd.length = args->length;
660 return truncate(&bsd);
664 linux_link(struct linux_link_args *args)
666 struct link_args bsd;
669 sg = stackgap_init();
670 CHECKALTEXIST(&sg, args->path);
671 CHECKALTCREAT(&sg, args->to);
675 printf(ARGS(link, "%s, %s"), args->path, args->to);
678 bsd.path = args->path;
686 linux_fdatasync(struct linux_fdatasync_args *uap)
688 struct fsync_args bsd;
693 #endif /*!__alpha__*/
696 linux_pread(struct linux_pread_args *uap)
698 struct pread_args bsd;
702 bsd.nbyte = uap->nbyte;
703 bsd.offset = uap->offset;
708 linux_pwrite(struct linux_pwrite_args *uap)
710 struct pwrite_args bsd;
714 bsd.nbyte = uap->nbyte;
715 bsd.offset = uap->offset;
720 linux_oldumount(struct linux_oldumount_args *args)
722 struct linux_umount_args args2;
724 args2.path = args->path;
726 return (linux_umount(&args2));
730 linux_umount(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(&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 linux_fcntl64_args *args)
854 struct proc *p = curproc;
855 struct l_flock linux_flock;
856 struct flock *bsd_flock;
857 struct fcntl_args fcntl_args;
858 struct filedesc *fdp;
863 sg = stackgap_init();
864 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
866 fcntl_args.fd = args->fd;
870 fcntl_args.cmd = F_DUPFD;
871 fcntl_args.arg = args->arg;
872 return (fcntl(&fcntl_args));
875 fcntl_args.cmd = F_GETFD;
876 return (fcntl(&fcntl_args));
879 fcntl_args.cmd = F_SETFD;
880 fcntl_args.arg = args->arg;
881 return (fcntl(&fcntl_args));
884 fcntl_args.cmd = F_GETFL;
885 error = fcntl(&fcntl_args);
886 result = p->p_retval[0];
888 if (result & O_RDONLY)
889 p->p_retval[0] |= LINUX_O_RDONLY;
890 if (result & O_WRONLY)
891 p->p_retval[0] |= LINUX_O_WRONLY;
893 p->p_retval[0] |= LINUX_O_RDWR;
894 if (result & O_NDELAY)
895 p->p_retval[0] |= LINUX_O_NONBLOCK;
896 if (result & O_APPEND)
897 p->p_retval[0] |= LINUX_O_APPEND;
898 if (result & O_FSYNC)
899 p->p_retval[0] |= LINUX_O_SYNC;
900 if (result & O_ASYNC)
901 p->p_retval[0] |= LINUX_FASYNC;
906 if (args->arg & LINUX_O_NDELAY)
907 fcntl_args.arg |= O_NONBLOCK;
908 if (args->arg & LINUX_O_APPEND)
909 fcntl_args.arg |= O_APPEND;
910 if (args->arg & LINUX_O_SYNC)
911 fcntl_args.arg |= O_FSYNC;
912 if (args->arg & LINUX_FASYNC)
913 fcntl_args.arg |= O_ASYNC;
914 fcntl_args.cmd = F_SETFL;
915 return (fcntl(&fcntl_args));
918 error = copyin((caddr_t)args->arg, &linux_flock,
919 sizeof(linux_flock));
922 linux_to_bsd_flock(&linux_flock, bsd_flock);
923 fcntl_args.fd = args->fd;
924 fcntl_args.cmd = F_GETLK;
925 fcntl_args.arg = (long)bsd_flock;
926 error = fcntl(&fcntl_args);
929 bsd_to_linux_flock(bsd_flock, &linux_flock);
930 return (copyout(&linux_flock, (caddr_t)args->arg,
931 sizeof(linux_flock)));
934 error = copyin((caddr_t)args->arg, &linux_flock,
935 sizeof(linux_flock));
938 linux_to_bsd_flock(&linux_flock, bsd_flock);
939 fcntl_args.fd = args->fd;
940 fcntl_args.cmd = F_SETLK;
941 fcntl_args.arg = (long)bsd_flock;
942 return (fcntl(&fcntl_args));
945 error = copyin((caddr_t)args->arg, &linux_flock,
946 sizeof(linux_flock));
949 linux_to_bsd_flock(&linux_flock, bsd_flock);
950 fcntl_args.fd = args->fd;
951 fcntl_args.cmd = F_SETLKW;
952 fcntl_args.arg = (long)bsd_flock;
953 return (fcntl(&fcntl_args));
956 fcntl_args.cmd = F_GETOWN;
957 return (fcntl(&fcntl_args));
961 * XXX some Linux applications depend on F_SETOWN having no
962 * significant effect for pipes (SIGIO is not delivered for
963 * pipes under Linux-2.2.35 at least).
966 if ((u_int)args->fd >= fdp->fd_nfiles ||
967 (fp = fdp->fd_ofiles[args->fd]) == NULL)
969 if (fp->f_type == DTYPE_PIPE)
972 fcntl_args.cmd = F_SETOWN;
973 fcntl_args.arg = args->arg;
974 return (fcntl(&fcntl_args));
981 linux_fcntl(struct linux_fcntl_args *args)
983 struct linux_fcntl64_args args64;
987 printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
990 args64.fd = args->fd;
991 args64.cmd = args->cmd;
992 args64.arg = args->arg;
993 return (fcntl_common(&args64));
996 #if defined(__i386__)
998 linux_fcntl64(struct linux_fcntl64_args *args)
1000 struct fcntl_args fcntl_args;
1001 struct l_flock64 linux_flock;
1002 struct flock *bsd_flock;
1006 sg = stackgap_init();
1007 bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(bsd_flock));
1010 if (ldebug(fcntl64))
1011 printf(ARGS(fcntl64, "%d, %08x, *"), args->fd, args->cmd);
1014 switch (args->cmd) {
1015 case LINUX_F_GETLK64:
1016 error = copyin((caddr_t)args->arg, &linux_flock,
1017 sizeof(linux_flock));
1020 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1021 fcntl_args.fd = args->fd;
1022 fcntl_args.cmd = F_GETLK;
1023 fcntl_args.arg = (long)bsd_flock;
1024 error = fcntl(&fcntl_args);
1027 bsd_to_linux_flock64(bsd_flock, &linux_flock);
1028 return (copyout(&linux_flock, (caddr_t)args->arg,
1029 sizeof(linux_flock)));
1031 case LINUX_F_SETLK64:
1032 error = copyin((caddr_t)args->arg, &linux_flock,
1033 sizeof(linux_flock));
1036 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1037 fcntl_args.fd = args->fd;
1038 fcntl_args.cmd = F_SETLK;
1039 fcntl_args.arg = (long)bsd_flock;
1040 return (fcntl(&fcntl_args));
1042 case LINUX_F_SETLKW64:
1043 error = copyin((caddr_t)args->arg, &linux_flock,
1044 sizeof(linux_flock));
1047 linux_to_bsd_flock64(&linux_flock, bsd_flock);
1048 fcntl_args.fd = args->fd;
1049 fcntl_args.cmd = F_SETLKW;
1050 fcntl_args.arg = (long)bsd_flock;
1051 return (fcntl(&fcntl_args));
1054 return (fcntl_common(args));
1056 #endif /* __i386__ */
1059 linux_chown(struct linux_chown_args *args)
1061 struct chown_args bsd;
1064 sg = stackgap_init();
1065 CHECKALTEXIST(&sg, args->path);
1069 printf(ARGS(chown, "%s, %d, %d"), args->path, args->uid,
1073 bsd.path = args->path;
1074 bsd.uid = args->uid;
1075 bsd.gid = args->gid;
1076 return (chown(&bsd));
1080 linux_lchown(struct linux_lchown_args *args)
1082 struct lchown_args bsd;
1085 sg = stackgap_init();
1086 CHECKALTEXIST(&sg, args->path);
1090 printf(ARGS(lchown, "%s, %d, %d"), args->path, args->uid,
1094 bsd.path = args->path;
1095 bsd.uid = args->uid;
1096 bsd.gid = args->gid;
1097 return (lchown(&bsd));