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

Cache object: 1fa0a4ca639f456687761bc6dfd3162c


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