Giter Club home page Giter Club logo

newfs's Introduction

实现的文件系统中的所有命令使用方式

挂载

需要满足磁盘中存在ddriver驱动,并指定一个目录为挂载目录,这里假设指定的目录为 ./tests/mnt

执行命令

./build/newfs --device=/root/ddriver -f -d -s ./tests/mnt
[root@localhost newfs]# ./build/newfs --device=/root/ddriver -f -d -s ./tests/mnt 
FUSE library version: 2.9.9
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.27
flags=0x003ffffb
max_readahead=0x00020000

打印文件系统日志,此时另开一个终端,进入 ./tests/mnt 目录下执行操作

创建目录

mkdir dir_name
[root@localhost mnt]# mkdir dir0
[root@localhost mnt]# mkdir dir1
[root@localhost mnt]# ls
dir0 dir1
[root@localhost mnt]#

创建文件

touch file_name
[root@localhost mnt]# touch file0
[root@localhost mnt]# touch file1
[root@localhost mnt]# ls
dir0 dir1 file0 file1
[root@localhost mnt]#

进入目录

cd dir_name

需要保证目录名存在,否则报错

[root@localhost mnt]# ls
dir0 dir1 file0 file1
[root@localhost mnt]# cd dir0
[root@localhost dir0]# cd dir0
bash: cd: dir0: No such file or directory
[root@localhost dir0]#

删除目录

rmdir [dir_list] 或 rm -rf [dir_list]

-r表示递归删除子目录,-f表示删除前不询问,需保证目录存在否则报错。

[root@localhost mnt]# ls
dir0 dir1 file0 file1
[root@localhost mnt]# rm -rf dir0
[root@localhost mnt]# ls
dir1 file0 file1
[root@localhost mnt]# rmdir dir1
[root@localhost mnt]# ls
file0 file1

删除文件

rm -f [file_list] 或 rm [file_list]

-f 表示在删除文件前不询问。

[root@localhost mnt]# ls
file0 file1
[root@localhost mnt]# rm file0 file1
rm: remove regular empty file 'file0'? y
rm: remove regular empty file 'file1'? y
[root@localhost mnt]# ls
[root@localhost mnt]#

向文件写入数据

echo xxx > file_name 或使用 tee 命令
[root@localhost mnt]# ls
a b
[root@localhost mnt]# echo "Hello World" > a
[root@localhost mnt]# cat a
Hello World
[root@localhost mnt]#
[root@localhost mnt]# tee -a b

Hello JiangChenyang!

Hello JiangChenyang!

[root@localhost mnt]# cat b

Hello JiangChenyang!

[root@localhost mnt]#

(8) 查看文件内容

cat file_name

效果如上

卸载

fusermount -u ./tests/mnt
[root@localhost newfs]# fusermount -u tests/mnt/

[root@localhost newfs]#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.