其他分享
首页 > 其他分享> > 20191324第七、八章读书笔记

20191324第七、八章读书笔记

作者:互联网

第七章 文件操作

文件操作级别

fdisk:将硬盘、U盘或SDC盘分区
mkfs:格式化磁盘分区,为系统做好准备
fsck: 检查和维修系统
碎片整理:压缩文件系统中的文件

kmount(),kumount ( ) (mount/umount file systems)
kmkdir(), krmdir() (make/ remove directory )
kchdir() , kgetewa () (change directory, get CWD pathname)
klink() ,kunlink( ) (hard link/unlink files)
kchmod(),kchown(),kutime( ) (change r| W |X permissions,owner, time)
kcreat(),kopen() (create/open file for R, W, RW, APPEND)
kread() ,kwrite( ) (read/write opened files)
klseek() ; kclose() (lseek/c1ose file descriptors)
ksymlink(), kreadlink() (create/read symbolic link files)
kstat() ,kfstat(), k1stat() (get file status/ information)
kopendir(), kreaddir() (open/read directories)

FILE mode I/O: fopen(),fread(); fwrite(), fseek(), fclose(),fflush()char mode I/o: getc(), getchar() ugetc(); putc(),putchaz()
line mode I/O: gets(), fgets();puts(), fputs()
formatted I/o: scanf(), fscanf(),sscanf(); printf(), fprintf(), sprintf()

文件I/O操作

点击查看代码
get abuffer = (dev,b1k) ;. if(buffer's data are
invalid) 
{
start_ io on buffer;
wait for I/O completion;
}
. copy datafrom buffer to fbuf ;
.release buffer to buffer cache ;
点击查看代码
.get a buffer =(dev, b1k) ;
 write data to the I/O buffer ;
. mark buffer as dataValid and DIRTY(for delay-write to disk);
. release the buffer to buffer cache ;

低级别文件操作

struct partition {
u8 drive; // 0x80 - active
u8 head; // starting head
u8 sector; // starting sector
u8 cylinder; // starting cylinder
u8 sys_type; // partition type
u8 end_head; // end head
u8 end_sector; // end sector
u8 end_cylinder; // end cylinder
u32 start_sector; // starting sector counting from 0
u32 nr_sectors; // number of sectors in partition
};

超级块

struct ext2_super_block {
u32 s_inodes_count; // Inodes count
u32 s_blocks_count; // Blocks count
u32 s_r_blocks_count; // Reserved blocks count
u32 s_free_blocks_count; // Free blocks count
u32 s_free_inodes_count; // Free inodes count
u32 s_first_data_block; // First Data Block
u32 s_log_block_size; // Block size
u32 s_log_cluster_size; // Allocation cluster size
u32 s_blocks_per_group; // # Blocks per group
u32 s_clusters_per_group; // # Fragments per group
u32 s_inodes_per_group; // # Inodes per group
u32 s_mtime; // Mount time
u32 s_wtime; // Write time
u32 s_mnt_count; // Mount count
u16 s_max_mnt_count; // Maximal mount count
u16 s_magic; // Magic signature
// more non-essential fields
u16 s_inode_size; // size of inode structure
};

块组描述符

struct ext2_ group_ desc (
u32
bg_ block_ bi tmap; // Bmap block number
u32 bg
inode_ bi tmap; //Imap b1ock number
u32 bg
inode_ table; // Indes begin block number
u16 bg_ free_ blocks_ count ; // THESE are OBVIOUS
u16 bg_ free_ inodes_ count ;
u16 bg_ used_ dirs_ count;
u16 bg_ pad; //ignore these
u32 bg_ reserved[3] ;
};

位图

索引节点

struct ext2_ inode {
u16 i_ mode;// 16 bits - ttttlugsIrwxJrwxIrwxl
u16 i_ uid;//owner uid
u32 i_ size;//file size in bytes
u32 i_ atime;//time fields in seconds
u32 i_ ctime;// since 00:00:00,1-1-1970
u32 i_ mtime;
u32 i_ dtime;
u16 i_ gid;// group ID
u16 i_ 1 inks_ count;// hard-link count
u32 i_ blocks;// number of 512-byte sectors
u32 i_ flags;//IGNORE
u32 i_ reserved1 ;//IGNORE
u32 i_ b1ock[15] ;//See details below
u32 i_ pad[7] ;//for inode size = 128 bytes
}

目录条目

struct ext2_dir_entry_2 {
u32 inode;
u16 rec_len;
u8 name_len;
u8 file_type;
char name[EXT2_NAME_LEN];
};

第八章:使用系统调用进行文件操作

系统调用

标签:count,八章,读书笔记,分区,fbuf,文件系统,u32,20191324,block
来源: https://www.cnblogs.com/pxmxxr/p/15377038.html