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/svr4_32/svr4_32_stat.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: svr4_32_stat.c,v 1.35 2008/04/28 20:23:46 martin Exp $  */
    2 
    3 /*-
    4  * Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Christos Zoulas.
    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: svr4_32_stat.c,v 1.35 2008/04/28 20:23:46 martin Exp $");
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/namei.h>
   38 #include <sys/proc.h>
   39 #include <sys/file.h>
   40 #include <sys/stat.h>
   41 #include <sys/filedesc.h>
   42 #include <sys/ioctl.h>
   43 #include <sys/kernel.h>
   44 #include <sys/mount.h>
   45 #include <sys/malloc.h>
   46 #include <sys/namei.h>
   47 #include <sys/unistd.h>
   48 #include <sys/kauth.h>
   49 
   50 #include <sys/time.h>
   51 #include <sys/ucred.h>
   52 #include <uvm/uvm_extern.h>
   53 #include <sys/sysctl.h>
   54 #include <sys/vfs_syscalls.h>
   55 
   56 #include <sys/syscallargs.h>
   57 
   58 #include <compat/svr4_32/svr4_32_types.h>
   59 #include <compat/svr4_32/svr4_32_signal.h>
   60 #include <compat/svr4_32/svr4_32_lwp.h>
   61 #include <compat/svr4_32/svr4_32_ucontext.h>
   62 #include <compat/svr4_32/svr4_32_syscallargs.h>
   63 #include <compat/svr4_32/svr4_32_util.h>
   64 #include <compat/svr4_32/svr4_32_stat.h>
   65 #include <compat/svr4_32/svr4_32_ustat.h>
   66 #include <compat/svr4_32/svr4_32_fuser.h>
   67 #include <compat/svr4/svr4_utsname.h>
   68 #include <compat/svr4/svr4_systeminfo.h>
   69 #include <compat/svr4_32/svr4_32_time.h>
   70 #include <compat/svr4_32/svr4_32_socket.h>
   71 
   72 #if defined(__sparc__) || defined(__sparc_v9__) || defined(__sparc64__)
   73 /*
   74  * Solaris-2.4 on the sparc has the old stat call using the new
   75  * stat data structure...
   76  */
   77 # define SVR4_NO_OSTAT
   78 #endif
   79 
   80 static void bsd_to_svr4_32_xstat(struct stat *, struct svr4_32_xstat *);
   81 static void bsd_to_svr4_32_stat64(struct stat *, struct svr4_32_stat64 *);
   82 static int svr4_32_to_bsd_pathconf(int);
   83 
   84 /*
   85  * SVR4 uses named pipes as named sockets, so we tell programs
   86  * that sockets are named pipes with mode 0
   87  */
   88 #define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
   89 
   90 
   91 #ifndef SVR4_NO_OSTAT
   92 static void bsd_to_svr4_32_stat(struct stat *, struct svr4_32_stat *);
   93 
   94 static void
   95 bsd_to_svr4_32_stat(struct stat *st, struct svr4_32_stat *st4)
   96 {
   97         memset(st4, 0, sizeof(*st4));
   98         st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
   99         st4->st_ino = st->st_ino;
  100         st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
  101         st4->st_nlink = st->st_nlink;
  102         st4->st_uid = st->st_uid;
  103         st4->st_gid = st->st_gid;
  104         st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
  105         st4->st_size = st->st_size;
  106         st4->st_atim = st->st_atimespec.tv_sec;
  107         st4->st_mtim = st->st_mtimespec.tv_sec;
  108         st4->st_ctim = st->st_ctimespec.tv_sec;
  109 }
  110 #endif
  111 
  112 
  113 static void
  114 bsd_to_svr4_32_xstat(struct stat *st, struct svr4_32_xstat *st4)
  115 {
  116         memset(st4, 0, sizeof(*st4));
  117         st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
  118         st4->st_ino = st->st_ino;
  119         st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
  120         st4->st_nlink = st->st_nlink;
  121         st4->st_uid = st->st_uid;
  122         st4->st_gid = st->st_gid;
  123         st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
  124         st4->st_size = st->st_size;
  125         st4->st_atim.tv_sec = st->st_atimespec.tv_sec;
  126         st4->st_atim.tv_nsec = st->st_atimespec.tv_nsec;
  127         st4->st_mtim.tv_sec = st->st_mtimespec.tv_sec;
  128         st4->st_mtim.tv_nsec = st->st_mtimespec.tv_nsec;
  129         st4->st_ctim.tv_sec = st->st_ctimespec.tv_sec;
  130         st4->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
  131         st4->st_blksize = st->st_blksize;
  132         st4->st_blocks = st->st_blocks;
  133         strlcpy(st4->st_fstype, "unknown", sizeof(st4->st_fstype));
  134 }
  135 
  136 
  137 static void
  138 bsd_to_svr4_32_stat64(struct stat *st, struct svr4_32_stat64 *st4)
  139 {
  140         memset(st4, 0, sizeof(*st4));
  141         st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
  142         st4->st_ino = st->st_ino;
  143         st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
  144         st4->st_nlink = st->st_nlink;
  145         st4->st_uid = st->st_uid;
  146         st4->st_gid = st->st_gid;
  147         st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
  148         st4->st_size = st->st_size;
  149         st4->st_atim.tv_sec = st->st_atimespec.tv_sec;
  150         st4->st_atim.tv_nsec = st->st_atimespec.tv_nsec;
  151         st4->st_mtim.tv_sec = st->st_mtimespec.tv_sec;
  152         st4->st_mtim.tv_nsec = st->st_mtimespec.tv_nsec;
  153         st4->st_ctim.tv_sec = st->st_ctimespec.tv_sec;
  154         st4->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
  155         st4->st_blocks = st->st_blocks;
  156         strlcpy(st4->st_fstype, "unknown", sizeof(st4->st_fstype));
  157 }
  158 
  159 
  160 int
  161 svr4_32_sys_stat(struct lwp *l, const struct svr4_32_sys_stat_args *uap, register_t *retval)
  162 {
  163 #ifdef SVR4_NO_OSTAT
  164         struct svr4_32_sys_xstat_args cup;
  165 
  166         SCARG(&cup, two) = 2;
  167         SCARG(&cup, path) = SCARG(uap, path);
  168         SCARG(&cup, ub) = SCARG(uap, ub);
  169         return svr4_32_sys_xstat(l, &cup, retval);
  170 #else
  171         struct stat             st;
  172         struct svr4_32_stat     svr4_st;
  173         int                     error;
  174 
  175         error = do_sys_stat(SCARG(&cup, path), FOLLOW, &st);
  176         if (error != 0)
  177                 return error;
  178 
  179         bsd_to_svr4_32_stat(&st, &svr4_st);
  180 
  181         if (S_ISSOCK(st.st_mode))
  182                 (void) svr4_add_socket(p, SCARG(&cup, path), &st);
  183 
  184         return copyout(&svr4_st, SCARG_P32(uap, ub),
  185                              sizeof svr4_st);
  186 #endif
  187 }
  188 
  189 
  190 int
  191 svr4_32_sys_lstat(struct lwp *l, const struct svr4_32_sys_lstat_args *uap, register_t *retval)
  192 {
  193 #ifdef SVR4_NO_OSTAT
  194         struct svr4_32_sys_lxstat_args cup;
  195 
  196         SCARG(&cup, two) = 2;
  197         SCARG(&cup, path) = SCARG(uap, path);
  198         SCARG(&cup, ub) = SCARG(uap, ub);
  199         return svr4_32_sys_lxstat(l, &cup, retval);
  200 #else
  201         struct stat             st;
  202         struct svr4_32_stat     svr4_st;
  203         int                     error;
  204 
  205         error = do_sys_stat(SCARG(&cup, path), NOFOLLOW, &st);
  206         if (error != 0)
  207                 return error;
  208 
  209         bsd_to_svr4_32_stat(&st, &svr4_st);
  210 
  211         if (S_ISSOCK(st.st_mode))
  212                 (void) svr4_add_socket(p, SCARG(&cup, path), &st);
  213 
  214         return copyout(&svr4_st, SCARG_P32(uap, ub),
  215                              sizeof svr4_st);
  216 #endif
  217 }
  218 
  219 
  220 int
  221 svr4_32_sys_fstat(struct lwp *l, const struct svr4_32_sys_fstat_args *uap, register_t *retval)
  222 {
  223 #ifdef SVR4_NO_OSTAT
  224         struct svr4_32_sys_fxstat_args cup;
  225 
  226         SCARG(&cup, two) = 2;
  227         SCARG(&cup, fd) = SCARG(uap, fd);
  228         SCARG(&cup, sb) = SCARG(uap, sb);
  229         return svr4_32_sys_fxstat(l, &cup, retval);
  230 #else
  231         struct stat             st;
  232         struct svr4_32_stat     svr4_st;
  233         int                     error;
  234 
  235         error = do_sys_fstat(SCARG(uap, fd), &st);
  236         if (error != 0)
  237                 return error;
  238 
  239         bsd_to_svr4_32_stat(&st, &svr4_st);
  240 
  241         return copyout(&svr4_st, SCARG_P32(uap, ub),
  242                              sizeof svr4_st);
  243 #endif
  244 }
  245 
  246 
  247 int
  248 svr4_32_sys_xstat(struct lwp *l, const struct svr4_32_sys_xstat_args *uap, register_t *retval)
  249 {
  250         struct stat             st;
  251         struct svr4_32_xstat    svr4_st;
  252         int                     error;
  253         const char *path = SCARG_P32(uap, path);
  254 
  255         error = do_sys_stat(path, FOLLOW, &st);
  256         if (error != 0)
  257                 return error;
  258 
  259         bsd_to_svr4_32_xstat(&st, &svr4_st);
  260 
  261         if (S_ISSOCK(st.st_mode))
  262                 (void) svr4_add_socket(l->l_proc, path, &st);
  263 
  264         return copyout(&svr4_st, SCARG_P32(uap, ub),
  265                              sizeof svr4_st);
  266 }
  267 
  268 
  269 int
  270 svr4_32_sys_lxstat(struct lwp *l, const struct svr4_32_sys_lxstat_args *uap, register_t *retval)
  271 {
  272         struct stat             st;
  273         struct svr4_32_xstat    svr4_st;
  274         int                     error;
  275         const char *path = SCARG_P32(uap, path);
  276 
  277         error = do_sys_stat(path, NOFOLLOW, &st);
  278         if (error != 0)
  279                 return error;
  280 
  281         bsd_to_svr4_32_xstat(&st, &svr4_st);
  282 
  283         if (S_ISSOCK(st.st_mode))
  284                 (void) svr4_add_socket(l->l_proc, path, &st);
  285 
  286         return copyout(&svr4_st, SCARG_P32(uap, ub),
  287                              sizeof svr4_st);
  288 }
  289 
  290 
  291 int
  292 svr4_32_sys_fxstat(struct lwp *l, const struct svr4_32_sys_fxstat_args *uap, register_t *retval)
  293 {
  294         struct stat             st;
  295         struct svr4_32_xstat    svr4_st;
  296         int                     error;
  297 
  298         error = do_sys_fstat(SCARG(uap, fd), &st);
  299         if (error != 0)
  300                 return error;
  301 
  302         bsd_to_svr4_32_xstat(&st, &svr4_st);
  303 
  304         return copyout(&svr4_st, SCARG_P32(uap, sb),
  305                              sizeof svr4_st);
  306 }
  307 
  308 
  309 int
  310 svr4_32_sys_stat64(struct lwp *l, const struct svr4_32_sys_stat64_args *uap, register_t *retval)
  311 {
  312         struct stat             st;
  313         struct svr4_32_stat64   svr4_st;
  314         int                     error;
  315         const char *path = SCARG_P32(uap, path);
  316 
  317         error = do_sys_stat(path, FOLLOW, &st);
  318         if (error != 0)
  319                 return error;
  320 
  321         bsd_to_svr4_32_stat64(&st, &svr4_st);
  322 
  323         if (S_ISSOCK(st.st_mode))
  324                 (void) svr4_add_socket(l->l_proc, path, &st);
  325 
  326         return copyout(&svr4_st,  SCARG_P32(uap, sb),
  327                              sizeof svr4_st);
  328 }
  329 
  330 
  331 int
  332 svr4_32_sys_lstat64(struct lwp *l, const struct svr4_32_sys_lstat64_args *uap, register_t *retval)
  333 {
  334         struct stat             st;
  335         struct svr4_32_stat64   svr4_st;
  336         int                     error;
  337         const char *path = SCARG_P32(uap, path);
  338 
  339         error = do_sys_stat(path, NOFOLLOW, &st);
  340         if (error != 0)
  341                 return error;
  342 
  343         bsd_to_svr4_32_stat64(&st, &svr4_st);
  344 
  345         if (S_ISSOCK(st.st_mode))
  346                 (void) svr4_add_socket(l->l_proc, path, &st);
  347 
  348         return copyout(&svr4_st, SCARG_P32(uap, sb),
  349                              sizeof svr4_st);
  350 }
  351 
  352 
  353 int
  354 svr4_32_sys_fstat64(struct lwp *l, const struct svr4_32_sys_fstat64_args *uap, register_t *retval)
  355 {
  356         struct stat             st;
  357         struct svr4_32_stat64   svr4_st;
  358         int                     error;
  359 
  360         error = do_sys_fstat(SCARG(uap, fd), &st);
  361         if (error != 0)
  362                 return error;
  363 
  364         bsd_to_svr4_32_stat64(&st, &svr4_st);
  365 
  366         return copyout(&svr4_st, SCARG_P32(uap, sb),
  367                              sizeof svr4_st);
  368 }
  369 
  370 
  371 struct svr4_32_ustat_args {
  372         syscallarg(svr4_dev_t)          dev;
  373         syscallarg(svr4_32_ustatp)      name;
  374 };
  375 
  376 static int
  377 svr4_32_ustat(struct lwp *l, const struct svr4_32_ustat_args *uap, register_t *retval)
  378 {
  379         /* {
  380                 syscallarg(svr4_dev_t)          dev;
  381                 syscallarg(svr4_32_ustatp)      name;
  382         } */
  383         struct svr4_32_ustat    us;
  384         int                     error;
  385 
  386         memset(&us, 0, sizeof us);
  387 
  388         /*
  389          * XXX: should set f_tfree and f_tinode at least
  390          * How do we translate dev -> fstat? (and then to svr4_32_ustat)
  391          */
  392         if ((error = copyout(&us, SCARG_P32(uap, name),
  393                              sizeof us)) != 0)
  394                 return (error);
  395 
  396         return 0;
  397 }
  398 
  399 
  400 
  401 int
  402 svr4_32_sys_uname(struct lwp *l, const struct svr4_32_sys_uname_args *uap, register_t *retval)
  403 {
  404         struct svr4_utsname     sut;
  405 
  406         memset(&sut, 0, sizeof(sut));
  407 
  408         strncpy(sut.sysname, ostype, sizeof(sut.sysname));
  409         sut.sysname[sizeof(sut.sysname) - 1] = '\0';
  410 
  411         strncpy(sut.nodename, hostname, sizeof(sut.nodename));
  412         sut.nodename[sizeof(sut.nodename) - 1] = '\0';
  413 
  414         strncpy(sut.release, osrelease, sizeof(sut.release));
  415         sut.release[sizeof(sut.release) - 1] = '\0';
  416 
  417         strncpy(sut.version, version, sizeof(sut.version));
  418         sut.version[sizeof(sut.version) - 1] = '\0';
  419 
  420         strncpy(sut.machine, machine, sizeof(sut.machine));
  421         sut.machine[sizeof(sut.machine) - 1] = '\0';
  422 
  423         return copyout((void *) &sut, SCARG_P32(uap, name),
  424                        sizeof(struct svr4_utsname));
  425 }
  426 
  427 
  428 int
  429 svr4_32_sys_systeminfo(struct lwp *l, const struct svr4_32_sys_systeminfo_args *uap, register_t *retval)
  430 {
  431         const char *str = NULL;
  432         int name[2];
  433         int error;
  434         size_t len;
  435         char buf[256];
  436 
  437         u_int rlen = SCARG(uap, len);
  438 
  439         switch (SCARG(uap, what)) {
  440         case SVR4_SI_SYSNAME:
  441                 str = ostype;
  442                 break;
  443 
  444         case SVR4_SI_HOSTNAME:
  445                 str = hostname;
  446                 break;
  447 
  448         case SVR4_SI_RELEASE:
  449                 str = osrelease;
  450                 break;
  451 
  452         case SVR4_SI_VERSION:
  453                 str = version;
  454                 break;
  455 
  456         case SVR4_SI_MACHINE:
  457                 str = "sun4m"; /* Lie, pretend we are 4m */
  458                 break;
  459 
  460         case SVR4_SI_ARCHITECTURE:
  461 #if defined(__sparc__)
  462                 str = "sparc";
  463 #else
  464                 str = machine_arch;
  465 #endif
  466                 break;
  467 
  468         case SVR4_SI_ISALIST:
  469 #if defined(__sparc__)
  470                 str = "sparcv8 sparcv8-fsmuld sparcv7 sparc";
  471 #elif defined(__i386__)
  472                 str = "i386";
  473 #else
  474                 str = "unknown";
  475 #endif
  476                 break;
  477 
  478         case SVR4_SI_HW_SERIAL:
  479                 snprintf(buf, sizeof(buf), "%lu", hostid);
  480                 str = buf;
  481                 break;
  482 
  483         case SVR4_SI_HW_PROVIDER:
  484                 str = ostype;
  485                 break;
  486 
  487         case SVR4_SI_SRPC_DOMAIN:
  488                 str = domainname;
  489                 break;
  490 
  491         case SVR4_SI_PLATFORM:
  492 #if defined(__i386__)
  493                 str = "i86pc";
  494 #elif defined(__sparc__)
  495                 {
  496                         extern char machine_model[];
  497 
  498                         str = machine_model;
  499                 }
  500 #else
  501                 str = "unknown";
  502 #endif
  503                 break;
  504 
  505         case SVR4_SI_KERB_REALM:
  506                 str = "unsupported";
  507                 break;
  508 
  509         case SVR4_SI_SET_HOSTNAME:
  510                 name[1] = KERN_HOSTNAME;
  511                 break;
  512 
  513         case SVR4_SI_SET_SRPC_DOMAIN:
  514                 name[1] = KERN_DOMAINNAME;
  515                 break;
  516 
  517         case SVR4_SI_SET_KERB_REALM:
  518                 return 0;
  519 
  520         default:
  521                 DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
  522                 return ENOSYS;
  523         }
  524 
  525         if (str) {
  526                 len = strlen(str) + 1;
  527                 if (len < rlen)
  528                         rlen = len;
  529 
  530                 if (SCARG_P32(uap, buf)) {
  531                         error = copyout(str, SCARG_P32(uap, buf),
  532                             rlen);
  533                         if (error)
  534                                 return error;
  535                         if (rlen > 0) {
  536                                 /* make sure we are NULL terminated */
  537                                 buf[0] = '\0';
  538                                 error = copyout(buf, &(((char *)
  539                                     SCARG_P32(uap, buf))[rlen - 1]), 1);
  540                         }
  541                 }
  542                 else
  543                         error = 0;
  544         }
  545         else {
  546                 error = copyinstr(SCARG_P32(uap, buf), buf,
  547                                   sizeof(buf), &len);
  548                 if (error)
  549                         return error;
  550                 name[0] = CTL_KERN;
  551                 error = old_sysctl(&name[0], 1, 0, 0, buf, len, NULL);
  552         }
  553 
  554         *retval = len;
  555         return error;
  556 }
  557 
  558 
  559 int
  560 svr4_32_sys_utssys(struct lwp *l, const struct svr4_32_sys_utssys_args *uap, register_t *retval)
  561 {
  562 
  563         switch (SCARG(uap, sel)) {
  564         case 0:         /* uname(2)  */
  565                 {
  566                         struct svr4_32_sys_uname_args ua;
  567                         SCARG(&ua, name) = SCARG(uap, a1);
  568                         return svr4_32_sys_uname(l, &ua, retval);
  569                 }
  570 
  571         case 2:         /* ustat(2)  */
  572                 {
  573                         struct svr4_32_ustat_args ua;
  574                         SCARG(&ua, dev) =  (uintptr_t)SCARG_P32(uap, a2);
  575                         SCARG(&ua, name) = SCARG(uap, a1);
  576                         return svr4_32_ustat(l, &ua, retval);
  577                 }
  578 
  579         case 3:         /* fusers(2) */
  580                 return ENOSYS;
  581 
  582         default:
  583                 return ENOSYS;
  584         }
  585         return ENOSYS;
  586 }
  587 
  588 
  589 int
  590 svr4_32_sys_utime(struct lwp *l, const struct svr4_32_sys_utime_args *uap, register_t *retval)
  591 {
  592         struct svr4_32_utimbuf ub;
  593         struct timeval tbuf[2], *tvp;
  594         int error;
  595 
  596         if (SCARG_P32(uap, ubuf)) {
  597                 if ((error = copyin(SCARG_P32(uap, ubuf),
  598                                     &ub, sizeof(ub))) != 0)
  599                         return error;
  600                 tbuf[0].tv_sec = ub.actime;
  601                 tbuf[0].tv_usec = 0;
  602                 tbuf[1].tv_sec = ub.modtime;
  603                 tbuf[1].tv_usec = 0;
  604                 tvp = tbuf;
  605         }
  606         else
  607                 tvp = NULL;
  608         return do_sys_utimes(l, NULL, SCARG_P32(uap, path), FOLLOW,
  609                             tvp, UIO_SYSSPACE);
  610 }
  611 
  612 
  613 int
  614 svr4_32_sys_utimes(struct lwp *l, const struct svr4_32_sys_utimes_args *uap, register_t *retval)
  615 {
  616         struct sys_utimes_args ua;
  617         SCARG(&ua, path) = SCARG_P32(uap, path);
  618         SCARG(&ua, tptr) = SCARG_P32(uap, tptr);
  619 
  620         return sys_utimes(l, &ua, retval);
  621 }
  622 
  623 
  624 static int
  625 svr4_32_to_bsd_pathconf(int name)
  626 {
  627         switch (name) {
  628         case SVR4_PC_LINK_MAX:
  629                 return _PC_LINK_MAX;
  630 
  631         case SVR4_PC_MAX_CANON:
  632                 return _PC_MAX_CANON;
  633 
  634         case SVR4_PC_MAX_INPUT:
  635                 return _PC_MAX_INPUT;
  636 
  637         case SVR4_PC_NAME_MAX:
  638                 return _PC_NAME_MAX;
  639 
  640         case SVR4_PC_PATH_MAX:
  641                 return _PC_PATH_MAX;
  642 
  643         case SVR4_PC_PIPE_BUF:
  644                 return _PC_PIPE_BUF;
  645 
  646         case SVR4_PC_NO_TRUNC:
  647                 return _PC_NO_TRUNC;
  648 
  649         case SVR4_PC_VDISABLE:
  650                 return _PC_VDISABLE;
  651 
  652         case SVR4_PC_CHOWN_RESTRICTED:
  653                 return _PC_CHOWN_RESTRICTED;
  654 
  655         case SVR4_PC_SYNC_IO:
  656                 return _PC_SYNC_IO;
  657 
  658         case SVR4_PC_FILESIZEBITS:
  659                 return _PC_FILESIZEBITS;
  660 
  661         case SVR4_PC_ASYNC_IO:
  662         case SVR4_PC_PRIO_IO:
  663                 /* Not supported */
  664                 return 0;
  665 
  666         default:
  667                 /* Invalid */
  668                 return -1;
  669         }
  670 }
  671 
  672 
  673 int
  674 svr4_32_sys_pathconf(struct lwp *l, const struct svr4_32_sys_pathconf_args *uap, register_t *retval)
  675 {
  676         struct sys_pathconf_args /* {
  677                 syscallarg(char *) path;
  678                 syscallarg(int) name;
  679         } */ ua;
  680 
  681         SCARG(&ua, path) = SCARG_P32(uap, path);
  682         SCARG(&ua, name) = svr4_32_to_bsd_pathconf(SCARG(&ua, name));
  683 
  684         switch (SCARG(&ua, name)) {
  685         case -1:
  686                 *retval = -1;
  687                 return EINVAL;
  688         case 0:
  689                 *retval = 0;
  690                 return 0;
  691         default:
  692                 return sys_pathconf(l, &ua, retval);
  693         }
  694 }
  695 
  696 
  697 int
  698 svr4_32_sys_fpathconf(struct lwp *l, const struct svr4_32_sys_fpathconf_args *uap, register_t *retval)
  699 {
  700         struct sys_fpathconf_args ua;
  701 
  702         SCARG(&ua, fd) = SCARG(uap, fd);
  703         SCARG(&ua, name) = svr4_32_to_bsd_pathconf(SCARG(uap, name));
  704 
  705         switch (SCARG(&ua, name)) {
  706         case -1:
  707                 *retval = -1;
  708                 return EINVAL;
  709         case 0:
  710                 *retval = 0;
  711                 return 0;
  712         default:
  713                 return sys_fpathconf(l, &ua, retval);
  714         }
  715 }

Cache object: 8ff330ffa6f48bb4da5d40710d651643


[ 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.