[File System] File System Study Notes (10) --- Miscellaneous

Source: Internet
Author: User

1. There are many partitions on a system, such as the smartphone platform. For example, the/data and/system partitions are both ext4 file systems, but the system still has only one file_system_type member, however, the ext4 file system corresponding to each partition corresponds to different super_blocks. fs_supers links these Super blocks of the same file system to form a bidirectional cyclic linked list. fs_supers is the linked list header, the linked list element is represented by the s_instance Member of the super_block struct. All super_blocks in the system are linked by s_list of the super_block struct to a bidirectional cyclic linked list. The header is represented by the super_blocks variable.

 

2. the pseudo file system is a file system that cannot be loaded. Therefore, it cannot be seen directly from the user space as a file or directory. All pseudo file systems in the system can be obtained from/proc/filesystem

 

3. dumpe2fs command dumpe2fs

 

4. In the memory, the first block in the file system is the super block, and each group has a super block. The superblock behind it is the backup of the first super block, and the group is composed of many blocks, for example, 32768

 

5. The inode size is determined by the file systems themselves, such as 256b.

 

6. The commands for viewing disk and directory capacity are DF and Du.

 

7. A file occupies at least one block. If the file is too large, it occupies multiple blocks.

 

8. When we delete a file, we only mark inode as available. The content of the file in the block is not cleared. Only when a new file needs to occupy blocks, will be overwritten, which is also the reason why we can restore the deleted file.

 

9. What is the meaning of each member in the STAT command to view the file?
A: The use of the STAT command is shown below. The meaning of each member is as follows:
File: indicates the file name.
Blocks: indicates the number of blocks occupied by the file. Generally, the size of a Linux block is 512 bytes, and the size of the file system block is 512,/= 8. The following indicates that the F1 file occupies 8 blocks. that is, a file occupies at least 8 blocks.
Device: indicates the device that stores files.
Inode: indicates the inode number corresponding to the file.
Size: indicates the file size.
Links: indicates the number of hard links.
Io block: the size of the system formatted block and the size of the file system block.
Accesss: indicates the last time the file was accessed. If you read the file once, the time will change.
Modify: indicates the time when the last file is modified. The time when the file is modified is updated. For example, save the file by running the VI command.
Change: indicates the last time the file's inode information was modified. For example, you can use the CHMOD command to update the file's permissions.

 

10. Each process can open up to 32 files. Can a process expand if it opens 32 files simultaneously?
A: When a file descriptor is allocated to the Linux kernel, the number of files simultaneously opened by each process is 32 by default. If the file descriptor is exceeded, the file is stored in Alps/kernel/fs/file. the expand_files () function in the alloc_fd () function in the C file is extended. But the maximum number of extensions is 1024, that is, even if a process opens 1024 files at the same time, but this 1024 user can still modify it by using commands.

 

11. How to view the statfs function related to the file system in Linux programming.

View File System Information

 

[CPP]View plaincopy
  1. # Include <sys/VFS. h>
  2. Int statfs (const char * path, struct statfs * BUF );
  3. Int fstatfs (int fd, struct statfs * BUF );


Parameters:
Path: the path name of the file system in which information is to be queried.
FD: The file description word located in the file system for which information is to be queried.
Buf: pointer variable of the following struct used to store information related to the file system

 

 

[CPP]View plaincopy
  1. Struct statfs {
  2. Long f_type;/* file system type */
  3. Long f_bsize;/* optimized transfer block size */
  4. Long f_blocks;/* Total Number of data blocks in the file system */
  5. Long f_bfree;/* Number of available blocks */
  6. Long f_bavail;/* number of blocks that non-superusers can obtain */
  7. Long f_files;/* Total number of file nodes */
  8. Long f_ffree;/* Number of available File nodes */
  9. Fsid_t f_fsid;/* File System ID */
  10. Long f_namelen;/* Maximum File Name Length */
  11. };



 

[File System] File System Study Notes (10) --- Miscellaneous

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.