The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/darwin/darwin_stat.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: darwin_stat.c,v 1.14 2008/04/28 20:23:41 martin Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2003, 2008 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Emmanuel Dreyfus.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __KERNEL_RCSID(0, "$NetBSD: darwin_stat.c,v 1.14 2008/04/28 20:23:41 martin Exp $");
   34 
   35 #include <sys/types.h>
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/filedesc.h>
   39 #include <sys/mount.h>
   40 #include <sys/namei.h>
   41 #include <sys/proc.h>
   42 #include <sys/stat.h>
   43 #include <sys/syscallargs.h>
   44 #include <sys/vfs_syscalls.h>
   45 
   46 #include <compat/sys/signal.h>
   47 #include <compat/sys/stat.h>
   48 
   49 #include <compat/common/compat_util.h>
   50 
   51 #include <compat/mach/mach_types.h>
   52 #include <compat/mach/mach_vm.h>
   53 
   54 #include <compat/darwin/darwin_audit.h>
   55 #include <compat/darwin/darwin_types.h>
   56 #include <compat/darwin/darwin_syscallargs.h>
   57 
   58 int
   59 darwin_sys_stat(struct lwp *l, const struct darwin_sys_stat_args *uap, register_t *retval)
   60 {
   61         /* {
   62                 syscallarg(char *) path;
   63                 syscallarg(struct stat12 *) ub;
   64         } */
   65         struct stat12 sb12;
   66         struct stat sb;
   67         int error;
   68 
   69         error = do_sys_stat(SCARG(uap, path), FOLLOW, &sb);
   70         if (error != 0)
   71                 return error;
   72 
   73         compat_12_stat_conv(&sb, &sb12);
   74         sb12.st_dev = native_to_darwin_dev(sb12.st_dev);
   75         sb12.st_rdev = native_to_darwin_dev(sb12.st_rdev);
   76 
   77         return copyout(&sb12, SCARG(uap, ub), sizeof(sb12));
   78 }
   79 
   80 int
   81 darwin_sys_fstat(struct lwp *l, const struct darwin_sys_fstat_args *uap, register_t *retval)
   82 {
   83         /* {
   84                 syscallarg(int) fd;
   85                 syscallarg(struct stat12 *) sb;
   86         } */
   87         struct stat12 sb12;
   88         struct stat sb;
   89         int error;
   90 
   91         error = do_sys_fstat(SCARG(uap, fd), &sb);
   92         if (error != 0)
   93                 return error;
   94 
   95         compat_12_stat_conv(&sb, &sb12);
   96         sb12.st_dev = native_to_darwin_dev(sb12.st_dev);
   97         sb12.st_rdev = native_to_darwin_dev(sb12.st_rdev);
   98 
   99         return copyout(&sb12, SCARG(uap, sb), sizeof(sb12));
  100 }
  101 
  102 int
  103 darwin_sys_lstat(struct lwp *l, const struct darwin_sys_lstat_args *uap, register_t *retval)
  104 {
  105         /* {
  106                 syscallarg(char *) path;
  107                 syscallarg(struct stat12 *) ub;
  108         } */
  109         struct stat12 sb12;
  110         struct stat sb;
  111         int error;
  112 
  113         error = do_sys_stat(SCARG(uap, path), NOFOLLOW, &sb);
  114         if (error != 0)
  115                 return error;
  116 
  117         compat_12_stat_conv(&sb, &sb12);
  118         sb12.st_dev = native_to_darwin_dev(sb12.st_dev);
  119         sb12.st_rdev = native_to_darwin_dev(sb12.st_rdev);
  120 
  121         return copyout(&sb12, SCARG(uap, ub), sizeof(sb12));
  122 }
  123 
  124 int
  125 darwin_sys_mknod(struct lwp *l, const struct darwin_sys_mknod_args *uap, register_t *retval)
  126 {
  127         /* {
  128                 syscallarg(char) path;
  129                 syscallarg(mode_t) mode;
  130                 syscallarg(dev_t) dev:
  131         } */
  132         struct sys_mknod_args cup;
  133 
  134         SCARG(&cup, path) = SCARG(uap, path);
  135         SCARG(&cup, mode) = SCARG(uap, mode);
  136         SCARG(&cup, dev) = darwin_to_native_dev(SCARG(uap, dev));
  137 
  138         return sys_mknod(l, &cup, retval);
  139 }

Cache object: 41582f716c8b1c3f6d7ba79571bc49bf


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.