Link:
pfs is published in sourceforge, the website of pfs is sourceforge.net/projects/pfspfs, if you are interested, you can go to the site to download the source code
Overview:
pfs provides an abstraction of a file system, the type of the file system is PFS, and pfs provides users The concept of and group does not support the concept of process.
pfs supports unix/linux systems, and does not support other systems. In addition, due to my economic problems, I only tested the 32-bit environment. I don't know whether pfs can work normally for 64-bit.
Introduction:
pfs is A software written by a person, because of my own lack of ability, pfs will inevitably have bugs (there may be bugs that make the program crash or destroy the entire pfs file system), if you find any design
deficiencies and bugs, please contact me, I Tel: 13812708015 (my surname is Yan). In addition, if you are a god who has the ability to write editors like vi, please contact me, I need your wisdom.
In the end, there are not many commands implemented by pfs and many commands are castrated versions, so the functions provided by pfs are not many . The
design purpose: the purpose of pfs design is personal entertainment
. People who want to learn the file system can learn some knowledge of the file system in depth. pfs supports most of the features that the file system should have.
All reading the code of pfs can roughly understand some design ideas and ideas of the inode file system based on the
PFS file System:
The PFS file system is an inode-based file system
. PFS supports: PFS supports the following system calls. For the meaning of the specific functions, please refer to the INTERFACE document
int getuid(void);
int getgid(void);
int dup(int fd);
int close(int fd);
int umask(int umask);
int dup(int fd, int fd2);
int ftruncate(int fd, int length);
int truncate(const char *pathname, int length);
int creat(const char *pathname, int mode);
int access(const char *pathname, int mode);
int open(const char *pathname, int flags, ...);
int lseek(int fd, int offset, int whence);
int read(int fd, void *buf, uint bytes);
int write(int fd, const void *buf, uint bytes);
int unlink(const char *pathname);
int link(const char *oldpath, const char *newpath);
int rename(const char *oldpath, const char *newpath);
int symlink(const char *oldpath, const char *newpath);
int fstat(int fd, struct stat *stp);
int stat(const char *pathname, struct stat *stp);
int lstat(const char *pathname, struct stat *stp);
int fchmod(int fd, int mode);
int chmod(const char *pathname, int mode);
int fchown(int fd, int user, int group);
int chown(const char *pathname, int user, int group);
int lchown(const char *pathname, int user, int group);
int umount(const char *pathname);
int mount(const char *source, const char *target, int flags);
int chdir(const char *pathname);
int rmdir(const char *pathname);
int mkdir(const char * pathname, int mode);
int mknod(const char *pathname, int mode, int dev);
int closedir(mc_DIR *dp);
int telldir(mc_DIR *dp);
void seekdir(mc_DIR *dp, int loc);
char * getcwd(char *buf, int size);
DIR *opendir(const char *pathname);
struct dirent *readdir(DIR *dp);
IO:
pfs reads data from standard input of unix/linux and outputs to unix/linux Standard output
installation instructions:
The installation of pfs is very simple, just enter make in the shell, and then the user can enter ./pfs to use pfs
Instructions:
In order to use pfs, the user first needs a virtual disk, and the virtual disk can use dd if=/dev/zero of= xxx.img bs=?? count=?? to create
and then the user needs to call mkfs to format a virtual disk, and finally the user needs to call the login command to enter the pfs system, mkfs and help are the only two that can be used without logging in to the system Command
user:
pfs provides three users root, robin and tom by default, the passwords are empty, 123456 and 111111 respectively. pfs does not provide commands for adding, deleting users and changing passwords for the time being.
Introduction to pfs commands: pfs includes the following practical commands related to the file system
su command:
Command format:
su user
Command overview:
switch to the specified user user
Return value:
return 0 if successful , failure returns -1
cd command:
command format:
cd directory
command overview:
switch to the specified directory directory
return value:
success returns 0, failure returns -1
rm command:
Command format 1:
rm file1 [file2] ... [filen]
Command format 2: -r equivalent -R
rm -rR dir1 [dir2] ... [dirn]
Command overview:
delete a file or directory, rm Cannot delete . and .., and rm cannot delete the root of any disk. For symbolic links, rm will directly delete the symbolic link instead of the file or directory pointed to by the symbolic link.
Return value:
0 for success, -1 for failure
cp command:
Command format 1:
cp file1 file2
Command format 2:
cp file1 [file2] ... [filen] directory
Command overview:
Copy files, the cp command will copy the file pointed to by the symbolic link
Return value:
0 for success, -1 for failure
mv command:
command format 1:
mv file1 file2
command format 2:
mv file1 [file2] ... [filen] directory
command overview:
move files, the mv command will move the file pointed to by the symbolic link
Return value: the return value is only related to the last mv operation
, return 0 for success, -1 for failure
ls command :
Command format:
ls [-aciltuAULR] [directorys]
Command overview:
Display the files in the directory
Return value:
0 for success, -1 for failure
lcp command:
Command format 1:
lcp file1 file2
Command format 2:
lcp file1 [file2] ... [filen] directory
command overview:
Copy files from unix/linux systems to a disk formatted as PFS, lcp will copy the file pointed to by the symbolic link Return value: The return value is only related to the success
of the last lcp operation
Returns 0, on failure returns -1
cat command:
Command format:
cat [files]
Command overview:
Display the content of each file in turn, cat will display the content of the file pointed to by the symbolic link instead of the content of the symbolic link itself
Display format 1: If there is only one file
content
display format 2: If there is Multiple files
file1:
content
.
.
.
filen
content
Return value: The return value of cat is only related to the last file to be displayed
Return 0 for success, -1 for failure
pwd command:
command format:
pwd
command overview:
output current directory
return value :
return 0 for success, -1 for failure
help command:
command format:
help
command overview:
print help information
Return value:
this command always returns 0
quit command:
command format:
quit
command overview:
exit pfs
return value:
no
mkfs command:
command format:
mkfs pathname blocks_size swap_size inode_count
command overview:
format command, Format the disk as a file system PFS
parameter meaning:
pathname is the disk to be formatted - for example 1.img
blocks_size is the size of the PFS data block - optional values are 512, 1024, 2048, 4096, 8192
swap_size is the swap area size - Swap size is at least 10
inode_count is the number of inodes - the minimum number of inodes is 100. The number of inodes in PFS is fixed during formatting, and then the strategy can be modified to dynamically allocate inodes,
but this requires adding some code
return values:
0 for success, 0 for failure -1
login command:
command format:
login device
command overview:
login command, after executing the command, pfs will use the device as the root disk and initialize the system, then prompt the user to log in, and finally enter the system
Return value:
return 0 for success, -1 for failure
mkdir command:
command format:
mkdir directory
command overview:
create an empty directory
return value:
return 0 on success, -1 on failure
rmdir command:
command format:
rmdir directory
command overview:
delete an empty directory
Return value:
return 0 on success, -1 on failure
mount command:
command format:
mount [-r] device dir
command overview:
mount the disk device in the directory dir
parameter meaning:
device is the path name of the virtual disk in unix/linux , dir is an empty directory in the PFS file system, -r means read-only mount
Return value:
return 0 for success, return -1 for failure
umount command:
command format:
umount dir
command overview:
unmount the disk mounted in the directory dir
Return value :
return 0 for success, -1 for failure
logout command:
command format:
logout
command overview: logout
status
Return value:
return 0 for success, -1 for failure
Implementation of a file system - PFS
{{o.name}}
{{m.name}}
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324156055&siteId=291194637
Recommended
Ranking