mirror of
https://github.com/libfuse/libfuse.git
synced 2024-11-23 04:04:31 +08:00
getattr: Make use of FUSE_GETATTR_FH in lowlevel examples
High level examples were already using it, but not lowlevel. Also update the documentation.
This commit is contained in:
parent
373ddc7eae
commit
0a76670183
@ -226,12 +226,12 @@ static void sfs_init(void *userdata, fuse_conn_info *conn) {
|
||||
}
|
||||
|
||||
|
||||
static void sfs_getattr(fuse_req_t req, fuse_ino_t ino, fuse_file_info *fi) {
|
||||
(void)fi;
|
||||
Inode& inode = get_inode(ino);
|
||||
static void sfs_getattr(fuse_req_t req, fuse_ino_t ino, fuse_file_info *fi)
|
||||
{
|
||||
struct stat attr;
|
||||
auto res = fstatat(inode.fd, "", &attr,
|
||||
AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
|
||||
int fd = fi ? fi->fh : get_inode(ino).fd;
|
||||
|
||||
auto res = fstatat(fd, "", &attr, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
|
||||
if (res == -1) {
|
||||
fuse_reply_err(req, errno);
|
||||
return;
|
||||
|
@ -204,10 +204,11 @@ static void lo_getattr(fuse_req_t req, fuse_ino_t ino,
|
||||
int res;
|
||||
struct stat buf;
|
||||
struct lo_data *lo = lo_data(req);
|
||||
int fd = fi ? fi->fh : lo_fd(req, ino);
|
||||
|
||||
(void) fi;
|
||||
|
||||
res = fstatat(lo_fd(req, ino), "", &buf, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
|
||||
res = fstatat(fd, "", &buf, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW);
|
||||
if (res == -1)
|
||||
return (void) fuse_reply_err(req, errno);
|
||||
|
||||
|
@ -303,7 +303,7 @@ struct fuse_lowlevel_ops {
|
||||
*
|
||||
* @param req request handle
|
||||
* @param ino the inode number
|
||||
* @param fi for future use, currently always NULL
|
||||
* @param fi file information, or NULL
|
||||
*/
|
||||
void (*getattr) (fuse_req_t req, fuse_ino_t ino,
|
||||
struct fuse_file_info *fi);
|
||||
|
Loading…
Reference in New Issue
Block a user