FreeBSD Bugzilla – Attachment 233566 Details for
Bug 263625
FUSE_CREATE is broken on anything older than protocol version 7.9
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Type cast test for version 7.8 or earlier
fuse-create-test.c (text/plain), 2.51 KB, created by
Ali Abdallah
on 2022-04-28 17:35:14 UTC
(
hide
)
Description:
Type cast test for version 7.8 or earlier
Filename:
MIME Type:
Creator:
Ali Abdallah
Created:
2022-04-28 17:35:14 UTC
Size:
2.51 KB
patch
obsolete
>#include <stdio.h> >#include <string.h> >#include <stdint.h> >#include <unistd.h> >#include <fcntl.h> > >/********************************************* > * KERNEL TYPES > *********************************************/ >struct fuse_attr { > uint64_t ino; > uint64_t size; > uint64_t blocks; > uint64_t atime; > uint64_t mtime; > uint64_t ctime; > uint32_t atimensec; > uint32_t mtimensec; > uint32_t ctimensec; > uint32_t mode; > uint32_t nlink; > uint32_t uid; > uint32_t gid; > uint32_t rdev; > uint32_t blksize; > uint32_t padding; >}; > >struct fuse_entry_out { > uint64_t nodeid; /* Inode ID */ > uint64_t generation; /* Inode generation: nodeid:gen must > be unique for the fs's lifetime */ > uint64_t entry_valid; /* Cache timeout for the name */ > uint64_t attr_valid; /* Cache timeout for the attributes */ > uint32_t entry_valid_nsec; > uint32_t attr_valid_nsec; > struct fuse_attr attr; >}; > >struct fuse_open_out { > uint64_t fh; > uint32_t open_flags; > uint32_t padding; >}; > > >/*************************************************** > * USERSPACE TYPES for protocol version 7.5 (or 7.8) > ***************************************************/ >struct fuse_attr_userspace { > uint64_t ino; > uint64_t size; > uint64_t blocks; > uint64_t atime; > uint64_t mtime; > uint64_t ctime; > uint32_t atimensec; > uint32_t mtimensec; > uint32_t ctimensec; > uint32_t mode; > uint32_t nlink; > uint32_t uid; > uint32_t gid; > uint32_t rdev; >}; > >struct fuse_entry_out_userspace { > uint64_t nodeid; /* Inode ID */ > uint64_t generation; /* Inode generation: nodeid:gen must > be unique for the fs's lifetime */ > uint64_t entry_valid; /* Cache timeout for the name */ > uint64_t attr_valid; /* Cache timeout for the attributes */ > uint32_t entry_valid_nsec; > uint32_t attr_valid_nsec; > struct fuse_attr_userspace attr; >}; > >struct create_out { > struct fuse_entry_out_userspace entry; > struct fuse_open_out open; >}; > >int main (int argc, char **argv) >{ > struct fuse_entry_out *feo; > struct fuse_open_out *foo; > > struct create_out fdip; > > /* Userspace fills these fields */ > fdip.entry.attr_valid_nsec = 1; > fdip.entry.entry_valid_nsec = 1; > fdip.open.fh = 13; > fdip.open.open_flags = O_RDWR; > fdip.open.padding = 0; > > /* With the following cast, fuse on FreeBSD Will get */ > feo = &fdip; > > foo = (struct fuse_open_out*)(feo + 1); > printf("ORIG: Wrong file handle %ld != %ld\n", > foo->fh, fdip.open.fh); > > /* But it should be as follows */ > foo = (struct fuse_open_out*)((char*)feo + sizeof(struct fuse_entry_out_userspace)); > printf("DIFF: File handle %ld == %ld\n", > foo->fh, fdip.open.fh); > > return(0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 263625
:
233558
| 233566