home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.solaris:215 comp.sys.sun.misc:4235 comp.unix.programmer:4670
- Newsgroups: comp.unix.solaris,comp.sys.sun.misc,comp.unix.programmer
- Path: sparky!uunet!decwrl!netcomsv!attain!icd.teradyne.com!difrel!dcp
- From: dcp@icd.teradyne.com (Dan Proskauer)
- Subject: swapctl() problems
- Message-ID: <1992Sep15.215809.20252@icd.teradyne.com>
- Keywords: swap swapctl
- Sender: news@icd.teradyne.com (News admin)
- Reply-To: dcp@icd.teradyne.com
- Organization: Teradyne, Inc. Boston MA
- Date: Tue, 15 Sep 1992 21:58:09 GMT
- Lines: 76
-
- Hi -
-
- I have recently discovered the library function swapctl() which is available
- in Solaris 2.0. Unfortunately I seem to be unable to get it to work properly. The
- combination of the man page and /usr/include/sys/swap.h are very confusing.
- Can anyone construct a program using this function which calculates the total
- number of pages allocated to swap and the total free?
-
- The specific problem is that function seems to want you to define a struct
- which has as one of its members an array of structs. However, the struct declaration
- in /usr/include/swap.h declares that array to be of length 1. This causes no end of
- problems which I can't seem to get around. By defining my own types and tricking
- it into believing all kinds of unlikely things I got it to compile and execute
- without returning -1. Unfortunately it does not set the correct values in the
- array. :-(
-
- It does however, function perfectly if you request information on only one
- swap entry.
-
- Any help will be greatly appreciated.
-
- - Dan Proskauer
-
-
- the man page specifies this:
-
- int swapctl(int cmd, void *arg);
-
- DESCRIPTION
- swapctl() adds, deletes, or returns information about swap
- resources. cmd specifies one of the following options con-
- tained in <sys/swap.h>:
-
- SC_ADD /* add a resource for swapping */
- SC_LIST /* list the resources for swapping */
- SC_REMOVE /* remove a resource for swapping */
- SC_GETNSWP /* return number of swap resources */
-
- When SC_LIST is specified, arg is a pointer to a swaptable
- structure containing the following members:
-
- int swt_n; /* number of swapents following */
- struct swapent swt_ent[]; /* array of swt_n swapents */
-
- A swapent structure contains the following members:
-
- char *ste_path; /* name of the swap file */
- off_t ste_start; /* starting block for swapping */
- off_t ste_length; /* length of swap area */
- long ste_pages; /* number of pages for swapping */
- long ste_free; /* number of ste_pages free */
- long ste_flags; /* ST_INDEL bit set if swap file */
- /* is now being deleted */
-
- SC_LIST causes swapctl() to return at most swt_n entries.
- The return value of swapctl() is the number actually
- returned.
-
- /usr/include/swap.h specifies:
-
- typedef struct swaptable {
- int swt_n; /* number of swapents following */
- struct swapent swt_ent[1]; /* array of swt_n swapents */
- } swaptbl_t;
-
-
-
-
- ---
- ---------------------------------------------------------------
- | Dan Proskauer -- MS: H71 | Internet: dcp@icd.teradyne.com |
- | Teradyne Inc. | |
- | 321 Harrison Ave. | Voice: (617) 422-2641 |
- | Boston, Ma. 02118 | Fax: (617) 422-2837 |
- ---------------------------------------------------------------
-
-