gwyn%brl-vld@sri-unix.UUCP (02/22/84)
From: Doug Gwyn (VLD/VMB) <gwyn@brl-vld> ustat(2) is in UNIX System III and V, as documented in the manual. You pass it a pointer to a buffer to receive the information, which includes total free blocks, free inodes, file system name, and pack name. There is also an argument to specify the device, of course. The information is stored in the file system super-block. It should be obvious how "df" works from the above description. In the absence of this information, one has to scan the disk and tally up the free space. This is not only slow and tedious, it also requires read access to the raw device (i.e. super-user permission).
jab@uokvax.UUCP (03/01/84)
#R:forcm5:-12800:uokvax:6100021:000:2703 uokvax!jab Feb 21 18:49:00 1984 /***** uokvax:net.unix / forcm5!jr / 3:47 am Feb 18, 1984 */ 1) What happened to ustat? 2) What are/were it's arguments? I assume it returned a long, for the number of bytes (where -1 might mean an error of some sort). 3) How can someone do the same thing without using the ustat system call? 4) How does df(1) work? -- JR (John Rogers) UUCP: forcm5!jr, fortune!jr, proper!jr CompuServe: 70140,213 /* ---------- */ I can answer a little of that. If I had the "PWB/Unix" manual, I could answer a whole lot more! i) "ustat" was a system call that you gave a special device name and a structure to be filled in. It looked up that device in the in-core mount table and copied specific items out. As I remember, the old RJE used it a lot. (I seem to remember our local wizard, one of only of few I've ever met, bumping into this when he put RJE on our top of a V6 system.) ii) I just looked through the System III kernel, and it's there. It's under the name "utssys", although there is a C library interface: #include <sys/types.h> #include <ustat.h> int ustat(dev, buf) int dev; /* major/minor of special device */ struct ustat *buf; The "struct ustat" contains the volume name and pack name and the number of free inodes/blocks. iii) It's on system V, also --- I stole the above C statements from a system V manual. iv) I assume that you could do the same thing FOR AN UNMOUNTED FILESYSTEM by opening that device and copying out the information from the superblock --- it's all there. For a mounted filesystem, you need to be able to get to the in-core superblock, and that's more trouble than it's worth. (Well, I suppose you could just "sync()" before getting it off the special device, but...) v) Different versions of "df" do different things. The Berkeley 2.8 "df", if I remember, went out to the disk and counted the number of free blocks! (Most of the older "df" commands do this.) On a lot of systems that don't have "ustat", you just grab the info you want out of the superblock. Peter Staubach here at OU hacked the "ustat" system call into his 2.8 pdp-11 system, and "df" does a "ustat" first, and if that fails, THEN it gets the info off the superblock. To put it mildly, it runs pretty quickly. I think I messed up the numbering scheme. Oh, well. The "ustat" system call, along with several other PWB notions, was never bought back by the people that gave us Version 7 and Unix/32V. (Version 7 begat 2.8bsd, and Unix/32V begat 3bsd and 4.Xbsd.) This explains why it wasn't in any of those versions --- the system III and system V are direct decendents of PWB, so those notions are in system {III,V}. Jeff Bowles Lisle, IL
chris@umcp-cs.UUCP (03/02/84)
Under 4.1 "df" works by reading the superblock off the disk. 4.1 maintains a "tfree" value in the superblock which holds the amount of free space. df also has a "-l" option to go count up the free list (it's printed out under a column marked "hardway" -- pretty appropriate). The -l option is occasionally useful if you suspect your superblock is munged. For the adventurous, you can experiment with different disk-inode- table sizes based on the output of "df -i". -- In-Real-Life: Chris Torek, Univ of MD Comp Sci UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris.umcp-cs@CSNet-Relay
jr@forcm5.UUCP (John Rogers) (03/06/84)
Hello. I was reading "The Programmer's Workbench" (an article in the 1978 special UNIX issue of the Bell Systems Technical Journal), and I noticed the following sentence: "The ustat system call was added to allow programs to discover the amount of free space remaining in a file system." Since I haven't seen ustat in the V7, Sys III, or 4.1BSD documentation, I'd like to know: 1) What happened to ustat? 2) What are/were it's arguments? I assume it returned a long, for the number of bytes (where -1 might mean an error of some sort). 3) How can someone do the same thing without using the ustat system call? 4) How does df(1) work? Thanks in advance... Chief question asker -- JR (John Rogers) UUCP: forcm5!jr, fortune!jr, proper!jr CompuServe: 70140,213
phil@amd70.UUCP (Phil Ngai) (03/16/84)
The man page for filesys(5) under V7 says the total free blocks field of the superblock is "not maintained by this version of the system." That's probably why 2.8 bsd df has to count the number of free blocks. -- Phil Ngai (408) 988-7777 {ucbvax,decwrl,ihnp4,allegra,intelca}!amd70!phil
fair@dual.UUCP (Erik E. Fair) (03/19/84)
Actually, the total free blocks and total free inodes were kept track of in 2.8BSD, so the df program sync'd and read the super blocks of the mounted filesystems. There is an option (-l) for forcing it to read the free list, just like the v7 df program. The comment in /usr/include/sys/filsys.h was left in inadvertently. Erik E. Fair dual!fair@Berkeley.ARPA {ihnp4,ucbvax,cbosgd,decwrl,amd70,fortune,zehntel}!dual!fair Dual Systems Corporation, Berkeley, California
ignatz@ihuxx.UUCP (Dave Ihnat, Chicago, IL) (03/30/84)
Hello. I was reading "The Programmer's Workbench" (an article in the 1978 special UNIX issue of the Bell Systems Technical Journal), and I noticed the following sentence: "The ustat system call was added to allow programs to discover the amount of free space remaining in a file system." Since I haven't seen ustat in the V7, Sys III, or 4.1BSD documentation, I'd like to know: 1) What happened to ustat? 2) What are/were it's arguments? I assume it returned a long, for the number of bytes (where -1 might mean an error of some sort). 3) How can someone do the same thing without using the ustat system call? 4) How does df(1) work? Thanks in advance... Chief question asker -- JR (John Rogers) UUCP: forcm5!jr, fortune!jr, proper!jr CompuServe: 70140,213 Excuse me, John...but I just looked at Sys III, V, and V.2 documentation. All clearly list info on the ustat(2) call. Interface is: #include <sys/types.h> #include <ustat.h> int ustat(dev,buf) int dev; struct ustat *buf; It returns total free blocks, number of free inodes, the filsys name, and the filsys pack name. (All of this is USG. Dammfino what it looks like for BSD.) And this is how df(1) does it. Dave Ihnat ihuxx!ignatz