/** * SmallFS.java - template for a file-system driver for the "small file-system" * * @author Gurtac Yemiscioglu */ public class SmallFS implements FSIF { private DiskScheduler dsched; private byte sblk[]; private int nblocks; public static final int SFS_NTABLES = 16; /** * called to initialise the file-system driver * * @param dsched disk scheduler used to interface with the underlying device * * @return 0 on success, non-zero on failure */ public int initFS (DiskScheduler dsched) { int i; int itotal, iused; int imagic; this.dsched = dsched; sblk = dsched.readBlock (0); if (sblk == null) { System.err.println ("failed to read superblock!"); return -1; } nblocks = (int)BM.read_uint32 (sblk, 12); imagic = (int)BM.read_uint32 (sblk, 0); if (imagic != 0xefbeadde) { System.err.println ("bad file-system magic! expected [deadbeef], found [" + BM.tohexbuf (sblk, 0, 4) + "]"); return -1; } System.out.println ("File-system magic : " + BM.tohexbuf (sblk, 0, 4)); System.out.println ("File-system version : " + BM.read_uint16 (sblk, 4) + "." + BM.read_uint16 (sblk, 6)); System.out.println ("Superblock age : " + BM.read_uint32 (sblk, 8)); System.out.println ("Total blocks : " + nblocks); System.out.println ("Block bitmap at : " + BM.read_uint32 (sblk, 16)); System.out.print ("Inode tables at : "); for (i=0; i