# vvsfs **Repository Path**: Miyanaga/vvsfs ## Basic Information - **Project Name**: vvsfs - **Description**: 一个非常简单的Linux文件系统模块。 - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-08-31 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # VVSFS drei - The third edition of VVSFS (C) Eric McCreath 2006-2016 (C) Saki Tojo 2016 This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; ## Features The VVSFS drei supports the `basictestscript` in the source code directory, it could pass all the test. The `basictestscript` is modified for loading `lz4_compress` module first, but didn't change all the other content. The VVSFS drei supports the following improvements in the list to the original version: * Support links (both hard and symbolic). * Support device nodes. * Support executing so files. * Support `mmap` working. * Removed bounds on the number of inodes and file name sizes. * Support `/proc` entry to inform users of the number of inodes, the amount of disk usage the filesystem is currently using. * Support LZ4 file content compression. * Support AES-256 and XOR block encryption. * Support de-duplicate blocks that are identical. * Support journal for improving the robust of the filesystem. * Optimized the filesystem for SSD for wrinting blocks to different location. The VVSFS drei supports the following own extension which is not in the list: * inodes and blocks are seperated. * Support rename file. * Support move file outside filesystem and inside filesystem. * Support enable and disable features using `/proc/vvsfs` entry. * Support using `ioctl` to encrypt, decrypt and truncate file. * Support mount different block size devices. * Support to store the create, modify and access time. The attachments have been following improvment: * Raw file viewer supports shows blocks usage and inodes usage. * Raw file viewer supports shows used inodes list. * Raw file viewer supports shows block hash and reference count. * Raw file viewer supports shows block state, including 'root block', 'empty' and 'encryption'. The VVSFS drei is depended on `lz4_compress` system module. Before installing the kernel module, you have to use `sudo modprobe lz4_compress` to install LZ4 Compression module into kernel first. ## Usage All the commands needs to be done after insert the vvsfs drei module and mount at least one test image file. ### View mounting information VVSFS drei supports display statistics information of mounting disks, to display those information, please launch: $ cat /proc/vvsfs The statistics information of one disk drive contains: * Disk Identifier ID * Disk features enabling status * Disk space usage * Disk block size * Disk inode usage * Disk block usage It may shows you the following information of one mounting disk: Disk #0 Encryption : No Compression : No SSD Optimization : No Device Space : 200 KB, 204800 bytes Data Space : 177 KB, 181724 bytes Used : 25 bytes Free : 177 KB, 181699 bytes Used% : 0% Unit : 1024 bytes block SSD Start Block : 20 Inode Blocks : 17 blocks inodes per Block : 23 inodes inode Total : 391 inodes inode Used : 2 inodes inode Free : 389 inodes inode Usage : 0% Data Blocks Total : 181 blocks Data Blocks Used : 2 blocks Data Blocks Free : 179 blocks Data Blocks Usage : 1% The first line shows the disk identifier ID, which is `0` for this instance. ### Compression VVSFS drei supports compressing file using LZ4 compression algorithm. To enable this feature, you have to get the disk identifier ID. e.g. to enable compression feature on disk whose identifier is 0, launch: $ echo enable compression 0 > /proc/vvsfs The command line won't give any response. To check whether you enable the feature or not, check the mounting information of the disk. The compression won't always enable for a single file. It will only enable for those file whose size is smaller after applying the compression. To disable this feature for the disk above, launch: $ echo disable compression 0 > /proc/vvsfs ### Encryption VVSFS drei supports 256-bit AES and XOR mixed encryption. To enable this feature, you have to get the disk identifier ID. e.g. to enable encryption feature on disk whose identifier is 0, launch: $ echo enable encryption 0 > /proc/vvsfs The command line won't give any response. To check whether you enable the feature or not, check the mounting information of the disk. The encryption won't be used until you give the vvsfs the key, to set the string "bismarck" as a key for the disk above, you have to launch the command: $ echo set key 0 bismarck > /proc/vvsfs Once you set the key, all the file content written after will be encrypted via 256-bit AES and XOR. If you set the key but didn't enable the encryption, it will decrypt all the content you access. If you didn't write the content, the content will stay in encryption. Once you change the content, the content will be decrypt. To disable this feature for the disk above, launch: $ echo disable encryption 0 > /proc/vvsfs Once you disable the encryption, all the content written after will be written in its original plain text. ### Input/Output Control (ioctl) VVSFS drei supports using `ioctl` to encrypt, decrypt and truncate file. You can view and test the features with example files named `ioctl_encrypt.c`, `ioctl_decrypt.c` and `ioctl_size.c`. The second parameter of `ioctl` function are defined in `vvsfs.h`. They are `VVSFS_IOCTL_ENCRYPT`, `VVSFS_IOCTL_DECRYPT` and `VVSFS_IOCTL_RESIZE`. The third parameter of `ioctl` function should be a pointer pointed to a structure whose type is `vvsfs_ioctl`. When the second parameter of `ioctl` is `VVSFS_IOCTL_ENCRYPT` and `VVSFS_IOCTL_DECRYPT`, only `key` of the structure will be used. When the second parameter is `VVSFS_IOCTL_RESIZE`, only `file_size` will be used. ### SSD Optimization VVSFS drei supports SSD written optimization. To enable this feature, you have to get the disk identifier ID. e.g. to enable ssd optimization feature on disk whose identifier is 0, launch: $ echo enable ssd_optimization 0 > /proc/vvsfs To disable this feature, launch: $ echo disable ssd_optimization 0 > /proc/vvsfs ## Build & Run ### Using `autobuild` script There is a `autobuild` tool for quick testing and demonstration. To build the vvsfs drei, launch: $ ./autobuild -b The `autobuild` tool could generate a 1024-byte block raw file with 200 blocks. To generate the testing files, launch: $ ./autobuild -g The test image file name is `vvsfs.raw`. After building the filesystem, the VVSFS drei raw file viewer is also compiled. Default filename is `view.vvsfs`. To view the testing images, launch: $ ./autobuild -p To mount the test file, launch: $ ./autobuild -m After the testing the filesystem, to unmount the raw file and uninstall the kernel module launch: $ ./autobuild -u ### Using commands **Build `vvsfs`** To compile and build the `vvsfs` filesystem, launch: $ make **Load `vvsfs` module** The vvsfs drei filesystem depends on `lz4_compress` kernel module. You have to load this module first using `modprobe` command as root: $ sudo modprobe lz4_compress After you load `lz4_compress` module, it should appears in your `lsmod` result: $ lsmod | grep lz4 lz4_compress 12481 0 Now you can load vvsfs drei via `insmod`: $ sudo insmod vvsfs.ko **Generate testing image file** To generate a testing image file, you have to use `dd` to generate the test image file: $ dd of=./vvsfs.raw if=/dev/zero bs=1024 count=200 Parameter `bs` could be 512, 1024 and 2048. Now, `vvsfs drei` supports for 512 bytes, 1024 bytes and 2048 bytes block. There's no limitation for the count. However, it should be larger than the maximum integer. **Format the image file** The image file needs formatting before mount it. To format an image file: $ ./mkfs.vvsfs ./vvsfs.raw The usage of 'mkfs.vvsfs' is: mkfs.vvsfs The parameter of `mkfs.vvsfs` has only `-b` for declaring explicit block size. It could be 512, 1024 or 2048. It will be 1024 as default. If you generate your image file with other size of blocks, please change the parameter `-b`. e.g., if you have a 512 bytes block image file (generate by `dd` with parameter `bs=512`), you have to format the image file via: $ ./mkfs.vvsfs ./vvsfs.raw -b 512 **Mount test image file** To mount the file, first you need a directory as an entry of the test image. Create an empty directory using `mkdir` command: $ mkdir testdir Mount the image file to the directory: $ sudo mount -t vvsfs -o loop vvsfs.raw testdir Now you can do the test as you want. **Unmount the image file** To unmount one test image, you have to close all the application which is now using the image, and launch `umount` to unmount the image file: $ sudo umount testdir **Remove the kernel module** If you want to remove the kernel module, launch `rmmod` after you unmount all the testdir data. $ sudo rmmod vvsfs ### License vvsfs drei is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. vvsfs drei is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with vvsfs drei. If not, see http://www.gnu.org/licenses/.