Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP
id AA6757 ; Tue, 12 Jan 93 19:04:06 EST
Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!uwm.edu!cs.utexas.edu!sun-barr!ames!agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: UFS on disk inode "spare" fields bad [and patch]
Message-ID: <1993Jan15.062302.15669@fcom.cc.utah.edu>
Keywords: UFS di_spare extensions
Sender: news@fcom.cc.utah.edu
Reply-To: terry@icarus.weber.edu
Organization: Weber State University (Ogden, UT)
Date: Fri, 15 Jan 93 06:23:02 GMT
Lines: 136
There was a recent disclosure of someones work on providing access control
lists directly within the file system... unfortunately it won't "just
install" without destroying backward compatability because the "spare"
fields of the on-disk inode aren't normally initialized to anything --
they contain absolutely random values in the default file system.
I noticed this problem while I was extending UFS to support the concept
of international locale within the file system (for localization to
other national languages -- my personal interest being Japanese, Russian,
and Greek locales).
The following is a patch to UFS to insure that the unused spare values
are initialized to 0 when not in use. The number of spare values present
is counted as long words and is defined in dinode.h as SZ_DI_SPARE. This
is so that future partial use of these fields will not prevent the still
unused "spare" fields from being correctly initialized.
I also changed the "spare" values from long to unsigned long at the same
time (to avoid potential sign extension problems when storing values
directly into these fields, like "last archived date" when these fields
are used without being labelled by a change to dinode.h).
These patches only help for extensions made to file systems created *after*
they are installed (sorry). What this means is that you can either write
a program to "blow" th spare fields to (unsigned long)0L after installing
this patch, and traverse the entire file system, or you can put a kernel
containing the patches on a dist.fs disk and install a system.
Here are the patches to UFS taken by diff -c <oldfile> <newfile> from
within the /sys/ufs directory:
--------------------------------------------------------------------------
*** dinode.h.org Mon Jan 11 22:19:34 1993
--- dinode.h.spare Fri Jan 15 00:00:07 1993
***************
*** 31,36 ****
--- 31,38 ----
* SUCH DAMAGE.
*
* @(#)dinode.h 7.10 (Berkeley) 5/8/91
+ *
+ * 13 Jan 93 Terry Lambert Fix "spare" fields of on disk inode
*/
/*
***************
*** 58,64 ****
long di_flags; /* 100: status, currently unused */
long di_blocks; /* 104: blocks actually held */
long di_gen; /* 108: generation number */
! long di_spare[4]; /* 112: reserved, currently unused */
};
#if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */
--- 60,67 ----
long di_flags; /* 100: status, currently unused */
long di_blocks; /* 104: blocks actually held */
long di_gen; /* 108: generation number */
! #define DI_SPARE_SZ 4 /* 112: spare for 4 longs*/
! u_long di_spare[ DI_SPARE_SZ]; /* reserved (unused) */
};
#if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */
*** inode.h.org Mon Jan 11 22:23:32 1993
--- inode.h.spare Thu Jan 14 23:56:46 1993
***************
*** 31,36 ****
--- 31,38 ----
* SUCH DAMAGE.
*
* @(#)inode.h 7.17 (Berkeley) 5/8/91
+ *
+ * 13 Jan 93 Terry Lambert Fix "spare" fields of on disk inode
*/
#ifdef KERNEL
***************
*** 87,92 ****
--- 89,95 ----
#define i_gen i_din.di_gen
#define i_forw i_chain[0]
#define i_back i_chain[1]
+ #define i_di_spare i_din.di_spare /* TRL: fix "spare"*/
/* flags */
#define ILOCKED 0x0001 /* inode is locked */
*** ufs_inode.c.org Thu Jan 14 23:29:31 1993
--- ufs_inode.c.spare Fri Jan 15 00:01:00 1993
***************
*** 31,36 ****
--- 31,38 ----
* SUCH DAMAGE.
*
* @(#)ufs_inode.c 7.40 (Berkeley) 5/8/91
+ *
+ * 13 Jan 93 Terry Lambert Fix "spare" fields of on disk inode
*/
#include "param.h"
***************
*** 140,145 ****
--- 142,160 ----
for (i = 0; i < MAXQUOTAS; i++)
ip->i_dquot[i] = NODQUOT;
#endif
+
+ /*
+ * 14 Jan 93 Terry Lambert Fix "spare"
+ *
+ * Because the "spare" field of the on disk inode was not set to
+ * a known value by default, it was unusable for an extension to
+ * UFS intended to be backward compatable with an existing UFS.
+ * With a known value in this field, it's possible to start using
+ * an extension on an existing disk without rebuilding it.
+ */
+ for (i=0; i < SZ_DI_SPARE; i++) {
+ ip->i_di_spare[ i] = (unsigned long)0L; /* "well known"*/
+
/*
* Put it onto its hash chain and lock it so that other requests for
* this inode will block if they arrive while we are sleeping waiting
--------------------------------------------------------------------------
Terry Lambert
terry@icarus.weber.edu
terry_lambert@novell.com
---
Any opinions in this posting are my own and not those of my present
or previous employers.
--
-------------------------------------------------------------------------------
"I have an 8 user poetic license" - me
Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
-------------------------------------------------------------------------------