* iinit is called once (from main)
* very early in initialization.
* It reads the root's super block
* and initializes the current date
* from the last modified date.
* panic: iinit -- cannot read the super
* block. Usually because of an IO error.
(*bdevsw
[rootdev
.d_major
].d_open
)(rootdev
, 1);
bcopy(bp
->b_addr
, cp
->b_addr
, 256);
mount
[0].m_dev
= rootdev
;
* alloc will obtain the next available
* free disk block from the free list of
* The super block has up to 100 remembered
* free blocks; the last of these is read to
* no space on dev x/y -- when
* the free list is exhausted.
sleep(&fp
->s_flock
, PINOD
);
bno
= fp
->s_free
[--fp
->s_nfree
];
} while (badblock(fp
, bno
, dev
));
bcopy(ip
, fp
->s_free
, 100);
* place the specified disk block
* back on the free list of the
sleep(&fp
->s_flock
, PINOD
);
if (badblock(fp
, bno
, dev
))
bcopy(fp
->s_free
, ip
, 100);
fp
->s_free
[fp
->s_nfree
++] = bno
;
* Check that a block number is in the
* range between the I list and the size
* This is used mainly to check that a
* garbage file system has not been mounted.
* bad block on dev x/y -- not in range
register struct filsys
*fp
;
if (bn
< fp
->s_isize
+2 || bn
>= fp
->s_fsize
) {
* Allocate an unused I node
* on the specified device.
* Used with file creation.
* The algorithm keeps up to
* 100 spare I nodes in the
* super block. When this runs out,
* a linear search through the
* I list is instituted to pick
sleep(&fp
->s_ilock
, PINOD
);
ino
= fp
->s_inode
[--fp
->s_ninode
];
for(bp
= &ip
->i_mode
; bp
< &ip
->i_addr
[8];)
* Inode was allocated after all.
for(i
=0; i
<fp
->s_isize
; i
++) {
if(dev
==inode
[k
].i_dev
&& ino
==inode
[k
].i_number
)
fp
->s_inode
[fp
->s_ninode
++] = ino
;
prdev("Out of inodes", dev
);
* Free the specified I node
* on the specified device.
* The algorithm stores up
* to 100 I nodes in the super
* block and throws away any more.
fp
->s_inode
[fp
->s_ninode
++] = ino
;
* getfs maps a device number into
* a pointer to the incore super
* The algorithm is a linear
* search through the mount table.
* A consistency check of the
* in core free-block and i-node
* bad count on dev x/y -- the count
* check failed. At this point, all
* the counts are zeroed which will
* almost certainly lead to "no space"
* panic: no fs -- the device is not mounted.
register struct mount
*p
;
for(p
= &mount
[0]; p
< &mount
[NMOUNT
]; p
++)
if(p
->m_bufp
!= NULL
&& p
->m_dev
== dev
) {
if(n1
> 100 || n2
> 100) {
* update is the internal name of
* 'sync'. It goes through the disk
* queues to initiate sandbagged IO;
* goes through the I nodes to write
* modified nodes; and it goes through
* the mount table to initiate modified
register struct inode
*ip
;
register struct mount
*mp
;
for(mp
= &mount
[0]; mp
< &mount
[NMOUNT
]; mp
++)
if(ip
->s_fmod
==0 || ip
->s_ilock
!=0 ||
ip
->s_flock
!=0 || ip
->s_ronly
!=0)
bp
= getblk(mp
->m_dev
, 1);
bcopy(ip
, bp
->b_addr
, 256);
for(ip
= &inode
[0]; ip
< &inode
[NINODE
]; ip
++)
if((ip
->i_flag
&ILOCK
) == 0) {