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/osf1/osf1_cvt.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: osf1_cvt.c,v 1.25 2007/12/08 18:36:20 dsl Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1999 Christopher G. Demetriou.  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. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Christopher G. Demetriou
   17  *      for the NetBSD Project.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
   35  * All rights reserved.
   36  *
   37  * Author: Chris G. Demetriou
   38  *
   39  * Permission to use, copy, modify and distribute this software and
   40  * its documentation is hereby granted, provided that both the copyright
   41  * notice and this permission notice appear in all copies of the
   42  * software, derivative works or modified versions, and any portions
   43  * thereof, and that both notices appear in supporting documentation.
   44  *
   45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
   47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   48  *
   49  * Carnegie Mellon requests users of this software to return to
   50  *
   51  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   52  *  School of Computer Science
   53  *  Carnegie Mellon University
   54  *  Pittsburgh PA 15213-3890
   55  *
   56  * any improvements or extensions that they make and grant Carnegie the
   57  * rights to redistribute these changes.
   58  */
   59 
   60 #include <sys/cdefs.h>
   61 __KERNEL_RCSID(0, "$NetBSD: osf1_cvt.c,v 1.25 2007/12/08 18:36:20 dsl Exp $");
   62 
   63 #include <sys/param.h>
   64 #include <sys/systm.h>
   65 #include <sys/namei.h>
   66 #include <sys/proc.h>
   67 #include <sys/file.h>
   68 #include <sys/stat.h>
   69 #include <sys/filedesc.h>
   70 #include <sys/kernel.h>
   71 #include <sys/malloc.h>
   72 #include <sys/mman.h>
   73 #include <sys/mount.h>
   74 #include <sys/signal.h>
   75 #include <sys/signalvar.h>
   76 #include <sys/reboot.h>
   77 #include <sys/syscallargs.h>
   78 #include <sys/exec.h>
   79 #include <sys/vnode.h>
   80 #include <sys/socket.h>
   81 #include <sys/socketvar.h>
   82 #include <sys/resource.h>
   83 #include <sys/resourcevar.h>
   84 #include <sys/wait.h>
   85 #include <uvm/uvm.h>                            /* XXX see mmap emulation */
   86 
   87 #include <nfs/rpcv2.h>
   88 #include <nfs/nfsproto.h>
   89 #include <nfs/nfs.h>
   90 #include <nfs/nfsmount.h>
   91 
   92 #include <compat/osf1/osf1.h>
   93 #include <compat/common/compat_util.h>
   94 #include <compat/osf1/osf1_cvt.h>
   95 
   96 const struct emul_flags_xtab osf1_access_flags_xtab[] = {
   97 #if 0 /* pseudo-flag */
   98     {   OSF1_F_OK,              OSF1_F_OK,              F_OK            },
   99 #endif
  100     {   OSF1_X_OK,              OSF1_X_OK,              X_OK            },
  101     {   OSF1_W_OK,              OSF1_W_OK,              W_OK            },
  102     {   OSF1_R_OK,              OSF1_R_OK,              R_OK            },
  103     {   0                                                               }
  104 };
  105 
  106 const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_rxtab[] = {
  107     {   FD_CLOEXEC,             FD_CLOEXEC,             OSF1_FD_CLOEXEC },
  108     {   0                                                               }
  109 };
  110 
  111 const struct emul_flags_xtab osf1_fcntl_getsetfd_flags_xtab[] = {
  112     {   OSF1_FD_CLOEXEC,        OSF1_FD_CLOEXEC,        FD_CLOEXEC      },
  113     {   0                                                               }
  114 };
  115 
  116 /* flags specific to GETFL/SETFL; also uses open rxtab */
  117 const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_rxtab[] = {
  118     {   FASYNC,                 FASYNC,                 OSF1_FASYNC     },
  119     {   0                                                               }
  120 };
  121 
  122 /* flags specific to GETFL/SETFL; also uses open xtab */
  123 const struct emul_flags_xtab osf1_fcntl_getsetfl_flags_xtab[] = {
  124     {   OSF1_FASYNC,            OSF1_FASYNC,            FASYNC          },
  125     {   0                                                               }
  126 };
  127 
  128 const struct emul_flags_xtab osf1_mmap_flags_xtab[] = {
  129     {   OSF1_MAP_SHARED,        OSF1_MAP_SHARED,        MAP_SHARED      },
  130     {   OSF1_MAP_PRIVATE,       OSF1_MAP_PRIVATE,       MAP_PRIVATE     },
  131     {   OSF1_MAP_TYPE,          OSF1_MAP_FILE,          MAP_FILE        },
  132     {   OSF1_MAP_TYPE,          OSF1_MAP_ANON,          MAP_ANON        },
  133     {   OSF1_MAP_FIXED,         OSF1_MAP_FIXED,         MAP_FIXED       },
  134 #if 0 /* pseudo-flag, and the default */
  135     {   OSF1_MAP_VARIABLE,      OSF1_MAP_VARIABLE,      0               },
  136 #endif
  137     {   OSF1_MAP_HASSEMAPHORE,  OSF1_MAP_HASSEMAPHORE,  MAP_HASSEMAPHORE },
  138     {   OSF1_MAP_INHERIT,       OSF1_MAP_INHERIT,       MAP_INHERIT     },
  139 #if 0 /* no equivalent +++ */
  140     {   OSF1_MAP_UNALIGNED,     OSF1_MAP_UNALIGNED,     ???             },
  141 #endif
  142     {   0                                                               }
  143 };
  144 
  145 const struct emul_flags_xtab osf1_mmap_prot_xtab[] = {
  146 #if 0 /* pseudo-flag */
  147     {   OSF1_PROT_NONE,         OSF1_PROT_NONE,         PROT_NONE       },
  148 #endif
  149     {   OSF1_PROT_READ,         OSF1_PROT_READ,         PROT_READ       },
  150     {   OSF1_PROT_WRITE,        OSF1_PROT_WRITE,        PROT_READ|PROT_WRITE },
  151     {   OSF1_PROT_EXEC,         OSF1_PROT_EXEC,         PROT_READ|PROT_EXEC },
  152     {   0                                                               }
  153 };
  154 
  155 const struct emul_flags_xtab osf1_nfs_mount_flags_xtab[] = {
  156     {   OSF1_NFSMNT_SOFT,       OSF1_NFSMNT_SOFT,       NFSMNT_SOFT,    },
  157     {   OSF1_NFSMNT_WSIZE,      OSF1_NFSMNT_WSIZE,      NFSMNT_WSIZE,   },
  158     {   OSF1_NFSMNT_RSIZE,      OSF1_NFSMNT_RSIZE,      NFSMNT_RSIZE,   },
  159     {   OSF1_NFSMNT_TIMEO,      OSF1_NFSMNT_TIMEO,      NFSMNT_TIMEO,   },
  160     {   OSF1_NFSMNT_RETRANS,    OSF1_NFSMNT_RETRANS,    NFSMNT_RETRANS, },
  161 #if 0 /* no equivalent; needs special handling, see below */
  162     {   OSF1_NFSMNT_HOSTNAME,   OSF1_NFSMNT_HOSTNAME,   ???,            },
  163 #endif
  164     {   OSF1_NFSMNT_INT,        OSF1_NFSMNT_INT,        NFSMNT_INT,     },
  165     {   OSF1_NFSMNT_NOCONN,     OSF1_NFSMNT_NOCONN,     NFSMNT_NOCONN,  },
  166 #if 0 /* no equivalents */
  167     {   OSF1_NFSMNT_NOAC,       OSF1_NFSMNT_NOAC,       ???,            },
  168     {   OSF1_NFSMNT_ACREGMIN,   OSF1_NFSMNT_ACREGMIN,   ???,            },
  169     {   OSF1_NFSMNT_ACREGMAX,   OSF1_NFSMNT_ACREGMAX,   ???,            },
  170     {   OSF1_NFSMNT_ACDIRMIN,   OSF1_NFSMNT_ACDIRMIN,   ???,            },
  171     {   OSF1_NFSMNT_ACDIRMAX,   OSF1_NFSMNT_ACDIRMAX,   ???,            },
  172     {   OSF1_NFSMNT_NOCTO,      OSF1_NFSMNT_NOCTO,      ???,            },
  173     {   OSF1_NFSMNT_POSIX,      OSF1_NFSMNT_POSIX,      ???,            },
  174     {   OSF1_NFSMNT_AUTO,       OSF1_NFSMNT_AUTO,       ???,            },
  175     {   OSF1_NFSMNT_SEC,        OSF1_NFSMNT_SEC,        ???,            },
  176     {   OSF1_NFSMNT_TCP,        OSF1_NFSMNT_TCP,        ???,            },
  177     {   OSF1_NFSMNT_PROPLIST,   OSF1_NFSMNT_PROPLIST,   ???,            },
  178 #endif
  179     {   0                                                               }
  180 };
  181 
  182 const struct emul_flags_xtab osf1_open_flags_rxtab[] = {
  183     {   O_ACCMODE,              O_RDONLY,               OSF1_O_RDONLY   },
  184     {   O_ACCMODE,              O_WRONLY,               OSF1_O_WRONLY   },
  185     {   O_ACCMODE,              O_RDWR,                 OSF1_O_RDWR     },
  186     {   O_NONBLOCK,             O_NONBLOCK,             OSF1_O_NONBLOCK },
  187     {   O_APPEND,               O_APPEND,               OSF1_O_APPEND   },
  188 #if 0 /* no equivalent +++ */
  189     {   ???,                    ???,                    O_DEFER         },
  190 #endif
  191     {   O_CREAT,                O_CREAT,                OSF1_O_CREAT    },
  192     {   O_TRUNC,                O_TRUNC,                OSF1_O_TRUNC    },
  193     {   O_EXCL,                 O_EXCL,                 OSF1_O_EXCL     },
  194     {   O_NOCTTY,               O_NOCTTY,               OSF1_O_NOCTTY   },
  195     {   O_SYNC,                 O_SYNC,                 OSF1_O_SYNC     },
  196     {   O_NDELAY,               O_NDELAY,               OSF1_O_NDELAY   },
  197 #if 0 /* no equivalent, also same value as O_NDELAY! */
  198     {   ???,                    ???,                    O_DRD           },
  199 #endif
  200     {   O_DSYNC,                O_DSYNC,                OSF1_O_DSYNC    },
  201     {   O_RSYNC,                O_RSYNC,                OSF1_O_RSYNC    },
  202     {   0                                                               }
  203 };
  204 
  205 const struct emul_flags_xtab osf1_open_flags_xtab[] = {
  206     {   OSF1_O_ACCMODE,         OSF1_O_RDONLY,          O_RDONLY        },
  207     {   OSF1_O_ACCMODE,         OSF1_O_WRONLY,          O_WRONLY        },
  208     {   OSF1_O_ACCMODE,         OSF1_O_RDWR,            O_RDWR          },
  209     {   OSF1_O_NONBLOCK,        OSF1_O_NONBLOCK,        O_NONBLOCK      },
  210     {   OSF1_O_APPEND,          OSF1_O_APPEND,          O_APPEND        },
  211 #if 0 /* no equivalent +++ */
  212     {   OSF1_O_DEFER,           OSF1_O_DEFER,           ???             },
  213 #endif
  214     {   OSF1_O_CREAT,           OSF1_O_CREAT,           O_CREAT         },
  215     {   OSF1_O_TRUNC,           OSF1_O_TRUNC,           O_TRUNC         },
  216     {   OSF1_O_EXCL,            OSF1_O_EXCL,            O_EXCL          },
  217     {   OSF1_O_NOCTTY,          OSF1_O_NOCTTY,          O_NOCTTY        },
  218     {   OSF1_O_SYNC,            OSF1_O_SYNC,            O_SYNC          },
  219     {   OSF1_O_NDELAY,          OSF1_O_NDELAY,          O_NDELAY        },
  220 #if 0 /* no equivalent, also same value as O_NDELAY! */
  221     {   OSF1_O_DRD,             OSF1_O_DRD,             ???             },
  222 #endif
  223     {   OSF1_O_DSYNC,           OSF1_O_DSYNC,           O_DSYNC         },
  224     {   OSF1_O_RSYNC,           OSF1_O_RSYNC,           O_RSYNC         },
  225     {   0                                                               }
  226 };
  227 
  228 const struct emul_flags_xtab osf1_reboot_opt_xtab[] = {
  229 #if 0 /* pseudo-flag */
  230     {   OSF1_RB_AUTOBOOT,       OSF1_RB_AUTOBOOT,       RB_AUTOBOOT     },
  231 #endif
  232     {   OSF1_RB_ASKNAME,        OSF1_RB_ASKNAME,        RB_ASKNAME      },
  233     {   OSF1_RB_SINGLE,         OSF1_RB_SINGLE,         RB_SINGLE       },
  234     {   OSF1_RB_NOSYNC,         OSF1_RB_NOSYNC,         RB_NOSYNC       },
  235 #if 0 /* same value as O_NDELAY, only used at boot time? */
  236     {   OSF1_RB_KDB,            OSF1_RB_KDB,            RB_KDB          },
  237 #endif
  238     {   OSF1_RB_HALT,           OSF1_RB_HALT,           RB_HALT         },
  239     {   OSF1_RB_INITNAME,       OSF1_RB_INITNAME,       RB_INITNAME     },
  240 #if 0 /* no equivalents +++ */
  241     {   OSF1_RB_DFLTROOT,       OSF1_RB_DFLTROOT,       ???             },
  242     {   OSF1_RB_ALTBOOT,        OSF1_RB_ALTBOOT,        ???             },
  243     {   OSF1_RB_UNIPROC,        OSF1_RB_UNIPROC,        ???             },
  244     {   OSF1_RB_PARAM,          OSF1_RB_PARAM,          ???             },
  245 #endif
  246     {   OSF1_RB_DUMP,           OSF1_RB_DUMP,           RB_DUMP         },
  247     {   0                                                               }
  248 };
  249 
  250 const struct emul_flags_xtab osf1_sendrecv_msg_flags_xtab[] = {
  251     {   OSF1_MSG_OOB,           OSF1_MSG_OOB,           MSG_OOB         },
  252     {   OSF1_MSG_PEEK,          OSF1_MSG_PEEK,          MSG_PEEK        },
  253     {   OSF1_MSG_DONTROUTE,     OSF1_MSG_DONTROUTE,     MSG_DONTROUTE   },
  254     {   OSF1_MSG_EOR,           OSF1_MSG_EOR,           MSG_EOR         },
  255     {   OSF1_MSG_TRUNC,         OSF1_MSG_TRUNC,         MSG_TRUNC       },
  256     {   OSF1_MSG_CTRUNC,        OSF1_MSG_CTRUNC,        MSG_CTRUNC      },
  257     {   OSF1_MSG_WAITALL,       OSF1_MSG_WAITALL,       MSG_WAITALL     },
  258     {   0                                                               }
  259 };
  260 
  261 const struct emul_flags_xtab osf1_sigaction_flags_rxtab[] = {
  262     {   SA_ONSTACK,             SA_ONSTACK,             OSF1_SA_ONSTACK },
  263     {   SA_RESTART,             SA_RESTART,             OSF1_SA_RESTART },
  264     {   SA_NOCLDSTOP,           SA_NOCLDSTOP,           OSF1_SA_NOCLDSTOP },
  265     {   SA_NODEFER,             SA_NODEFER,             OSF1_SA_NODEFER },
  266     {   SA_RESETHAND,           SA_RESETHAND,           OSF1_SA_RESETHAND },
  267     {   SA_NOCLDWAIT,           SA_NOCLDWAIT,           OSF1_SA_NOCLDWAIT },
  268 #if 0 /* XXX not yet */
  269     {   SA_SIGINFO,             SA_SIGINFO,             OSF1_SA_SIGINFO },
  270 #endif
  271     {   0                                                               },
  272 };
  273 
  274 const struct emul_flags_xtab osf1_sigaction_flags_xtab[] = {
  275     {   OSF1_SA_ONSTACK,        OSF1_SA_ONSTACK,        SA_ONSTACK      },
  276     {   OSF1_SA_RESTART,        OSF1_SA_RESTART,        SA_RESTART      },
  277     {   OSF1_SA_NOCLDSTOP,      OSF1_SA_NOCLDSTOP,      SA_NOCLDSTOP    },
  278     {   OSF1_SA_NODEFER,        OSF1_SA_NODEFER,        SA_NODEFER      },
  279     {   OSF1_SA_RESETHAND,      OSF1_SA_RESETHAND,      SA_RESETHAND    },
  280     {   OSF1_SA_NOCLDWAIT,      OSF1_SA_NOCLDWAIT,      SA_NOCLDWAIT    },
  281 #if 0 /* XXX not yet */
  282     {   OSF1_SA_SIGINFO,        OSF1_SA_SIGINFO,        SA_SIGINFO      },
  283 #endif
  284     {   0                                                               },
  285 };
  286 
  287 const struct emul_flags_xtab osf1_wait_options_xtab[] = {
  288     {   OSF1_WNOHANG,           OSF1_WNOHANG,           WNOHANG         },
  289     {   OSF1_WUNTRACED,         OSF1_WUNTRACED,         WUNTRACED       },
  290     {   0                                                               }
  291 };
  292 
  293 void
  294 osf1_cvt_flock_from_native(const struct flock *nf, struct osf1_flock *of)
  295 {
  296 
  297         memset(of, 0, sizeof of);
  298 
  299         of->l_start = nf->l_start;
  300         of->l_len = nf->l_len;
  301         of->l_pid = nf->l_pid;
  302 
  303         switch (nf->l_type) {
  304         case F_RDLCK:
  305                 of->l_type = OSF1_F_RDLCK;
  306                 break;
  307 
  308         case F_WRLCK:
  309                 of->l_type = OSF1_F_WRLCK;
  310                 break;
  311 
  312         case F_UNLCK:
  313                 of->l_type = OSF1_F_UNLCK;
  314                 break;
  315         }
  316 
  317         switch (nf->l_whence) {
  318         case SEEK_SET:
  319                 of->l_whence = OSF1_SEEK_SET;
  320                 break;
  321 
  322         case SEEK_CUR:
  323                 of->l_whence = OSF1_SEEK_CUR;
  324                 break;
  325 
  326         case SEEK_END:
  327                 of->l_whence = OSF1_SEEK_END;
  328                 break;
  329         }
  330 }
  331 
  332 int
  333 osf1_cvt_flock_to_native(const struct osf1_flock *of, struct flock *nf)
  334 {
  335 
  336         memset(nf, 0, sizeof nf);
  337 
  338         nf->l_start = of->l_start;
  339         nf->l_len = of->l_len;
  340         nf->l_pid = of->l_pid;
  341 
  342         switch (of->l_type) {
  343         case OSF1_F_RDLCK:
  344                 nf->l_type = F_RDLCK;
  345                 break;
  346 
  347         case OSF1_F_WRLCK:
  348                 nf->l_type = F_WRLCK;
  349                 break;
  350 
  351         case OSF1_F_UNLCK:
  352                 nf->l_type = F_UNLCK;
  353                 break;
  354 
  355         default:
  356                 return (EINVAL);
  357         }
  358 
  359         switch (of->l_whence) {
  360         case OSF1_SEEK_SET:
  361                 nf->l_whence = SEEK_SET;
  362                 break;
  363 
  364         case OSF1_SEEK_CUR:
  365                 nf->l_whence = SEEK_CUR;
  366                 break;
  367 
  368         case OSF1_SEEK_END:
  369                 nf->l_whence = SEEK_END;
  370                 break;
  371 
  372         default:
  373                 return (EINVAL);
  374         }
  375 
  376         return (0);
  377 }
  378 
  379 int
  380 osf1_cvt_msghdr_xopen_to_native(const struct osf1_msghdr_xopen *omh, struct msghdr *bmh)
  381 {
  382         unsigned long leftovers;
  383 
  384         memset(bmh, 0, sizeof bmh);
  385         bmh->msg_name = omh->msg_name;          /* XXX sockaddr translation */
  386         bmh->msg_namelen = omh->msg_namelen;
  387         bmh->msg_iov = NULL;                    /* iovec xlation separate */
  388         bmh->msg_iovlen = omh->msg_iovlen;
  389 
  390         /* XXX we don't translate control messages (yet) */
  391         if (bmh->msg_control != NULL || bmh->msg_controllen != 0)
  392 {
  393 printf("osf1_cvt_msghdr_xopen_to_native: control\n");
  394                 return (EINVAL);
  395 }
  396 
  397         /* translate flags */
  398         bmh->msg_flags = emul_flags_translate(osf1_sendrecv_msg_flags_xtab,
  399             omh->msg_flags, &leftovers);
  400         if (leftovers != 0)
  401 {
  402 printf("osf1_cvt_msghdr_xopen_to_native: leftovers 0x%lx\n", leftovers);
  403                 return (EINVAL);
  404 }
  405 
  406         return (0);
  407 }
  408 
  409 int
  410 osf1_cvt_pathconf_name_to_native(oname, bnamep)
  411         int oname, *bnamep;
  412 {
  413         int error;
  414 
  415         error  = 0;
  416         switch (oname) {
  417         case OSF1__PC_CHOWN_RESTRICTED:
  418                 *bnamep = _PC_CHOWN_RESTRICTED;
  419                 break;
  420 
  421         case OSF1__PC_LINK_MAX:
  422                 *bnamep = _PC_LINK_MAX;
  423                 break;
  424 
  425         case OSF1__PC_MAX_CANON:
  426                 *bnamep = _PC_MAX_CANON;
  427                 break;
  428 
  429         case OSF1__PC_MAX_INPUT:
  430                 *bnamep = _PC_MAX_INPUT;
  431                 break;
  432 
  433         case OSF1__PC_NAME_MAX:
  434                 *bnamep = _PC_NAME_MAX;
  435                 break;
  436 
  437         case OSF1__PC_NO_TRUNC:
  438                 *bnamep = _PC_NO_TRUNC;
  439                 break;
  440 
  441         case OSF1__PC_PATH_MAX:
  442                 *bnamep = _PC_PATH_MAX;
  443                 break;
  444 
  445         case OSF1__PC_PIPE_BUF:
  446                 *bnamep = _PC_PIPE_BUF;
  447                 break;
  448 
  449         case OSF1__PC_VDISABLE:
  450                 *bnamep = _PC_VDISABLE;
  451                 break;
  452 
  453         default:
  454                 error = EINVAL;
  455                 break;
  456         }
  457 
  458         return (error);
  459 }
  460 
  461 /*
  462  * Convert from as rusage structure to an osf1 rusage structure.
  463  */
  464 void
  465 osf1_cvt_rusage_from_native(const struct rusage *ru, struct osf1_rusage *oru)
  466 {
  467 
  468         oru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
  469         oru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
  470 
  471         oru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
  472         oru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
  473 
  474         oru->ru_maxrss = ru->ru_maxrss;
  475         oru->ru_ixrss = ru->ru_ixrss;
  476         oru->ru_idrss = ru->ru_idrss;
  477         oru->ru_isrss = ru->ru_isrss;
  478         oru->ru_minflt = ru->ru_minflt;
  479         oru->ru_majflt = ru->ru_majflt;
  480         oru->ru_nswap = ru->ru_nswap;
  481         oru->ru_inblock = ru->ru_inblock;
  482         oru->ru_oublock = ru->ru_oublock;
  483         oru->ru_msgsnd = ru->ru_msgsnd;
  484         oru->ru_msgrcv = ru->ru_msgrcv;
  485         oru->ru_nsignals = ru->ru_nsignals;
  486         oru->ru_nvcsw = ru->ru_nvcsw;
  487         oru->ru_nivcsw = ru->ru_nivcsw;
  488 }
  489 
  490 /*
  491  * XXX: Only a subset of the flags is currently implemented.
  492  */
  493 void
  494 osf1_cvt_sigaction_from_native(const struct sigaction *bsa, struct osf1_sigaction *osa)
  495 {
  496 
  497         osa->osf1_sa_handler = bsa->sa_handler;
  498         osf1_cvt_sigset_from_native(&bsa->sa_mask, &osa->osf1_sa_mask);
  499 
  500         /* translate flags */
  501         osa->osf1_sa_flags = emul_flags_translate(osf1_sigaction_flags_rxtab,
  502             bsa->sa_flags, NULL);
  503 }
  504 
  505 int
  506 osf1_cvt_sigaction_to_native(const struct osf1_sigaction *osa, struct sigaction *bsa)
  507 {
  508 
  509         bsa->sa_handler = osa->osf1_sa_handler;
  510         osf1_cvt_sigset_to_native(&osa->osf1_sa_mask, &bsa->sa_mask);
  511 
  512         /* translate flags */
  513         bsa->sa_flags = emul_flags_translate(osf1_sigaction_flags_xtab,
  514             osa->osf1_sa_flags, NULL);
  515         /* XXX error if we can't translate */
  516 
  517         return (0);
  518 }
  519 
  520 void
  521 osf1_cvt_sigset_from_native(const sigset_t *bss, osf1_sigset_t *oss)
  522 {
  523         int i, newsig;
  524 
  525         osf1_sigemptyset(oss);
  526         for (i = 1; i < NSIG; i++) {
  527                 if (sigismember(bss, i)) {
  528                         newsig = native_to_osf1_signo[i];
  529                         if (newsig)
  530                                 osf1_sigaddset(oss, newsig);
  531                 }
  532         }
  533 }
  534 
  535 int
  536 osf1_cvt_sigset_to_native(const osf1_sigset_t *oss, sigset_t *bss)
  537 {
  538         int i, newsig;
  539 
  540         sigemptyset(bss);
  541         for (i = 1; i < OSF1_NSIG; i++) {
  542                 if (osf1_sigismember(oss, i)) {
  543                         newsig = osf1_to_native_signo[i];
  544                         if (newsig)
  545                                 sigaddset(bss, newsig);
  546                 }
  547         }
  548         return (0);
  549 }
  550 
  551 /*
  552  * Convert from a stat structure to an osf1 stat structure.
  553  */
  554 void
  555 osf1_cvt_stat_from_native(const struct stat *st, struct osf1_stat *ost)
  556 {
  557 
  558         ost->st_dev = osf1_cvt_dev_from_native(st->st_dev);
  559         ost->st_ino = st->st_ino;
  560         ost->st_mode = st->st_mode;
  561         ost->st_nlink = st->st_nlink;
  562         ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid;
  563         ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid;
  564         ost->st_rdev = osf1_cvt_dev_from_native(st->st_rdev);
  565         ost->st_size = st->st_size;
  566         ost->st_atime_sec = st->st_atime;
  567         ost->st_spare1 = 0;
  568         ost->st_mtime_sec = st->st_mtime;
  569         ost->st_spare2 = 0;
  570         ost->st_ctime_sec = st->st_ctime;
  571         ost->st_spare3 = 0;
  572         ost->st_blksize = st->st_blksize;
  573         ost->st_blocks = st->st_blocks;
  574         ost->st_flags = st->st_flags;
  575         ost->st_gen = st->st_gen;
  576 }
  577 
  578 /*
  579  * Convert from a stat structure to an osf1 stat structure.
  580  */
  581 void
  582 osf1_cvt_stat2_from_native(const struct stat *st, struct osf1_stat2 *ost)
  583 {
  584 
  585         memset(ost, 0, sizeof *ost);
  586         ost->st_dev = osf1_cvt_dev_from_native(st->st_dev);
  587         ost->st_ino = st->st_ino;
  588         ost->st_mode = st->st_mode;
  589         ost->st_nlink = st->st_nlink;
  590         ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid;
  591         ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid;
  592         ost->st_rdev = osf1_cvt_dev_from_native(st->st_rdev);
  593         ost->st_size = st->st_size;
  594         ost->st_atime_sec = st->st_atime;
  595         ost->st_mtime_sec = st->st_mtime;
  596         ost->st_ctime_sec = st->st_ctime;
  597         ost->st_blocksize = st->st_blksize;
  598         ost->st_blocks = st->st_blocks;
  599         ost->st_flags = st->st_flags;
  600         ost->st_generation = st->st_gen;
  601 }
  602 
  603 void
  604 osf1_cvt_statfs_from_native(const struct statvfs *bsfs, struct osf1_statfs *osfs)
  605 {
  606 
  607         memset(osfs, 0, sizeof (struct osf1_statfs));
  608         if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
  609                 osfs->f_type = OSF1_MOUNT_UFS;
  610         else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
  611                 osfs->f_type = OSF1_MOUNT_NFS;
  612         else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
  613                 osfs->f_type = OSF1_MOUNT_MFS;
  614         else
  615                 /* uh oh...  XXX = PC, CDFS, PROCFS, etc. */
  616                 osfs->f_type = OSF1_MOUNT_ADDON;
  617         osfs->f_flags = bsfs->f_flag;           /* XXX translate */
  618         osfs->f_fsize = bsfs->f_frsize;
  619         osfs->f_bsize = bsfs->f_bsize;
  620         osfs->f_blocks = bsfs->f_blocks;
  621         osfs->f_bfree = bsfs->f_bfree;
  622         osfs->f_bavail = bsfs->f_bavail;
  623         osfs->f_files = bsfs->f_files;
  624         osfs->f_ffree = bsfs->f_ffree;
  625         memcpy(&osfs->f_fsid, &bsfs->f_fsidx, sizeof osfs->f_fsid);
  626         /* osfs->f_spare zeroed above */
  627         memcpy(osfs->f_mntonname, bsfs->f_mntonname, sizeof osfs->f_mntonname);
  628         memcpy(osfs->f_mntfromname, bsfs->f_mntfromname,
  629             sizeof osfs->f_mntfromname);
  630         /* XXX osfs->f_xxx should be filled in... */
  631 }

Cache object: cc0369be37328903630209aaaec0cf10


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