-
Notifications
You must be signed in to change notification settings - Fork 2
Overview
anuragpeshne edited this page Apr 14, 2013
·
10 revisions
- System creates a folder TransDisk in home directory of user logged in host machine which acts as Disk for TransOS.
- TransDisk folder contains several plain text files representing disk blocks.
- Each file acting as disk block has upper limit on file size since data blocks have fixed capacity. In case of TransOS this limit is 500 Bytes.
-
Diskrepresent virtual Disk of TransOS. - It has various static variables which control behavior of TransOS such size of virtual Disk, number of Inodes, maximum virtual block size and location of virtual Disk.
- It prepares virtual disk on first time run creating virtual
Blocks,InodesinitializingFreeSpaceManagmentand creating defaultUser. -
bootup()which loads necessary files from physical disk to memory. -
shutDown(): Flushes dirty caches and cleans temporary files. - Super Block Structure:
[Line 1] 2000 number of blocks in file system [Line 2] 5678 freeBlogBitmap1_freeBlogBitmap2_freeBlogBitmap3_freeBlogBitmap4 [Line 3] 9 free inodes bitmap
- Represents virtual Inode of TransOS system.
- Inode Structure:
Inode Number 000 Signature 1 // 1 |0 inactive, 1 Inode, 2 single indirect data block, Block Count 00 File Type d Group Id 000 HardLink Count 00 RefCount 00 UserId 000 AccessedTime 2013-02-25 19:54:17 CreateTime 2013-02-25 19:54:17 ModifyTime 2013-02-25 19:54:17 permission 777 BlockPointer[0] 00000 BlockPointer[1] 00000 BlockPointer[2] 00000 BlockPointer[3] 00000 BlockPointer[4] 00000 //Indirect Block Pointer
- Note that last Block pointer points to another block containing pointers to data block. Thus it acts as indirect pointer block.
- Present version may not use all the fields of Inode.
- It manages free blocks and Inodes in the system.
- Implemented as bitmap with each bit showing whether disk Block/Inode is used or free.
- Important methods include
getBlock()&consumeBlock(blockNumber)for managing Disk Blocks andgetInode()&consumeInode(inodeNum). - Console on right side of UI can be use to monitor free space in Real Time.
- Requires
bootUp()andshutDown()since it requires saving bitmap to disk and retrieving on startup.
- It represents virtual directory on TransOS system.
- Kept in memory as
HashMapwith inode number as key and Directory Entry as value. - Stored on disk as:
d 123 folder1 //d: directory d 324 folder2 r 411 newFile //r: regular file(text file)
-
All the file/folder operations are defined as parent directory methods.
-
targetDir.copy(sourceInode, sourceDirInode)- this method recursively copies data of file denoted by sourceInode from its parent Directory denoted by sourceDirInode to targetDir object on which this method is called on.
-
throwsPermissionDeniedException if sourceInode not readable or target directory not writable.
-
targetDir.delete(victimInode)- Deletes file/folder from directory denoted by targetDir.
- If target is folder then recursively deletes all files and folder under folder denoted by victimInode.
-
throwsPermissionDeniedException if victimInode is not writable or targetDirectory is not writable.
-
targetDir.move(sourceInode, sourceDirInode)- this method copies using
targetDir.copy(sourceInode, sourceDirInode)and then deletes file denoted by sourceInode usingtargetDir.delete(targetInode). -
throwsPermissionDeniedException if sourceInode is not readable or targetDirectory or sourceDirectory is not writable.
- this method copies using
-
targetDir.editFile(targetInodeNum)- Assembles file data from virtual blocks into a single file in temporary area and calls upon
Desktop.getDesktop().open(tempFile); - Further actions depending upon whether file was edited and need to written back is decided by DiskWatcher service.
-
throwsPermissionDeniedException if sourceInode is not readable;
- Assembles file data from virtual blocks into a single file in temporary area and calls upon
-
targetDir.makeDir(name)andtargetDir.makeFile(name, content)- Creates new file/directory inside target directory.
-
throwsPermissionDeniedException if target directory is not writable;
-
targetDir.rename(targetIndoeNum, newName)- Renames File/Directory denoted by targetInodeNum.
-
throwsPermissionDeniedException if target directory is not writable;
-
-
Changing File Permission and Owner:
targetDir.chmod(targetInode, permission)targetDir.chown(targetInode, newUsername)
-
Hard Link:
targetDir.makeHardLink(path):void
-
Soft Link:
targetDir.makeSoftLink(path):Inode
- Wrapper for value field in
HashMapto accommodate name and type, thus giving additional metadata during listing of directory.
- Disk Watcher is background thread which monitors temporary folder for changes.
- It is implemented using a new feature introduced in Java 7 called as WatchService.
- Working:
- The basic idea behind using such service is to use native text-editor of host system to edit TransOS files. Whenever a file is opened, TransOS assembles all data blocks and create a temporary file in temporary space and uses
Desktop.getDesktop().open(tempFile)which triggers host OS to open this temporary file using it's default text editor. -
DiskWatcherwatches temporary space for changes and triggers file edit when it detects file is edited. This file is then again broken into data blocks of max block size and written to virtual disk.
- The basic idea behind using such service is to use native text-editor of host system to edit TransOS files. Whenever a file is opened, TransOS assembles all data blocks and create a temporary file in temporary space and uses
- Platform Dependencies:
- WatcheService uses native file event notification facility where available and falls back to primitive mechanism, such as polling, when a native facility is not available.
- Since it is dependent of native event notification we get different event notification on different OS.
- For Example when a file is edited:
- We get
ENTRY_MODIFYon Windows 7 - On Ubuntu 12.10 we get series of
ENTRY_CREATEDandENTRY_DELETEnotification on host system temporary files.
- We get
- User fields:
- Username
- Hash(Password)
- Group Name
- User Id
- Group Id
- Home Directory Inode Number
- Only one User can be loggedin the system at a time.
- New users can be added before logging in the system.
- Default User root with password root123 is created while installing the system.
- Users are stored in plain text files in system as
UserName PswdHash UserId GroupId HomeDirInode root ff9830c42660c1dd1942844f8069b74a 1 1 3
- User Id and Group Id are generated automatically by the system and are used for internal purpose only.
- Groups are stored in file. Its structure:
1 none 2 cs