home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume3 / strace / part02 / system.c < prev   
Encoding:
C/C++ Source or Header  |  1992-03-02  |  8.6 KB  |  365 lines

  1. /*
  2.  * @(#)system.c    2.4 92/01/21
  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. /*ARGSUSED*/
  22. int
  23. sys_sync(tcp)
  24. struct tcb *tcp;
  25. {
  26.     return 0;
  27. }
  28.  
  29. static Xlat bootflags[] = {
  30.     RB_AUTOBOOT,    "AUTOBOOT",    /* flags for system auto-booting itself */
  31.     RB_ASKNAME,    "ASKNAME",    /* ask for file name to reboot from */
  32.     RB_SINGLE,    "SINGLE",    /* reboot to single user only */
  33.     RB_NOSYNC,    "NOSYNC",    /* dont sync before reboot */
  34.     RB_HALT,    "HALT",        /* don't reboot, just halt */
  35.     RB_INITNAME,    "INITNAME",    /* name given for /etc/init */
  36.     RB_NOBOOTRC,    "NOBOOTRC",    /* don't run /etc/rc.boot */
  37.     RB_DEBUG,    "DEBUG",    /* being run under debugger */
  38.     RB_DUMP,    "DUMP",        /* dump system core */
  39.     RB_WRITABLE,    "WRITABLE",    /* mount root read/write */
  40.     RB_STRING,    "STRING",    /* pass boot args to prom monitor */
  41.     0,        NULL,
  42. };
  43.  
  44. int
  45. sys_reboot(tcp)
  46. struct tcb *tcp;
  47. {
  48.     if (entering(tcp)) {
  49.         if (!printflags(bootflags, tcp->u_args[0]))
  50.             tprintf("RB_???");
  51.         if (tcp->u_args[0] & RB_STRING) {
  52.             (void)printstr(tcp->pid, tcp->u_args[1], -1);
  53.         }
  54.     }
  55.     return 0;
  56. }
  57.  
  58. int
  59. sys_sysacct(tcp)
  60. struct tcb *tcp;
  61. {
  62.     if (entering(tcp)) {
  63.         (void)printstr(tcp->pid, tcp->u_args[0], -1);
  64.     }
  65.     return 0;
  66. }
  67.  
  68. int
  69. sys_swapon(tcp)
  70. struct tcb *tcp;
  71. {
  72.     if (entering(tcp)) {
  73.         (void)printstr(tcp->pid, tcp->u_args[0], -1);
  74.     }
  75.     return 0;
  76. }
  77.  
  78. int
  79. sys_nfs_svc(tcp)
  80. struct tcb *tcp;
  81. {
  82.     if (entering(tcp)) {
  83.         printsock(tcp->pid, tcp->u_args[0]);
  84.     }
  85.     return 0;
  86. }
  87.  
  88. static Xlat mountflags[] = {
  89.     M_RDONLY,    "RDONLY",    /* mount fs read only */
  90.     M_NOSUID,    "NOSUID",    /* mount fs with setuid not allowed */
  91.     M_NEWTYPE,    "NEWTYPE",    /* use type string instead of int */
  92.     M_GRPID,    "GRPID",    /* Old BSD group-id on create */
  93. #ifdef    M_REMOUNT
  94.     M_REMOUNT,    "REMOUNT",    /* change options on an existing mount */
  95. #endif
  96. #ifdef    M_NOSUB
  97.     M_NOSUB,    "NOSUB",    /* Disallow mounts beneath this mount */
  98. #endif
  99. #ifdef    M_MULTI
  100.     M_MULTI,    "MULTI",    /* Do multi-component lookup on files */
  101. #endif
  102. #ifdef    M_SYS5
  103.     M_SYS5,        "SYS5",        /* Mount with Sys 5-specific semantics */
  104. #endif
  105.     0,        NULL,
  106. };
  107. static Xlat nfsflags[] = {
  108.     NFSMNT_SOFT,    "SOFT",        /* soft mount (hard is default) */
  109.     NFSMNT_WSIZE,    "WSIZE",    /* set write size */
  110.     NFSMNT_RSIZE,    "RSIZE",    /* set read size */
  111.     NFSMNT_TIMEO,    "TIMEO",    /* set initial timeout */
  112.     NFSMNT_RETRANS,    "RETRANS",    /* set number of request retrys */
  113.     NFSMNT_HOSTNAME,"HOSTNAME",    /* set hostname for error printf */
  114.     NFSMNT_INT,    "INT",        /* allow interrupts on hard mount */
  115.     NFSMNT_NOAC,    "NOAC",        /* don't cache attributes */
  116.     NFSMNT_ACREGMIN,"ACREGMIN",    /* set min secs for file attr cache */
  117.     NFSMNT_ACREGMAX,"ACREGMAX",    /* set max secs for file attr cache */
  118.     NFSMNT_ACDIRMIN,"ACDIRMIN",    /* set min secs for dir attr cache */
  119.     NFSMNT_ACDIRMAX,"ACDIRMAX",    /* set max secs for dir attr cache */
  120. #ifdef    NFSMNT_SECURE
  121.     NFSMNT_SECURE,    "SECURE",    /* secure mount */
  122. #endif
  123. #ifdef    NFSMNT_NOCTO
  124.     NFSMNT_NOCTO,    "NOCTO",    /* no close-to-open consistency */
  125. #endif
  126. #ifdef    NFSMNT_POSIX
  127.     NFSMNT_POSIX,    "POSIX",    /* static pathconf kludge info */
  128. #endif
  129.     0,        NULL,
  130. };
  131.  
  132. int
  133. sys_mount(tcp)
  134. struct tcb *tcp;
  135. {
  136.     char type[4];
  137.  
  138.     if (entering(tcp)) {
  139.         if (!(tcp->u_args[2] & M_NEWTYPE) || umovestr(tcp->pid,
  140.                 tcp->u_args[0],  sizeof type, type) < 0) {
  141.             tprintf("OLDTYPE:#%x", tcp->u_args[0]);
  142.         } else {
  143.             tprintf("%s, ", type);
  144.         }
  145.         (void)printstr(tcp->pid, tcp->u_args[1], -1);
  146.         tprintf(", ");
  147.         if (!printflags(mountflags, tcp->u_args[2] & ~M_NEWTYPE))
  148.             tprintf("M_???");
  149.         tprintf(", ");
  150.  
  151.         if (strcmp(type, "4.2") == 0) {
  152.             struct ufs_args a;
  153.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, (char *)&a) < 0)
  154.                 return 0;
  155.             (void)printstr(tcp->pid, (int)a.fspec, -1);
  156.         } else if (strcmp(type, "lo") == 0) {
  157.             struct lo_args a;
  158.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, (char *)&a) < 0)
  159.                 return 0;
  160.             (void)printstr(tcp->pid, (int)a.fsdir, -1);
  161.         } else if (strcmp(type, "nfs") == 0) {
  162.             struct nfs_args a;
  163.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, (char *)&a) < 0)
  164.                 return 0;
  165.             tprintf("[");
  166.             printsock(tcp->pid, (int)a.addr);
  167.             tprintf(", ");
  168.             if (!printflags(nfsflags, a.flags))
  169.                 tprintf("NFSMNT_???");
  170.             tprintf(", ws:%u,rs:%u,to:%u,re:%u,",
  171.                 a.wsize, a.rsize, a.timeo, a.retrans);
  172.             if (a.flags & NFSMNT_HOSTNAME && a.hostname)
  173.                 (void)printstr(tcp->pid, (int)a.hostname, -1);
  174.             else
  175.                 tprintf("%#x", a.hostname);
  176.             tprintf(",reg-min:%u,max:%u,dir-min:%u,max:%u,",
  177.                 a.acregmin, a.acregmax, a.acdirmin, a.acdirmax);
  178.             if (a.flags & NFSMNT_SECURE && a.netname)
  179.                 (void)printstr(tcp->pid, (int)a.netname, -1);
  180.             else
  181.                 tprintf("%#x", a.netname);
  182.             tprintf("]");
  183.         } else if (strcmp(type, "rfs") == 0) {
  184.             struct rfs_args a;
  185.             struct token t;
  186.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, (char *)&a) < 0)
  187.                 return 0;
  188.             tprintf("[");
  189.             (void)printstr(tcp->pid, (int)a.rmtfs, -1);
  190.             if (umove(tcp->pid, (int)a.token, sizeof t, (char *)&t) < 0)
  191.                 return 0;
  192.             tprintf(", %u, %s]", t.t_id, t.t_uname);
  193.         } else if (strcmp(type, "pcfs") == 0) {
  194.             struct pc_args a;
  195.             if (umove(tcp->pid, tcp->u_args[3], sizeof a, (char *)&a) < 0)
  196.                 return 0;
  197.             (void)printstr(tcp->pid, (int)a.fspec, -1);
  198.         }
  199.     }
  200.     return 0;
  201. }
  202.  
  203. int
  204. sys_unmount(tcp)
  205. struct tcb *tcp;
  206. {
  207.     if (entering(tcp)) {
  208.         (void)printstr(tcp->pid, tcp->u_args[0], -1);
  209.     }
  210.     return 0;
  211. }
  212.  
  213. int
  214. sys_umount(tcp)
  215. struct tcb *tcp;
  216. {
  217.     return sys_unmount(tcp);
  218. }
  219.  
  220. int
  221. sys_auditsys(tcp)
  222. struct tcb *tcp;
  223. {
  224.     /* XXX - no information available */
  225.     return printargs(tcp);
  226. }
  227.  
  228. static Xlat ex_auth_flags[] = {
  229.     AUTH_UNIX,     "AUTH_UNIX",
  230.     AUTH_DES,     "AUTH_DES",
  231.     0,        NULL,
  232. };
  233.  
  234. int
  235. sys_exportfs(tcp)
  236. struct tcb *tcp;
  237. {
  238.     struct export e;
  239.     int i;
  240.  
  241.     if (entering(tcp)) {
  242.         (void)printstr(tcp->pid, tcp->u_args[0], -1);
  243.         if (umove(tcp->pid, tcp->u_args[1], sizeof e, (char *)&e) < 0) {
  244.             tprintf("%#x", tcp->u_args[1]);
  245.             return 0;
  246.         }
  247.         tprintf("{fl:%u, anon:%u, ", e.ex_flags, e.ex_anon);
  248.         printxval(ex_auth_flags, e.ex_auth, "AUTH_???");
  249.         tprintf(", roots:[");
  250.         if (e.ex_auth == AUTH_UNIX) {
  251.             for (i=0; i<e.ex_u.exunix.rootaddrs.naddrs; i++) {
  252.                 printsock(tcp->pid,
  253.                     (int)&e.ex_u.exunix.rootaddrs.addrvec[i]);
  254.             }
  255.             tprintf("], writers:[");
  256.             for (i=0; i<e.ex_writeaddrs.naddrs; i++) {
  257.                 printsock(tcp->pid,
  258.                     (int)&e.ex_writeaddrs.addrvec[i]);
  259.             }
  260.             tprintf("]");
  261.         } else {
  262.             for (i=0; i<e.ex_u.exdes.nnames; i++) {
  263.                 printsock(tcp->pid,
  264.                     (int)&e.ex_u.exdes.rootnames[i]);
  265.                 tprintf(", ");
  266.             }
  267.             tprintf("], window:%u", e.ex_u.exdes.window);
  268.         }
  269.         tprintf("}");
  270.     }
  271.     return 0;
  272. }
  273.  
  274. static Xlat sysconflimits[] = {
  275. #ifdef    _SC_ARG_MAX
  276.     _SC_ARG_MAX,        "_SC_ARG_MAX",        /* space for argv & envp */
  277. #endif
  278. #ifdef    _SC_CHILD_MAX
  279.     _SC_CHILD_MAX,        "_SC_CHILD_MAX",    /* maximum children per process??? */
  280. #endif
  281. #ifdef    _SC_CLK_TCK
  282.     _SC_CLK_TCK,        "_SC_CLK_TCK",        /* clock ticks/sec */
  283. #endif
  284. #ifdef    _SC_NGROUPS_MAX
  285.     _SC_NGROUPS_MAX,    "_SC_NGROUPS_MAX",    /* number of groups if multple supp. */
  286. #endif
  287. #ifdef    _SC_OPEN_MAX
  288.     _SC_OPEN_MAX,        "_SC_OPEN_MAX",        /* max open files per process */
  289. #endif
  290. #ifdef    _SC_JOB_CONTROL
  291.     _SC_JOB_CONTROL,    "_SC_JOB_CONTROL",    /* do we have job control */
  292. #endif
  293. #ifdef    _SC_SAVED_IDS
  294.     _SC_SAVED_IDS,        "_SC_SAVED_IDS",    /* do we have saved uid/gids */
  295. #endif
  296. #ifdef    _SC_VERSION
  297.     _SC_VERSION,        "_SC_VERSION",        /* POSIX version supported */
  298. #endif
  299.     0,         NULL,
  300. };
  301.  
  302. static Xlat pathconflimits[] = {
  303. #ifdef    _PC_LINK_MAX
  304.     _PC_LINK_MAX,    "_PC_LINK_MAX",        /* max links to file/dir */
  305. #endif
  306. #ifdef    _PC_MAX_CANON
  307.     _PC_MAX_CANON,    "_PC_MAX_CANON",    /* max line length */
  308. #endif
  309. #ifdef    _PC_MAX_INPUT
  310.     _PC_MAX_INPUT,    "_PC_MAX_INPUT",    /* max "packet" to a tty device */
  311. #endif
  312. #ifdef    _PC_NAME_MAX
  313.     _PC_NAME_MAX,    "_PC_NAME_MAX",        /* max pathname component length */
  314. #endif
  315. #ifdef    _PC_PATH_MAX
  316.     _PC_PATH_MAX,    "_PC_PATH_MAX",        /* max pathname length */
  317. #endif
  318. #ifdef    _PC_PIPE_BUF
  319.     _PC_PIPE_BUF,    "_PC_PIPE_BUF",        /* size of a pipe */
  320. #endif
  321. #ifdef    _PC_CHOWN_RESTRICTED
  322.     _PC_CHOWN_RESTRICTED,    "_PC_CHOWN_RESTRICTED",    /* can we give away files */
  323. #endif
  324. #ifdef    _PC_NO_TRUNC
  325.     _PC_NO_TRUNC,    "_PC_NO_TRUNC",        /* trunc or error on >NAME_MAX */
  326. #endif
  327. #ifdef    _PC_VDISABLE
  328.     _PC_VDISABLE,    "_PC_VDISABLE",        /* best char to shut off tty c_cc */
  329. #endif
  330.     0,         NULL,
  331. };
  332.  
  333. int
  334. sys_sysconf(tcp)
  335. struct tcb *tcp;
  336. {
  337.     if (entering(tcp)) {
  338.         printxval(sysconflimits, tcp->u_args[0], "_SC_???");
  339.     }
  340.     return 0;
  341. }
  342.  
  343. int
  344. sys_pathconf(tcp)
  345. struct tcb *tcp;
  346. {
  347.     if (entering(tcp)) {
  348.         (void)printstr(tcp->pid, tcp->u_args[0], -1);
  349.         tprintf(", ");
  350.         printxval(pathconflimits, tcp->u_args[1], "_SC_???");
  351.     }
  352.     return 0;
  353. }
  354.  
  355. int
  356. sys_fpathconf(tcp)
  357. struct tcb *tcp;
  358. {
  359.     if (entering(tcp)) {
  360.         tprintf("%u, ", tcp->u_args[0]);
  361.         printxval(pathconflimits, tcp->u_args[1], "_SC_???");
  362.     }
  363.     return 0;
  364. }
  365.