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/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 /*
    2  * Copyright (c) 1998 Mark Newton
    3  * Copyright (c) 1994 Christos Zoulas
    4  * All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. The name of the author may not be used to endorse or promote products
   15  *    derived from this software without specific prior written permission
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   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$
   29  */
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/proc.h>
   34 #include <sys/stat.h>
   35 #include <sys/filedesc.h>
   36 #include <sys/kernel.h>
   37 #include <sys/unistd.h>
   38 #include <sys/time.h>
   39 #include <sys/sysctl.h>
   40 #include <sys/sysproto.h>
   41 
   42 #include <vm/vm.h>
   43 
   44 #include <netinet/in.h>
   45 
   46 #include <svr4/svr4.h>
   47 #include <svr4/svr4_types.h>
   48 #include <svr4/svr4_signal.h>
   49 #include <svr4/svr4_proto.h>
   50 #include <svr4/svr4_util.h>
   51 #include <svr4/svr4_stat.h>
   52 #include <svr4/svr4_ustat.h>
   53 #include <svr4/svr4_utsname.h>
   54 #include <svr4/svr4_systeminfo.h>
   55 #include <svr4/svr4_socket.h>
   56 #include <svr4/svr4_time.h>
   57 #if defined(NOTYET)
   58 #include "svr4_fuser.h"
   59 #endif
   60 
   61 #ifdef sparc
   62 /* 
   63  * Solaris-2.4 on the sparc has the old stat call using the new
   64  * stat data structure...
   65  */
   66 # define SVR4_NO_OSTAT
   67 #endif
   68 
   69 struct svr4_ustat_args {
   70         svr4_dev_t              dev;
   71         struct svr4_ustat * name;
   72 };
   73 
   74 static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *));
   75 static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *));
   76 int svr4_ustat __P((struct proc *, struct svr4_ustat_args *));
   77 static int svr4_to_bsd_pathconf __P((int));
   78 
   79 /*
   80  * SVR4 uses named pipes as named sockets, so we tell programs
   81  * that sockets are named pipes with mode 0
   82  */
   83 #define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
   84 
   85 
   86 #ifndef SVR4_NO_OSTAT
   87 static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
   88 
   89 static void
   90 bsd_to_svr4_stat(st, st4)
   91         struct stat             *st;
   92         struct svr4_stat        *st4;
   93 {
   94         memset(st4, 0, sizeof(*st4));
   95         st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
   96         st4->st_ino = st->st_ino;
   97         st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
   98         st4->st_nlink = st->st_nlink;
   99         st4->st_uid = st->st_uid;
  100         st4->st_gid = st->st_gid;
  101         st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
  102         st4->st_size = st->st_size;
  103         st4->st_atim = st->st_atimespec.tv_sec;
  104         st4->st_mtim = st->st_mtimespec.tv_sec;
  105         st4->st_ctim = st->st_ctimespec.tv_sec;
  106 }
  107 #endif
  108 
  109 
  110 static void
  111 bsd_to_svr4_xstat(st, st4)
  112         struct stat             *st;
  113         struct svr4_xstat       *st4;
  114 {
  115         memset(st4, 0, sizeof(*st4));
  116         st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
  117         st4->st_ino = st->st_ino;
  118         st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
  119         st4->st_nlink = st->st_nlink;
  120         st4->st_uid = st->st_uid;
  121         st4->st_gid = st->st_gid;
  122         st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
  123         st4->st_size = st->st_size;
  124         st4->st_atim = st->st_atimespec;
  125         st4->st_mtim = st->st_mtimespec;
  126         st4->st_ctim = st->st_ctimespec;
  127         st4->st_blksize = st->st_blksize;
  128         st4->st_blocks = st->st_blocks;
  129         strcpy(st4->st_fstype, "unknown");
  130 }
  131 
  132 
  133 static void
  134 bsd_to_svr4_stat64(st, st4)
  135         struct stat             *st;
  136         struct svr4_stat64      *st4;
  137 {
  138         memset(st4, 0, sizeof(*st4));
  139         st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
  140         st4->st_ino = st->st_ino;
  141         st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
  142         st4->st_nlink = st->st_nlink;
  143         st4->st_uid = st->st_uid;
  144         st4->st_gid = st->st_gid;
  145         st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
  146         st4->st_size = st->st_size;
  147         st4->st_atim = st->st_atimespec;
  148         st4->st_mtim = st->st_mtimespec;
  149         st4->st_ctim = st->st_ctimespec;
  150         st4->st_blksize = st->st_blksize;
  151         st4->st_blocks = st->st_blocks;
  152         strcpy(st4->st_fstype, "unknown");
  153 }
  154 
  155 int
  156 svr4_sys_stat(p, uap)
  157         struct proc *p;
  158         struct svr4_sys_stat_args *uap;
  159 {
  160         struct stat             st;
  161         struct svr4_stat        svr4_st;
  162         struct stat_args        cup;
  163         int                     error;
  164         caddr_t sg = stackgap_init();
  165 
  166         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  167 
  168         SCARG(&cup, path) = SCARG(uap, path);
  169         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
  170 
  171 
  172         if ((error = stat(p, &cup)) != 0)
  173                 return error;
  174 
  175         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
  176                 return error;
  177 
  178         bsd_to_svr4_stat(&st, &svr4_st);
  179 
  180         if (S_ISSOCK(st.st_mode))
  181                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
  182 
  183         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
  184                 return error;
  185 
  186         return 0;
  187 }
  188 
  189 
  190 int
  191 svr4_sys_lstat(p, uap)
  192         register struct proc *p;
  193         struct svr4_sys_lstat_args *uap;
  194 {
  195         struct stat             st;
  196         struct svr4_stat        svr4_st;
  197         struct lstat_args       cup;
  198         int                     error;
  199         caddr_t                 sg = stackgap_init();
  200 
  201         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  202 
  203         SCARG(&cup, path) = SCARG(uap, path);
  204         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
  205 
  206         if ((error = lstat(p, &cup)) != 0)
  207                 return error;
  208 
  209         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
  210                 return error;
  211 
  212         bsd_to_svr4_stat(&st, &svr4_st);
  213 
  214         if (S_ISSOCK(st.st_mode))
  215                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
  216 
  217         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
  218                 return error;
  219 
  220         return 0;
  221 }
  222 
  223 
  224 int
  225 svr4_sys_fstat(p, uap)
  226         register struct proc *p;
  227         struct svr4_sys_fstat_args *uap;
  228 {
  229         struct stat             st;
  230         struct svr4_stat        svr4_st;
  231         struct fstat_args       cup;
  232         int                     error;
  233         caddr_t                 sg = stackgap_init();
  234 
  235         SCARG(&cup, fd) = SCARG(uap, fd);
  236         SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
  237 
  238         if ((error = fstat(p, &cup)) != 0)
  239                 return error;
  240 
  241         if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
  242                 return error;
  243 
  244         bsd_to_svr4_stat(&st, &svr4_st);
  245 
  246         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
  247                 return error;
  248 
  249         return 0;
  250 }
  251 
  252 
  253 int
  254 svr4_sys_xstat(p, uap)
  255         register struct proc *p;
  256         struct svr4_sys_xstat_args *uap;
  257 {
  258         struct stat             st;
  259         struct svr4_xstat       svr4_st;
  260         struct stat_args        cup;
  261         int                     error;
  262 
  263         caddr_t sg = stackgap_init();
  264         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  265 
  266         SCARG(&cup, path) = SCARG(uap, path);
  267         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
  268 
  269         if ((error = stat(p, &cup)) != 0)
  270                 return error;
  271 
  272         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
  273                 return error;
  274 
  275         bsd_to_svr4_xstat(&st, &svr4_st);
  276 
  277 #if defined(SOCKET_NOTYET)
  278         if (S_ISSOCK(st.st_mode))
  279                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
  280 #endif
  281 
  282         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
  283                 return error;
  284 
  285         return 0;
  286 }
  287 
  288 int
  289 svr4_sys_lxstat(p, uap)
  290         register struct proc *p;
  291         struct svr4_sys_lxstat_args *uap;
  292 {
  293         struct stat             st;
  294         struct svr4_xstat       svr4_st;
  295         struct lstat_args       cup;
  296         int                     error;
  297         caddr_t sg = stackgap_init();
  298         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  299 
  300         SCARG(&cup, path) = SCARG(uap, path);
  301         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
  302 
  303         if ((error = lstat(p, &cup)) != 0)
  304                 return error;
  305 
  306         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
  307                 return error;
  308 
  309         bsd_to_svr4_xstat(&st, &svr4_st);
  310 
  311 #if defined(SOCKET_NOTYET)
  312         if (S_ISSOCK(st.st_mode))
  313                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
  314 #endif
  315         if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
  316                 return error;
  317 
  318         return 0;
  319 }
  320 
  321 
  322 int
  323 svr4_sys_fxstat(p, uap)
  324         register struct proc *p;
  325         struct svr4_sys_fxstat_args *uap;
  326 {
  327         struct stat             st;
  328         struct svr4_xstat       svr4_st;
  329         struct fstat_args       cup;
  330         int                     error;
  331 
  332         caddr_t sg = stackgap_init();
  333 
  334         SCARG(&cup, fd) = SCARG(uap, fd);
  335         SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
  336 
  337         if ((error = fstat(p, &cup)) != 0)
  338                 return error;
  339 
  340         if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
  341                 return error;
  342 
  343         bsd_to_svr4_xstat(&st, &svr4_st);
  344 
  345         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
  346                 return error;
  347 
  348         return 0;
  349 }
  350 
  351 int
  352 svr4_sys_stat64(p, uap)
  353         register struct proc *p;
  354         struct svr4_sys_stat64_args *uap;
  355 {
  356         struct stat             st;
  357         struct svr4_stat64      svr4_st;
  358         struct stat_args        cup;
  359         int                     error;
  360         caddr_t                 sg = stackgap_init();
  361 
  362         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  363 
  364         SCARG(&cup, path) = SCARG(uap, path);
  365         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
  366 
  367         if ((error = stat(p, &cup)) != 0)
  368                 return error;
  369 
  370         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
  371                 return error;
  372 
  373         bsd_to_svr4_stat64(&st, &svr4_st);
  374 
  375         if (S_ISSOCK(st.st_mode))
  376                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
  377 
  378         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
  379                 return error;
  380 
  381         return 0;
  382 }
  383 
  384 
  385 int
  386 svr4_sys_lstat64(p, uap)
  387         register struct proc *p;
  388         struct svr4_sys_lstat64_args *uap;
  389 {
  390         struct stat             st;
  391         struct svr4_stat64      svr4_st;
  392         struct stat_args        cup;
  393         int                     error;
  394         caddr_t                 sg = stackgap_init();
  395 
  396         CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path));
  397 
  398         SCARG(&cup, path) = SCARG(uap, path);
  399         SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
  400 
  401         if ((error = lstat(p, (struct lstat_args *)&cup)) != 0)
  402                 return error;
  403 
  404         if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
  405                 return error;
  406 
  407         bsd_to_svr4_stat64(&st, &svr4_st);
  408 
  409         if (S_ISSOCK(st.st_mode))
  410                 (void) svr4_add_socket(p, SCARG(uap, path), &st);
  411 
  412         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
  413                 return error;
  414 
  415         return 0;
  416 }
  417 
  418 
  419 int
  420 svr4_sys_fstat64(p, uap)
  421         register struct proc *p;
  422         struct svr4_sys_fstat64_args *uap;
  423 {
  424         struct stat             st;
  425         struct svr4_stat64      svr4_st;
  426         struct fstat_args       cup;
  427         int                     error;
  428         caddr_t sg = stackgap_init();
  429 
  430         SCARG(&cup, fd) = SCARG(uap, fd);
  431         SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
  432 
  433         if ((error = fstat(p, &cup)) != 0)
  434                 return error;
  435 
  436         if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
  437                 return error;
  438 
  439         bsd_to_svr4_stat64(&st, &svr4_st);
  440 
  441         if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
  442                 return error;
  443 
  444         return 0;
  445 }
  446 
  447 
  448 int
  449 svr4_ustat(p, uap)
  450         register struct proc *p;
  451         struct svr4_ustat_args *uap;
  452 {
  453         struct svr4_ustat       us;
  454         int                     error;
  455 
  456         memset(&us, 0, sizeof us);
  457 
  458         /*
  459          * XXX: should set f_tfree and f_tinode at least
  460          * How do we translate dev -> fstat? (and then to svr4_ustat)
  461          */
  462         if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
  463                 return (error);
  464 
  465         return 0;
  466 }
  467 
  468 /*extern char ostype[], hostname[], osrelease[], version[], machine[];*/
  469 
  470 int
  471 svr4_sys_uname(p, uap)
  472         register struct proc *p;
  473         struct svr4_sys_uname_args *uap;
  474 {
  475         struct svr4_utsname     sut;
  476         
  477 
  478         memset(&sut, 0, sizeof(sut));
  479 
  480         strncpy(sut.sysname, ostype, sizeof(sut.sysname));
  481         sut.sysname[sizeof(sut.sysname) - 1] = '\0';
  482 
  483         strncpy(sut.nodename, hostname, sizeof(sut.nodename));
  484         sut.nodename[sizeof(sut.nodename) - 1] = '\0';
  485 
  486         strncpy(sut.release, osrelease, sizeof(sut.release));
  487         sut.release[sizeof(sut.release) - 1] = '\0';
  488 
  489         strncpy(sut.version, version, sizeof(sut.version));
  490         sut.version[sizeof(sut.version) - 1] = '\0';
  491 
  492         strncpy(sut.machine, machine, sizeof(sut.machine));
  493         sut.machine[sizeof(sut.machine) - 1] = '\0';
  494 
  495         return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
  496                        sizeof(struct svr4_utsname));
  497 }
  498 
  499 int
  500 svr4_sys_systeminfo(p, uap)
  501         struct proc *p;
  502         struct svr4_sys_systeminfo_args *uap;
  503 {
  504         char            *str = NULL;
  505         int             error = 0;
  506         register_t      *retval = p->p_retval;
  507         size_t          len = 0;
  508         char            buf[1];   /* XXX NetBSD uses 256, but that seems
  509                                      like awfully excessive kstack usage
  510                                      for an empty string... */
  511         u_int           rlen = SCARG(uap, len);
  512 
  513         switch (SCARG(uap, what)) {
  514         case SVR4_SI_SYSNAME:
  515                 str = ostype;
  516                 break;
  517 
  518         case SVR4_SI_HOSTNAME:
  519                 str = hostname;
  520                 break;
  521 
  522         case SVR4_SI_RELEASE:
  523                 str = osrelease;
  524                 break;
  525 
  526         case SVR4_SI_VERSION:
  527                 str = version;
  528                 break;
  529 
  530         case SVR4_SI_MACHINE:
  531                 str = machine;
  532                 break;
  533 
  534         case SVR4_SI_ARCHITECTURE:
  535                 str = machine;
  536                 break;
  537 
  538         case SVR4_SI_HW_SERIAL:
  539                 str = "";
  540                 break;
  541 
  542         case SVR4_SI_HW_PROVIDER:
  543                 str = ostype;
  544                 break;
  545 
  546         case SVR4_SI_SRPC_DOMAIN:
  547                 str = domainname;
  548                 break;
  549 
  550         case SVR4_SI_PLATFORM:
  551 #ifdef __i386__
  552                 str = "i86pc";
  553 #else
  554                 str = "unknown";
  555 #endif
  556                 break;
  557 
  558         case SVR4_SI_KERB_REALM:
  559                 str = "unsupported";
  560                 break;
  561 #if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
  562         case SVR4_SI_SET_HOSTNAME:
  563                 if ((error = suser(p)) != 0)
  564                         return error;
  565                 name = KERN_HOSTNAME;
  566                 return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
  567 
  568         case SVR4_SI_SET_SRPC_DOMAIN:
  569                 if ((error = suser(p)) != 0)
  570                         return error;
  571                 name = KERN_NISDOMAINNAME;
  572                 return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
  573 #else
  574         case SVR4_SI_SET_HOSTNAME:
  575         case SVR4_SI_SET_SRPC_DOMAIN:
  576                 /* FALLTHROUGH */
  577 #endif
  578         case SVR4_SI_SET_KERB_REALM:
  579                 return 0;
  580 
  581         default:
  582                 DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
  583                 return ENOSYS;
  584         }
  585 
  586         if (str) {
  587                 len = strlen(str) + 1;
  588                 if (len > rlen)
  589                         len = rlen;
  590 
  591                 if (SCARG(uap, buf)) {
  592                         error = copyout(str, SCARG(uap, buf), len);
  593                         if (error)
  594                                 return error;
  595                         /* make sure we are NULL terminated */
  596                         buf[0] = '\0';
  597                         error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
  598                 }
  599                 else
  600                         error = 0;
  601         }
  602         /* XXX NetBSD has hostname setting stuff here.  Why would an emulator
  603            want to do that? */
  604 
  605         *retval = len;
  606         return error;
  607 }
  608 
  609 int
  610 svr4_sys_utssys(p, uap)
  611         register struct proc *p;
  612         struct svr4_sys_utssys_args *uap;
  613 {
  614         switch (SCARG(uap, sel)) {
  615         case 0:         /* uname(2)  */
  616                 {
  617                         struct svr4_sys_uname_args ua;
  618                         SCARG(&ua, name) = SCARG(uap, a1);
  619                         return svr4_sys_uname(p, &ua);
  620                 }
  621 
  622         case 2:         /* ustat(2)  */
  623                 {
  624                         struct svr4_ustat_args ua;
  625                         SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
  626                         SCARG(&ua, name) = SCARG(uap, a1);
  627                         return svr4_ustat(p, &ua);
  628                 }
  629 
  630         case 3:         /* fusers(2) */
  631                 return ENOSYS;
  632 
  633         default:
  634                 return ENOSYS;
  635         }
  636         return ENOSYS;
  637 }
  638 
  639 
  640 int
  641 svr4_sys_utime(p, uap)
  642         register struct proc *p;
  643         struct svr4_sys_utime_args *uap;
  644 {
  645         struct svr4_utimbuf ub;
  646         struct timeval tbuf[2];
  647         struct utimes_args ap;
  648         int error;
  649         caddr_t sg = stackgap_init();
  650         void *ttp;
  651 
  652         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  653         SCARG(&ap, path) = SCARG(uap, path);
  654         if (SCARG(uap, ubuf) != NULL) {
  655                 if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
  656                         return error;
  657                 tbuf[0].tv_sec = ub.actime;
  658                 tbuf[0].tv_usec = 0;
  659                 tbuf[1].tv_sec = ub.modtime;
  660                 tbuf[1].tv_usec = 0;
  661                 ttp = stackgap_alloc(&sg, sizeof(tbuf));
  662                 error = copyout(tbuf, ttp, sizeof(tbuf));
  663                 if (error)
  664                         return error;
  665                 SCARG(&ap, tptr) = ttp;
  666         }
  667         else
  668                 SCARG(&ap, tptr) = NULL;
  669         return utimes(p, &ap);
  670 }
  671 
  672 
  673 int
  674 svr4_sys_utimes(p, uap)
  675         register struct proc *p;
  676         struct svr4_sys_utimes_args *uap;
  677 {
  678         caddr_t sg = stackgap_init();
  679         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  680         return utimes(p, (struct utimes_args *)uap);
  681 }
  682 
  683 static int
  684 svr4_to_bsd_pathconf(name)
  685         int name;
  686 {
  687         switch (name) {
  688         case SVR4_PC_LINK_MAX:
  689                 return _PC_LINK_MAX;
  690 
  691         case SVR4_PC_MAX_CANON:
  692                 return _PC_MAX_CANON;
  693 
  694         case SVR4_PC_MAX_INPUT:
  695                 return _PC_MAX_INPUT;
  696 
  697         case SVR4_PC_NAME_MAX:
  698                 return _PC_NAME_MAX;
  699 
  700         case SVR4_PC_PATH_MAX:
  701                 return _PC_PATH_MAX;
  702 
  703         case SVR4_PC_PIPE_BUF:
  704                 return _PC_PIPE_BUF;
  705 
  706         case SVR4_PC_NO_TRUNC:
  707                 return _PC_NO_TRUNC;
  708 
  709         case SVR4_PC_VDISABLE:
  710                 return _PC_VDISABLE;
  711 
  712         case SVR4_PC_CHOWN_RESTRICTED:
  713                 return _PC_CHOWN_RESTRICTED;
  714         case SVR4_PC_SYNC_IO:
  715 #if defined(_PC_SYNC_IO)
  716                 return _PC_SYNC_IO;
  717 #else
  718                 return 0;
  719 #endif
  720         case SVR4_PC_ASYNC_IO:
  721         case SVR4_PC_PRIO_IO:
  722                 /* Not supported */
  723                 return 0;
  724 
  725         default:
  726                 /* Invalid */
  727                 return -1;
  728         }
  729 }
  730 
  731 
  732 int
  733 svr4_sys_pathconf(p, uap)
  734         register struct proc *p;
  735         struct svr4_sys_pathconf_args *uap;
  736 {
  737         caddr_t         sg = stackgap_init();
  738         register_t      *retval = p->p_retval;
  739 
  740         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  741 
  742         SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
  743 
  744         switch (SCARG(uap, name)) {
  745         case -1:
  746                 *retval = -1;
  747                 return EINVAL;
  748         case 0:
  749                 *retval = 0;
  750                 return 0;
  751         default:
  752                 return pathconf(p, (struct pathconf_args *)uap);
  753         }
  754 }
  755 
  756 
  757 int
  758 svr4_sys_fpathconf(p, uap)
  759         register struct proc *p;
  760         struct svr4_sys_fpathconf_args *uap;
  761 {
  762         register_t      *retval = p->p_retval;
  763 
  764         SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
  765 
  766         switch (SCARG(uap, name)) {
  767         case -1:
  768                 *retval = -1;
  769                 return EINVAL;
  770         case 0:
  771                 *retval = 0;
  772                 return 0;
  773         default:
  774                 return fpathconf(p, (struct fpathconf_args *)uap);
  775         }
  776 }

Cache object: 70fe7dc6e0ea614460a5a3193af333fe


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