home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / solaris / 215 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  3.6 KB

  1. Xref: sparky comp.unix.solaris:215 comp.sys.sun.misc:4235 comp.unix.programmer:4670
  2. Newsgroups: comp.unix.solaris,comp.sys.sun.misc,comp.unix.programmer
  3. Path: sparky!uunet!decwrl!netcomsv!attain!icd.teradyne.com!difrel!dcp
  4. From: dcp@icd.teradyne.com (Dan Proskauer)
  5. Subject: swapctl() problems
  6. Message-ID: <1992Sep15.215809.20252@icd.teradyne.com>
  7. Keywords: swap swapctl
  8. Sender: news@icd.teradyne.com (News admin)
  9. Reply-To: dcp@icd.teradyne.com
  10. Organization: Teradyne, Inc. Boston MA
  11. Date: Tue, 15 Sep 1992 21:58:09 GMT
  12. Lines: 76
  13.  
  14. Hi -
  15.  
  16.     I have recently discovered the library function swapctl() which is available
  17. in Solaris 2.0.  Unfortunately I seem to be unable to get it to work properly.  The
  18. combination of the man page and /usr/include/sys/swap.h are very confusing.
  19. Can anyone construct a program using this function which calculates the total
  20. number of pages allocated to swap and the total free?
  21.  
  22.     The specific problem is that function seems to want you to define a struct
  23. which has as one of its members an array of structs.  However, the struct declaration
  24. in /usr/include/swap.h declares that array to be of length 1.  This causes no end of
  25. problems which I can't seem to get around.  By defining my own types and tricking
  26. it into believing all kinds of unlikely things I got it to compile and execute
  27. without returning -1.  Unfortunately it does not set the correct values in the
  28. array.  :-(
  29.  
  30.     It does however, function perfectly if you request information on only one
  31. swap entry.
  32.  
  33.     Any help will be greatly appreciated.
  34.     
  35.         - Dan Proskauer
  36.     
  37.  
  38. the man page specifies this:
  39.  
  40.      int swapctl(int cmd, void *arg);
  41.  
  42. DESCRIPTION
  43.      swapctl() adds, deletes, or returns information  about  swap
  44.      resources.   cmd specifies one of the following options con-
  45.      tained in <sys/swap.h>:
  46.  
  47.            SC_ADD                      /* add a resource for swapping */
  48.            SC_LIST                     /* list the resources for swapping */
  49.            SC_REMOVE                   /* remove a resource for swapping */
  50.            SC_GETNSWP                  /* return number of swap resources */
  51.  
  52.      When SC_LIST is specified, arg is a pointer to  a  swaptable
  53.      structure containing the following members:
  54.  
  55.            int     swt_n;              /* number of swapents following */
  56.            struct  swapent swt_ent[];  /* array of swt_n swapents */
  57.  
  58.      A swapent structure contains the following members:
  59.  
  60.            char    *ste_path;          /* name of the swap file */
  61.            off_t   ste_start;          /* starting block for swapping */
  62.            off_t   ste_length;         /* length of swap area */
  63.            long    ste_pages;          /* number of pages for swapping */
  64.            long    ste_free;           /* number of ste_pages free */
  65.            long    ste_flags;          /* ST_INDEL bit set if swap file */
  66.                                        /* is now being deleted */
  67.  
  68.      SC_LIST causes swapctl() to return at  most  swt_n  entries.
  69.      The  return  value  of  swapctl()  is  the  number  actually
  70.      returned.
  71.      
  72. /usr/include/swap.h specifies:
  73.  
  74. typedef struct  swaptable {
  75.     int swt_n;          /* number of swapents following */
  76.     struct  swapent swt_ent[1]; /* array of swt_n swapents */
  77. } swaptbl_t;
  78.  
  79.  
  80.  
  81.  
  82. ---
  83. ---------------------------------------------------------------
  84. | Dan Proskauer -- MS: H71 | Internet:  dcp@icd.teradyne.com  |
  85. | Teradyne Inc.            |                                  |
  86. | 321 Harrison Ave.        | Voice:     (617) 422-2641        |
  87. | Boston, Ma. 02118        | Fax:       (617) 422-2837        |
  88. ---------------------------------------------------------------
  89.  
  90.