mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:54:05 -06:00
vault backup: 2022-09-05 11:22:31
This commit is contained in:
parent
9910ab9e69
commit
b6a6db0530
@ -6,7 +6,7 @@ tags:
|
||||
- lecture
|
||||
---
|
||||
|
||||
# what is a file
|
||||
# what is a file (LINUX)
|
||||
an interface of OS to users
|
||||
|
||||
os manages files just as files - it doesn't care what type of file it is - they are all bytes arranges logically in sequence.
|
||||
@ -21,8 +21,47 @@ files need to be interpreted. THis is done by applications. e.g., powerpoint, ms
|
||||
- the operating system maps files onto regions of the storage
|
||||
- files are really an artifact of the dialogue between the user and the OS
|
||||
|
||||
# how to define it
|
||||
- a colle
|
||||
## how to define it
|
||||
- a collection of related data
|
||||
- e.g., the set of lines in a program
|
||||
|
||||
structure:
|
||||
- a byte stream or a sequence of bytes, text file is a stream of ascii characgers
|
||||
|
||||
what can the user do
|
||||
- create, write, read, reposition, delete, truncate (through system calls)
|
||||
|
||||
## attributes
|
||||
- name
|
||||
- owner
|
||||
- Uid and Gid
|
||||
- file type
|
||||
- location of data
|
||||
- size of data
|
||||
- permission
|
||||
- "housekeeping" information
|
||||
- time and created modified etc
|
||||
- and more
|
||||
|
||||
## where is the data stored
|
||||
- in an index node (inode) pointed by an entry of a directory. (you can think of a directory as just a set of <name, inode> entries. )
|
||||
|
||||
internal fragmentation
|
||||
- dont know exactly how many bytes to allocate to a file
|
||||
- extra space is lost
|
||||
|
||||
external fragmentaion TODO
|
||||
|
||||
these issues have been solved using block allocaiton instead of continuous allocation
|
||||
|
||||
## system calls for file systems
|
||||
- open close, read, write, ioctl, etc
|
||||
|
||||
`ssize_t write(int fd, const, void *buf, size_t count)`
|
||||
- fd - file descriptor
|
||||
- write up to count butes from the buffer pointed buf to the file referred to by the file descriptor
|
||||
- returns -1 if error. and errno is set
|
||||
- should return number of bytes written if ok
|
||||
|
||||
# file access pattersns
|
||||
# directory structure
|
||||
|
||||
Loading…
Reference in New Issue
Block a user