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

Cache object: 0756f1883cb139a367de7c0278a8d3dc


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