4 #include "funfsbyteswap.h"
13 #ifndef FUSE_KERNEL_VERSION
14 #include <linux/fuse.h>
17 inline void bswap_fuse_attr(struct fuse_attr
*attr
)
25 SWAP32(&attr
->blocks
);
31 inline void encode_fuse_attr(WvBuf
&buf
, struct fuse_attr
*attr
)
33 bswap_fuse_attr(attr
);
35 buf
.put(&attr
->mode
, 4);
36 buf
.put(&attr
->nlink
, 4);
37 buf
.put(&attr
->uid
, 4);
38 buf
.put(&attr
->gid
, 4);
39 buf
.put(&attr
->rdev
, 4);
40 buf
.put(&attr
->size
, 8);
41 buf
.put(&attr
->blocks
, 4);
42 buf
.put(&attr
->atime
, 4);
43 buf
.put(&attr
->mtime
, 4);
44 buf
.put(&attr
->ctime
, 4);
47 inline void decode_fuse_attr(WvBuf
&buf
, struct fuse_attr
*attr
)
49 memcpy(&attr
->mode
, buf
.get(4), 4);
50 memcpy(&attr
->nlink
, buf
.get(4), 4);
51 memcpy(&attr
->uid
, buf
.get(4), 4);
52 memcpy(&attr
->gid
, buf
.get(4), 4);
53 memcpy(&attr
->rdev
, buf
.get(4), 4);
54 memcpy(&attr
->size
, buf
.get(8), 8);
55 memcpy(&attr
->blocks
, buf
.get(4), 4);
56 memcpy(&attr
->atime
, buf
.get(4), 4);
57 memcpy(&attr
->mtime
, buf
.get(4), 4);
58 memcpy(&attr
->ctime
, buf
.get(4), 4);
60 bswap_fuse_attr(attr
);
63 inline void bswap_fuse_kstatfs(struct fuse_kstatfs
*fst
)
65 SWAP32(&fst
->block_size
);
67 SWAP32(&fst
->blocks_free
);
69 SWAP32(&fst
->files_free
);
70 SWAP32(&fst
->namelen
);
73 inline void decode_fuse_kstatfs(WvBuf
&buf
, struct fuse_kstatfs
*fst
)
75 memcpy(&fst
->block_size
, buf
.get(4), 4);
76 memcpy(&fst
->blocks
, buf
.get(4), 4);
77 memcpy(&fst
->blocks_free
, buf
.get(4), 4);
78 memcpy(&fst
->files
, buf
.get(4), 4);
79 memcpy(&fst
->files_free
, buf
.get(4), 4);
80 memcpy(&fst
->namelen
, buf
.get(4), 4);
82 bswap_fuse_kstatfs(fst
);
85 inline void encode_fuse_kstatfs(WvBuf
&buf
, struct fuse_kstatfs
*fst
)
87 bswap_fuse_kstatfs(fst
);
89 buf
.put(&fst
->block_size
, 4);
90 buf
.put(&fst
->blocks
, 4);
91 buf
.put(&fst
->blocks_free
, 4);
92 buf
.put(&fst
->files
, 4);
93 buf
.put(&fst
->files_free
, 4);
94 buf
.put(&fst
->namelen
, 4);
97 inline void encode_fuse_dirent(WvBuf
&buf
, struct dirent
*de
)
99 buf
.putch(de
->d_type
);
100 assert(de
->d_reclen
< 256);
101 buf
.put(de
->d_name
, strlen(de
->d_name
));
105 inline void decode_fuse_dirent(WvBuf
&buf
, struct fuse_dirent
*fde
)
107 fde
->type
= buf
.getch();
108 fde
->namelen
= buf
.strchr('\0') - 1;
109 strncpy(fde
->name
, (const char *)buf
.get(fde
->namelen
+ 1), 256);