On Tue, Apr 21, 2015 at 10:26:23AM +0800, 王旭 wrote: > > On 4/20/15 12:33 AM, xuw2...@gmail.com wrote: > >> From: George Wang <xuw2...@gmail.com> > <snip> > >> This means the value "_IOW*" will be negative when we store it in the int > >> variables. Such as the "BTRFS_IOC_QGROUP_CREATE", it will be "0x4010942e" > >> on > >> X86_64, but "0x8010942e" on PPC64. > >> Notice that the IOC values are the "unsigned long" type, so we use the > >> "unsigned long" to store it, and this can insure the comparison between the > >> variable and BTRFS_IOC_* valid. > > > > Looks good - very strange that the manpage states that the interface takes > > an int. :( > > I think maybe the manpage of ioctl is stale. But int can also work > except for comparison. > And fortunately the kernel interface is unsigned int, such as btrfs: > > 5217 long btrfs_ioctl(struct file *file, unsigned int > 5218 cmd, unsigned long arg) > > > > > But - an "unsigned int" would be enough, right? I don't think it needs > > to be an unsigned long. *shrug* > > unsigned int will be OK. But the btrfs-progs is user space, so the > ioctl I think it should be > consistent with the glibc: > /usr/include/sys/ioctl.h:extern int ioctl (int __fd, unsigned long int > __request, ...) __THROW; > unsigned long int is same with unsigned long. So maybe the unsigned > long will be better?
I think we should stick to the glibc interface as it's the closest one, although kernel uses usigned int in the end. Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html