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

Cache object: 9078b8a60ca57303fcc27b5955216f0b


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