Subject: RFC: new mode bits in stat structure
To: None <tech-kern@NetBSD.ORG>
From: Jason Thorpe <>
List: tech-kern
Date: 06/25/1998 23:36:05
Hi folks...

For the HSM we're building on NetBSD/alpha, I need a couple of additional
mode bits to indicate two separate additional file states:

	- File has been archived

	- File is not resident on disk

I'll also be making some changes to various system utilities, like ls(1)
(to display these extra status bits in ls -l) and find(1) (e.g. "find all
non-resident files").

Another option is to have a separate structure for this, returned by a
separate call, but that is bad for us in several ways (not the least of
which is the extra, needless system call overhead to get the additional
information; this is a big deal, since we have file systems which have
LARGE numbers of files in a single directory, for example).

The following diff adds those two additional bits in the top 16 bits
of the mode_t.  These bits are currently otherwise unused.  If a program
uses the old stat interface, it will obviously not get these bits, but
this isn't really a practical problem, since those programs wouldn't know
what to do with them anyhow :-)

I'd like to add these new bits and the changes to the system utilities that
would care about them to the master NetBSD sources (not only does this save
hair for us, but we are hoping to fold all of the HSM code back into NetBSD
at some point).  Are there any objections to this?

Jason R. Thorpe                             
NASA Ames Research Center                            Home: +1 408 866 1912
NAS: M/S 258-5                                       Work: +1 650 604 0935
Moffett Field, CA 94035                             Pager: +1 650 428 6939

Index: stat.h
RCS file: /cvsroot/src/sys/sys/stat.h,v
retrieving revision 1.35
diff -c -r1.35 stat.h
*** stat.h	1998/05/05 21:25:05	1.35
--- stat.h	1998/06/26 06:38:52
*** 205,210 ****
--- 205,224 ----
  #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
+ /*
+  * These live in the upper 16 bits of a mode_t, and are thus not
+  * visible in the old stat structures, which only have 16 bits
+  * for mode.  This is not a practical problem, since these bits
+  * are used by hierarchical storage mangement systems, which should
+  * all be new code, anyhow.
+  */
+ #define	S_IFARCHIVED	0200000		/* file is archived */
+ #define	S_IFNONRES	0400000		/* file is non-resident */
+ #define	S_ISARCHIVED(m)	((m) & S_IFARCHIVED)
+ #define	S_ISNONRES(m)	((m) & S_IFNONRES)
+ #endif
+ #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
  #define	ACCESSPERMS	(S_IRWXU|S_IRWXG|S_IRWXO)	/* 0777 */
  							/* 7777 */