Okay?

Index: linux_misc.c
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.76
diff -u -p -r1.76 linux_misc.c
--- linux_misc.c        22 Apr 2012 05:43:14 -0000      1.76
+++ linux_misc.c        22 May 2012 14:58:00 -0000
@@ -441,6 +441,76 @@ linux_sys_statfs(p, v, retval)
        return copyout((caddr_t) &ltmp, (caddr_t) SCARG(uap, sp), sizeof ltmp);
 }
 
+static void
+bsd_to_linux_statfs64(struct statfs *bsp, struct linux_statfs64 *lsp)
+{
+
+       /*
+        * Convert BSD filesystem names to Linux filesystem type numbers
+        * where possible.  Linux statfs uses a value of -1 to indicate
+        * an unsupported field.
+        */
+       if (!strcmp(bsp->f_fstypename, MOUNT_FFS) ||
+           !strcmp(bsp->f_fstypename, MOUNT_MFS))
+               lsp->l_ftype = 0x11954;
+       else if (!strcmp(bsp->f_fstypename, MOUNT_NFS))
+               lsp->l_ftype = 0x6969;
+       else if (!strcmp(bsp->f_fstypename, MOUNT_MSDOS))
+               lsp->l_ftype = 0x4d44;
+       else if (!strcmp(bsp->f_fstypename, MOUNT_PROCFS))
+               lsp->l_ftype = 0x9fa0;
+       else if (!strcmp(bsp->f_fstypename, MOUNT_EXT2FS))
+               lsp->l_ftype = 0xef53;
+       else if (!strcmp(bsp->f_fstypename, MOUNT_CD9660))
+               lsp->l_ftype = 0x9660;
+       else if (!strcmp(bsp->f_fstypename, MOUNT_NCPFS))
+               lsp->l_ftype = 0x6969;
+       else
+               lsp->l_ftype = -1;
+
+       lsp->l_fbsize = bsp->f_bsize;
+       lsp->l_fblocks = bsp->f_blocks;
+       lsp->l_fbfree = bsp->f_bfree;
+       lsp->l_fbavail = bsp->f_bavail;
+       lsp->l_ffiles = bsp->f_files;
+       lsp->l_fffree = bsp->f_ffree;
+       lsp->l_ffsid.val[0] = bsp->f_fsid.val[0];
+       lsp->l_ffsid.val[1] = bsp->f_fsid.val[1];
+       lsp->l_fnamelen = MAXNAMLEN;    /* XXX */
+}
+
+int
+linux_sys_statfs64(struct proc *p, void *v, register_t *retval)
+{
+       struct linux_sys_statfs64_args /* {
+               syscallarg(char *) path;
+               syscallarg(struct linux_statfs *) sp;
+       } */ *uap = v;
+       struct statfs btmp, *bsp;
+       struct linux_statfs64 ltmp;
+       struct sys_statfs_args bsa;
+       caddr_t sg;
+       int error;
+
+       sg = stackgap_init(p->p_emul);
+       bsp = (struct statfs *) stackgap_alloc(&sg, sizeof (struct statfs));
+
+       LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+       SCARG(&bsa, path) = SCARG(uap, path);
+       SCARG(&bsa, buf) = bsp;
+
+       if ((error = sys_statfs(p, &bsa, retval)))
+               return error;
+
+       if ((error = copyin((caddr_t) bsp, (caddr_t) &btmp, sizeof btmp)))
+               return error;
+
+       bsd_to_linux_statfs64(&btmp, &ltmp);
+
+       return copyout((caddr_t) &ltmp, (caddr_t) SCARG(uap, sp), sizeof ltmp);
+}
+
 int
 linux_sys_fstatfs(p, v, retval)
        struct proc *p;
Index: syscalls.master
===================================================================
RCS file: /cvs/src/sys/compat/linux/syscalls.master,v
retrieving revision 1.66
diff -u -p -r1.66 syscalls.master
--- syscalls.master     14 Dec 2011 08:33:18 -0000      1.66
+++ syscalls.master     22 May 2012 14:58:00 -0000
@@ -416,7 +416,8 @@
 266    STD             { int linux_sys_clock_getres(clockid_t which, \
                            struct l_timespec *tp); }
 267    UNIMPL          linux_sys_clock_nanosleep
-268    UNIMPL          linux_sys_statfs64
+268    STD             { int linux_sys_statfs64(char *path, \
+                           struct linux_statfs64 *sp); }
 269    UNIMPL          linux_sys_fstatfs64
 270    UNIMPL          linux_sys_tgkill
 271    UNIMPL          linux_sys_utimes

Reply via email to