Deleted Added
full compact
linux_file.c (71699) linux_file.c (72538)
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

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.
27 *
1/*-
2 * Copyright (c) 1994-1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

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.
27 *
28 * $FreeBSD: head/sys/compat/linux/linux_file.c 71699 2001-01-27 00:01:31Z jhb $
28 * $FreeBSD: head/sys/compat/linux/linux_file.c 72538 2001-02-16 14:42:11Z jlemon $
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sysproto.h>
36#include <sys/fcntl.h>
37#include <sys/file.h>
38#include <sys/filedesc.h>
39#include <sys/lock.h>
40#include <sys/proc.h>
41#include <sys/vnode.h>
42#include <sys/malloc.h>
29 */
30
31#include "opt_compat.h"
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sysproto.h>
36#include <sys/fcntl.h>
37#include <sys/file.h>
38#include <sys/filedesc.h>
39#include <sys/lock.h>
40#include <sys/proc.h>
41#include <sys/vnode.h>
42#include <sys/malloc.h>
43#include <sys/mount.h>
43#include <sys/dirent.h>
44#include <sys/conf.h>
45#include <sys/tty.h>
46
44#include <sys/dirent.h>
45#include <sys/conf.h>
46#include <sys/tty.h>
47
48#include <ufs/ufs/extattr.h>
49#include <ufs/ufs/quota.h>
50#include <ufs/ufs/ufsmount.h>
51
47#include <machine/../linux/linux.h>
48#include <machine/../linux/linux_proto.h>
49#include <compat/linux/linux_util.h>
50
51#ifndef __alpha__
52int
53linux_creat(struct proc *p, struct linux_creat_args *args)
54{

--- 825 unchanged lines hidden (view full) ---

880 struct pwrite_args bsd;
881
882 bsd.fd = uap->fd;
883 bsd.buf = uap->buf;
884 bsd.nbyte = uap->nbyte;
885 bsd.offset = uap->offset;
886 return pwrite(p, &bsd);
887}
52#include <machine/../linux/linux.h>
53#include <machine/../linux/linux_proto.h>
54#include <compat/linux/linux_util.h>
55
56#ifndef __alpha__
57int
58linux_creat(struct proc *p, struct linux_creat_args *args)
59{

--- 825 unchanged lines hidden (view full) ---

885 struct pwrite_args bsd;
886
887 bsd.fd = uap->fd;
888 bsd.buf = uap->buf;
889 bsd.nbyte = uap->nbyte;
890 bsd.offset = uap->offset;
891 return pwrite(p, &bsd);
892}
893
894int
895linux_mount(struct proc *p, struct linux_mount_args *args)
896{
897 struct mount_args bsd_args;
898 struct ufs_args ufs;
899 char fstypename[MFSNAMELEN];
900 char mntonname[MNAMELEN], mntfromname[MNAMELEN];
901 int error = 0;
902
903 error = copyinstr(args->filesystemtype, fstypename,
904 MFSNAMELEN - 1, NULL);
905 if (error)
906 return (error);
907 error = copyinstr(args->specialfile, mntfromname, MFSNAMELEN - 1, NULL);
908 if (error)
909 return (error);
910 error = copyinstr(args->dir, mntonname, MFSNAMELEN - 1, NULL);
911 if (error)
912 return (error);
913
914#ifdef DEBUG
915 if (ldebug(mount))
916 printf(ARGS(mount, "%s, %s, %s"),
917 fstypename, mntfromname, mntonname);
918#endif
919
920 if (strcmp(fstypename, "ext2") == 0) {
921 bsd_args.type = "ext2fs";
922 bsd_args.data = (void *)&ufs;
923 ufs.fspec = mntfromname;
924#define DEFAULT_ROOTID -2
925 ufs.export.ex_root = DEFAULT_ROOTID;
926 ufs.export.ex_flags =
927 args->rwflag & LINUX_MS_RDONLY ? MNT_EXRDONLY : 0;
928 } else if (strcmp(fstypename, "proc") == 0) {
929 bsd_args.type = "linprocfs";
930 bsd_args.data = NULL;
931 } else {
932 return (ENODEV);
933 }
934
935 bsd_args.path = mntonname;
936 bsd_args.flags = 0;
937
938 if ((args->rwflag & 0xffff0000) == 0xc0ed0000) {
939 /*
940 * Linux SYNC flag is not included; the closest equivalent
941 * FreeBSD has is !ASYNC, which is our default.
942 */
943 if (args->rwflag & LINUX_MS_RDONLY)
944 bsd_args.flags |= MNT_RDONLY;
945 if (args->rwflag & LINUX_MS_NOSUID)
946 bsd_args.flags |= MNT_NOSUID;
947 if (args->rwflag & LINUX_MS_NODEV)
948 bsd_args.flags |= MNT_NODEV;
949 if (args->rwflag & LINUX_MS_NOEXEC)
950 bsd_args.flags |= MNT_NOEXEC;
951 if (args->rwflag & LINUX_MS_REMOUNT)
952 bsd_args.flags |= MNT_UPDATE;
953 }
954
955 return (mount1(p, &bsd_args, UIO_SYSSPACE));
956}
957
958int
959linux_umount(struct proc *p, struct linux_umount_args *args)
960{
961 struct linux_umount2_args args2;
962
963 args2.path = args->path;
964 args2.flags = 0;
965 return (linux_umount2(p, &args2));
966}
967
968int
969linux_umount2(struct proc *p, struct linux_umount2_args *args)
970{
971 struct unmount_args bsd;
972
973 bsd.path = args->path;
974 bsd.flags = args->flags; /* XXX correct? */
975 return (unmount(p, &bsd));
976}