home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3999 / system.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-09  |  6.1 KB  |  245 lines

  1. /*
  2.  * @(#)system.c    1.1 91/09/06
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include <sys/ptrace.h>
  8. #include <sys/reboot.h>
  9. #define NFSCLIENT
  10. #define LOFS
  11. #define RFS
  12. #define PCFS
  13. #include <sys/mount.h>
  14. #include <sys/socket.h>
  15. #include <nfs/export.h>
  16. #include <rpc/types.h>
  17. #include <rpc/auth.h>
  18.  
  19. #include "defs.h"
  20.  
  21. int
  22. sys_sync(tcp)
  23. struct tcb *tcp;
  24. {
  25.     return 0;
  26. }
  27.  
  28. static Xlat bootflags[] = {
  29.     RB_AUTOBOOT,    "AUTOBOOT",    /* flags for system auto-booting itself */
  30.     RB_ASKNAME,    "ASKNAME",    /* ask for file name to reboot from */
  31.     RB_SINGLE,    "SINGLE",    /* reboot to single user only */
  32.     RB_NOSYNC,    "NOSYNC",    /* dont sync before reboot */
  33.     RB_HALT,    "HALT",        /* don't reboot, just halt */
  34.     RB_INITNAME,    "INITNAME",    /* name given for /etc/init */
  35.     RB_NOBOOTRC,    "NOBOOTRC",    /* don't run /etc/rc.boot */
  36.     RB_DEBUG,    "DEBUG",    /* being run under debugger */
  37.     RB_DUMP,    "DUMP",        /* dump system core */
  38.     RB_WRITABLE,    "WRITABLE",    /* mount root read/write */
  39.     RB_STRING,    "STRING",    /* pass boot args to prom monitor */
  40.     0,        NULL,
  41. };
  42.  
  43. int
  44. sys_reboot(tcp)
  45. struct tcb *tcp;
  46. {
  47.     if (entering(tcp)) {
  48.         printflags(bootflags, tcp->u_args[0]);
  49.         if (tcp->u_args[0] & RB_STRING) {
  50.             printstr(tcp->pid, tcp->u_args[1], -1);
  51.         }
  52.     }
  53.     return 0;
  54. }
  55.  
  56. int
  57. sys_sysacct(tcp)
  58. struct tcb *tcp;
  59. {
  60.     if (entering(tcp)) {
  61.         printstr(tcp->pid, tcp->u_args[0], -1);
  62.     }
  63.     return 0;
  64. }
  65.  
  66. int
  67. sys_swapon(tcp)
  68. struct tcb *tcp;
  69. {
  70.     if (entering(tcp)) {
  71.         printstr(tcp->pid, tcp->u_args[0], -1);
  72.     }
  73.     return 0;
  74. }
  75.  
  76. static Xlat mountflags[] = {
  77.     M_RDONLY,    "RDONLY",    /* mount fs read only */
  78.     M_NOSUID,    "NOSUID",    /* mount fs with setuid not allowed */
  79.     M_NEWTYPE,    "NEWTYPE",    /* use type string instead of int */
  80.     M_GRPID,    "GRPID",    /* Old BSD group-id on create */
  81.     M_REMOUNT,    "REMOUNT",    /* change options on an existing mount */
  82.     M_NOSUB,    "NOSUB",    /* Disallow mounts beneath this mount */
  83.     M_MULTI,    "MULTI",    /* Do multi-component lookup on files */
  84.     M_SYS5,        "SYS5",        /* Mount with Sys 5-specific semantics */
  85.     0,        NULL,
  86. };
  87. static Xlat nfsflags[] = {
  88.     NFSMNT_SOFT,    "SOFT",        /* soft mount (hard is default) */
  89.     NFSMNT_WSIZE,    "WSIZE",    /* set write size */
  90.     NFSMNT_RSIZE,    "RSIZE",    /* set read size */
  91.     NFSMNT_TIMEO,    "TIMEO",    /* set initial timeout */
  92.     NFSMNT_RETRANS,    "RETRANS",    /* set number of request retrys */
  93.     NFSMNT_HOSTNAME,"HOSTNAME",    /* set hostname for error printf */
  94.     NFSMNT_INT,    "INT",        /* allow interrupts on hard mount */
  95.     NFSMNT_NOAC,    "NOAC",        /* don't cache attributes */
  96.     NFSMNT_ACREGMIN,"ACREGMIN",    /* set min secs for file attr cache */
  97.     NFSMNT_ACREGMAX,"ACREGMAX",    /* set max secs for file attr cache */
  98.     NFSMNT_ACDIRMIN,"ACDIRMIN",    /* set min secs for dir attr cache */
  99.     NFSMNT_ACDIRMAX,"ACDIRMAX",    /* set max secs for dir attr cache */
  100.     NFSMNT_SECURE,    "SECURE",    /* secure mount */
  101.     NFSMNT_NOCTO,    "NOCTO",    /* no close-to-open consistency */
  102.     NFSMNT_POSIX,    "POSIX",    /* static pathconf kludge info */
  103.     0,        NULL,
  104. };
  105.  
  106. int
  107. sys_mount(tcp)
  108. struct tcb *tcp;
  109. {
  110.     char type[4];
  111.  
  112.     if (entering(tcp)) {
  113.         if (!(tcp->u_args[2] & M_NEWTYPE) || umovestr(tcp->pid,
  114.                 tcp->u_args[0],  sizeof type, type) < 0) {
  115.             fprintf(outf, "OLDTYPE:#%x", tcp->u_args[0]);
  116.         } else {
  117.             fprintf(outf, "%s, ", type);
  118.         }
  119.         printstr(tcp->pid, tcp->u_args[1], -1);
  120.         fprintf(outf, ", ");
  121.         printflags(mountflags, tcp->u_args[2] & ~M_NEWTYPE);
  122.         fprintf(outf, ", ");
  123.  
  124.         if (strcmp(type, "4.2") == 0) {
  125.             struct ufs_args a;
  126.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, &a) < 0)
  127.                 return 0;
  128.             printstr(tcp->pid, a.fspec, -1);
  129.         } else if (strcmp(type, "lo") == 0) {
  130.             struct lo_args a;
  131.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, &a) < 0)
  132.                 return 0;
  133.             printstr(tcp->pid, a.fsdir, -1);
  134.         } else if (strcmp(type, "nfs") == 0) {
  135.             struct nfs_args a;
  136.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, &a) < 0)
  137.                 return 0;
  138.             fprintf(outf, "[");
  139.             printsock(tcp->pid, a.addr);
  140.             fprintf(outf, ", ");
  141.             printflags(nfsflags, a.flags);
  142.             fprintf(outf, ", ws:%u,rs:%u,to:%u,re:%u,",
  143.                 a.wsize, a.rsize, a.timeo, a.retrans);
  144.             if (a.flags & NFSMNT_HOSTNAME && a.hostname)
  145.                 printstr(tcp->pid, a.hostname, -1);
  146.             else
  147.                 fprintf(outf, "%#x", a.hostname);
  148.             fprintf(outf, ",reg-min:%u,max:%u,dir-min:%u,max:%u,",
  149.                 a.acregmin, a.acregmax, a.acdirmin, a.acdirmax);
  150.             if (a.flags & NFSMNT_SECURE && a.netname)
  151.                 printstr(tcp->pid, a.netname, -1);
  152.             else
  153.                 fprintf(outf, "%#x", a.netname);
  154.             fprintf(outf, "]");
  155.         } else if (strcmp(type, "rfs") == 0) {
  156.             struct rfs_args a;
  157.             struct token t;
  158.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, &a) < 0)
  159.                 return 0;
  160.             fprintf(outf, "[");
  161.             printstr(tcp->pid, a.rmtfs, -1);
  162.             if (umove(tcp->pid, a.token, sizeof t, &t) < 0)
  163.                 return 0;
  164.             fprintf(outf, ", %u, %s]", t.t_id, t.t_uname);
  165.         } else if (strcmp(type, "pcfs") == 0) {
  166.             struct pc_args a;
  167.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, &a) < 0)
  168.                 return 0;
  169.             printstr(tcp->pid, a.fspec, -1);
  170.         }
  171.     }
  172.     return 0;
  173. }
  174.  
  175. int
  176. sys_unmount(tcp)
  177. struct tcb *tcp;
  178. {
  179.     if (entering(tcp)) {
  180.         printstr(tcp->pid, tcp->u_args[0], -1);
  181.     }
  182.     return 0;
  183. }
  184.  
  185. int
  186. sys_umount(tcp)
  187. struct tcb *tcp;
  188. {
  189.     return sys_unmount(tcp);
  190. }
  191.  
  192. int
  193. sys_auditsys(tcp)
  194. struct tcb *tcp;
  195. {
  196.     /* XXX - no information available */
  197.     return printargs(tcp);
  198. }
  199.  
  200. static Xlat ex_auth_flags[] = {
  201.     AUTH_UNIX,     "AUTH_UNIX",
  202.     AUTH_DES,     "AUTH_DES",
  203.     0,        NULL,
  204. };
  205.  
  206. int
  207. sys_exportfs(tcp)
  208. struct tcb *tcp;
  209. {
  210.     struct export e;
  211.     int i;
  212.  
  213.     if (entering(tcp)) {
  214.         printstr(tcp->pid, tcp->u_args[0], -1);
  215.         if (umove(tcp->pid, tcp->u_args[1], sizeof e, (char *)&e) < 0) {
  216.             fprintf(outf, "%#x", tcp->u_args[1]);
  217.             return 0;
  218.         }
  219.         fprintf(outf, "{fl:%u, anon:%u, ", e.ex_flags, e.ex_anon);
  220.         printxval(ex_auth_flags, e.ex_auth, "AUTH_???");
  221.         fprintf(outf, ", roots:[");
  222.         if (e.ex_auth == AUTH_UNIX) {
  223.             for (i=0; i<e.ex_u.exunix.rootaddrs.naddrs; i++) {
  224.                 printsock(tcp->pid,
  225.                     &e.ex_u.exunix.rootaddrs.addrvec[i]);
  226.             }
  227.             fprintf(outf, "], writers:[");
  228.             for (i=0; i<e.ex_writeaddrs.naddrs; i++) {
  229.                 printsock(tcp->pid,
  230.                     &e.ex_writeaddrs.addrvec[i]);
  231.             }
  232.             fprintf(outf, "]");
  233.         } else {
  234.             for (i=0; i<e.ex_u.exdes.nnames; i++) {
  235.                 printsock(tcp->pid,
  236.                     &e.ex_u.exdes.rootnames[i]);
  237.                 fprintf(outf, ", ");
  238.             }
  239.             fprintf(outf, "], window:%u", e.ex_u.exdes.window);
  240.         }
  241.         fprintf(outf, "}");
  242.     }
  243.     return 0;
  244. }
  245.