分类: LINUX
2011-05-14 16:31:30
fuse在内核中通过设备号 /dev/fuse来进行内核与用户空间之间通信,其中内核代码(/fs/fuse),通信之间采用协议方式。内核发送到用户态时就会发送一个头fuse_in_head(用户数据进入端):
struct fuse_in_header
{
__u32 len;
__u32 opcode;
__u64 unique;
__u32 nodeid;
__u32 uid;
__u32 gid;
__u32 pid;
__u32 padding;
}
各个字段含义如下:
字段名称 |
数据类型 |
含义 |
len |
uint32_t |
本次请求数据包的长度 |
opcode |
uint32_t |
操作码 |
unique |
uint64_t |
请求的uid,回复包需要 |
nodeid |
uint32_t |
本次操作涉及的文件系统 node id |
uid |
uint32_t |
调用者的id |
gid |
uint32_t |
调用者所在组id |
padding |
uint32_t |
未使用,填充至64字节倍数 |
其中操作码即为文件系统的所有涉及操作:
操作码 |
回复函数(正确情况) |
reply数据类型 |
值 |
相应函数 |
备注 |
FUSE_LOOKUP |
fuse_reply_entry |
fuse_entry_out |
0 |
do_lookup |
取属性 |
FUSE_FORGET |
|
|
1 |
do_forget |
|
FUSE_GETATTR |
fuse_reply_attr |
fuse_attr_out |
2 |
do_getattr |
取属性 |
FUSE_SETATTR |
fuse_reply_attr |
fuse_attr_out |
3 |
do_setattr |
|
FUSE_READLINK |
fuse_reply_readlink |
string |
4 |
do_readlink |
|
FUSE_SYMLINK |
fuse_reply_entry |
fuse_entry_out |
5 |
do_symlink |
|
FUSE_MKNOD |
fuse_reply_entry |
fuse_entry_out |
6 |
do_mknod |
|
FUSE_MKDIR |
fuse_reply_entry |
fuse_entry_out |
7 |
do_mkdir |
|
FUSE_UNLINK |
fuse_reply_err |
errcode |
8 |
do_unlink |
|
FUSE_RMDIR |
fuse_reply_err |
errcode |
9 |
do_rmdir |
|
FUSE_RENAME |
fuse_reply_err |
errcode |
10 |
do_rename |
|
FUSE_LINK |
fuse_reply_entry |
fuse_entry_out |
11 |
do_link |
|
FUSE_OPEN |
fuse_reply_open |
fuse_open_out |
12 |
do_open |
|
FUSE_READ |
fuse_reply_buf, fuse_reply_iov |
char[] |
13 |
do_read |
|
FUSE_WRITE |
fuse_reply_write |
int |
14 |
do_write |
|
FUSE_STATFS |
fuse_reply_statfs |
fuse_statfs_out |
15 |
do_statfs |
|
FUSE_RELEASE |
fuse_reply_err |
errcode |
16 |
do_release |
|
FUSE_FSYNC |
fuse_reply_err |
errcode |
17 |
do_fsync |
|
FUSE_SETXATTR |
fuse_reply_err |
errcode |
18 |
do_setxattr |
|
FUSE_GETXATTR |
fuse_reply_buf fuse_reply_xattr |
fuse_getxattr_out |
19 |
do_getxattr |
|
FUSE_LISTATTR |
fuse_reply_xattr |
fuse_getxattr_out |
20 |
do_listxattr |
|
FUSE_REMOVEXATTR |
fuse_reply_err |
errcode |
21 |
do_removexattr |
|
FUSE_FLUSH |
fuse_reply_err |
errcode |
22 |
do_flush |
|
FUSE_INIT |
No |
No |
23 |
do_init |
系统实现 |
FUSE_OPENDIR |
fuse_reply_open |
fuse_open_out |
24 |
do_opendir |
|
FUSE_READDIR |
fuse_reply_buf |
char*[] |
25 |
do_readdir |
|
FUSE_RELEASEDIR |
fuse_reply_err |
errcode |
26 |
do_releasedir |
|
FUSE_FSYNCDIR |
fuse_reply_err |
errcode |
27 |
do_fsyncdir |
|
FUSE_GETLK |
fuse_reply_lock |
fuse_lk_out |
28 |
do_getlk |
|
FUSE_SETLK |
fuse_reply_err |
errcode |
29 |
do_setlk |
|
FUSE_SETLKW |
|
fuse_lk_out |
30 |
do_setlkw |
setlk实现 |
FUSE_ACCESS |
fuse_reply_err |
errcode |
31 |
do_access |
|
FUSE_CREATE |
fuse_reply_create |
fuse_open_out?? |
32 |
do_create |
|
FUSE_INTERRUPT |
|
|
33 |
do_interrupt |
系统实现 |
FUSE_BMAP |
fuse_reply_bmap |
|
34 |
do_bmap |
|
FUSE_IOCTL |
fuse_reply_ioctl fuse_reply_ioctl_retry |
|
35 |
do_ioctl |
|
FUSE_POLL |
fuse_reply_poll |
|
36 |
do_poll |
|
FUSE_DESTROY |
NULL |
|
37 |
do_destroy |
|
CUSE_INIT |
无 |
无 |
38 |
do_lowlevel_init |
|
参考资料:
http://blogold.chinaunix.net/u3/117103/links_22081.html