FUSE is a good thing and can be used in a special field to implement your own virtual file system.
Fuse Download and Installation:
Download the latest installation package from fuse website: http://sourceforge.net/projects/fuse/files/fuse-2.X/
Installation is simple:
./configure
Make
Make install (note: This step is to be done in root user mode)
To mount the fuse virtual file system:
Modprobe Fuse
To see if fuse was mounted successfully:
Lsmod|grep Fuse executes the command and outputs
[Email protected] fuse]# Lsmod | grep fuse
Fuse 49237 2
Prove Mount succeeded
Down is the use of the problem, hehe.
After installing fuse, its subfolder example has some well-done file system instances, teaching you to mount and use the file system, recommend the use of FUSEXMP_FH.C This example
Because he includes all of the file operations related mappings.
Compiling the FUSEXMP_FH.C requires the following compile command:
Gcc-wall ' pkg-config fuse--cflags--libs '-lulockmgr fusexmp_fh.c-o fusexmp_fh.exe
Build Fusexmp_fh.exe executable after compiling
Create a folder under the/mnt directory fuse
Cd/mnt
mkdir Fuse
Then go to the Fusexmp_fh.exe directory to execute
./fusexmp_fh.exe/mnt/fuse-d
The virtual file system can be started, this time to execute
DF command, you can see that the virtual file system is mounted.
[[email protected] example]# DF
Fuse 6824296 3499688 2972352 55%/mnt/fuse
This time you enter the/mnt/fuse directory
Execute LS, you can see the mapped file contents, the file operation under this directory will be called to fusexmp_fh.exe this process registered
File manipulation functions.
The registration handle is as follows:
[CPP]View PlainCopy
- Static struct Fuse_operations Xmp_oper = {
- . GetAttr = Xmp_getattr,
- . fgetattr = Xmp_fgetattr,
- . Access = Xmp_access,
- . Readlink = Xmp_readlink,
- . Opendir = Xmp_opendir,
- . Readdir = Xmp_readdir,
- . Releasedir = Xmp_releasedir,
- . Mknod = Xmp_mknod,
- . mkdir = Xmp_mkdir,
- . symlink = Xmp_symlink,
- . Unlink = Xmp_unlink,
- . rmdir = Xmp_rmdir,
- . Rename = Xmp_rename,
- . link = xmp_link,
- . chmod = Xmp_chmod,
- . Chown = Xmp_chown,
- . truncate = Xmp_truncate,
- . ftruncate = Xmp_ftruncate,
- . Utimens = Xmp_utimens,
- . Create = Xmp_create,
- . open = Xmp_open,
- . Read = Xmp_read,
- . write = Xmp_write,
- . Statfs = Xmp_statfs,
- . Flush = Xmp_flush,
- . Release = Xmp_release,
- . Fsync = Xmp_fsync,
- #ifdef HAVE_SETXATTR
- . setxattr = Xmp_setxattr,
- . getxattr = Xmp_getxattr,
- . listxattr = Xmp_listxattr,
- . removexattr = Xmp_removexattr,
- #endif
- . Lock = Xmp_lock,
- . FLAG_NULLPATH_OK = 1,
- };
For example, if you execute mkdir XXX, this function is called to the fusexmp_fh.exe process int xmp_mkdir (const char *path, mode_t mode).
You can modify the implementation of this function to add your own information inside.
When the following error message appears:
Fuse:bad mount point '/mnt/fuse ': Transport endpoint are not connected
You just have to do
Umount-l/mnt/fuse command can dissolve the above error, the specific reason is needless to say, umount so obvious.
We use fuse this time mainly to realize the function of a cloud.
http://blog.csdn.net/langeldep/article/details/6221112
Installation and use of fuse virtual file system