Installation and use of fuse virtual file system

Source: Internet
Author: User

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
  1. Static struct Fuse_operations Xmp_oper = {
  2. . GetAttr = Xmp_getattr,
  3. . fgetattr = Xmp_fgetattr,
  4. . Access = Xmp_access,
  5. . Readlink = Xmp_readlink,
  6. . Opendir = Xmp_opendir,
  7. . Readdir = Xmp_readdir,
  8. . Releasedir = Xmp_releasedir,
  9. . Mknod = Xmp_mknod,
  10. . mkdir = Xmp_mkdir,
  11. . symlink = Xmp_symlink,
  12. . Unlink = Xmp_unlink,
  13. . rmdir = Xmp_rmdir,
  14. . Rename = Xmp_rename,
  15. . link = xmp_link,
  16. . chmod = Xmp_chmod,
  17. . Chown = Xmp_chown,
  18. . truncate = Xmp_truncate,
  19. . ftruncate = Xmp_ftruncate,
  20. . Utimens = Xmp_utimens,
  21. . Create = Xmp_create,
  22. . open = Xmp_open,
  23. . Read = Xmp_read,
  24. . write = Xmp_write,
  25. . Statfs = Xmp_statfs,
  26. . Flush = Xmp_flush,
  27. . Release = Xmp_release,
  28. . Fsync = Xmp_fsync,
  29. #ifdef HAVE_SETXATTR
  30. . setxattr = Xmp_setxattr,
  31. . getxattr = Xmp_getxattr,
  32. . listxattr = Xmp_listxattr,
  33. . removexattr = Xmp_removexattr,
  34. #endif
  35. . Lock = Xmp_lock,
  36. . FLAG_NULLPATH_OK = 1,
  37. };

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

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.