Sectors (ex:512 bytes) - assumed to be linear array with the "locality of reference" property
Blocks (ex: 8192bytes) - same assumption as block
Partitions - a block of disk that holds a file system(all meta-data and data). A single disk can hold multiple file systems (This can be taken to an extreme - we can create a big file in our file system and treat it as a partition! Then we can put a file system in it!)
inodes - in UNIX a "file" is equivalent to "inode+associated data"
File Name Components (ex: /usr/bin/sh) - each directory entry is a component of the file name
File Names - the combination of all file name components gives the actual file name
Symbolic Links - files whose contents is a file name
cp /usr/bin/sh /home/eggert/junk/sh
int ifd = open("/usr/bin/sh", O_RDONLY);
int ofd = open("/home/eggert/junk/sh", O_WRONLY, O_CRCAT, 0066);
A: Floppy, B: Floppy, C: Hard Drive
General Rule: ignore slashes in file name. The only exception here would be where there are two leading slashes, for example: //abc /det.
Rule: if it starts with a slash(/), file name interrupted relative to root directory. Otherwise, start with working directory (inode# -> which is a process table entry
chdir system call - changes the working directory by changing the inode# of the current process.
Example: chdir ("/bin")
chdir.c:
int main(int argvc, char* argv){
if(argc != 2) error;
if(chdir(argv[1] != 0)){
perror(argv[1]);
return 1;
}
return 0;
}
/*Runs, But ineffective, since it does
*not change shell's working directory
*and instead it changes the process's working
*directory and then exits. The shell thus returns to old working directory */
chroot
----> deprecated, because cannot access files above it
----> Eg: chroot("/home/eggert/junk/") execvp("/usr/bin/sh") /* Will fail*/
----> Security Problem: create/home/eggert/junk/etc/pass create /home/eggert/junk/etc/shadow. --> here we can create new password and use it to become root. this is not safe.
----> Because of the security issue, we make it a privileged function call.
----> This is used t create chrooted jails, which is the next section.
fork()
chroot("/a/b")
set vid("apache")
execvp("/usr/bin/apache")
Trying to get out of chrooted jail
(/..) <--- Special case if in root
User just sees the file names
Mount Table:
----> Cannot allow inodes to point to other file systems
----> This is because it forces all file systems to be mounted together
----> inode #s are local to a file system they are in
----> they uniquely identify a file we need
Linux directories are small, and a concatenation of the above shown structure
If they are large, they can be implemented using a hash table
Hard Links: when two different directory entries point to the same file
ln /etc/passed
/home/eggert/junk/pass
Files do not have a name, they have an inode#
Goes to each parent and prints it out
----> mv home/eggert /home/eggert/junk/j --> not allowed since it will create a directory loop
Efficiency Issue: 3 lseeks, 3 writes
Correctness Issue