Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: copy_(to|from)_user_errcode()

we've got some helpers that return errors sanely, move them to a more
common location for use in fs-ioctl.c

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+16 -6
-6
fs/bcachefs/chardev.c
··· 22 22 #include <linux/slab.h> 23 23 #include <linux/uaccess.h> 24 24 25 - __must_check 26 - static int copy_to_user_errcode(void __user *to, const void *from, unsigned long n) 27 - { 28 - return copy_to_user(to, from, n) ? -EFAULT : 0; 29 - } 30 - 31 25 /* returns with ref on ca->ref */ 32 26 static struct bch_dev *bch2_device_lookup(struct bch_fs *c, u64 dev, 33 27 unsigned flags)
+16
fs/bcachefs/util.h
··· 848 848 void bch2_darray_str_exit(darray_str *); 849 849 int bch2_split_devs(const char *, darray_str *); 850 850 851 + #ifdef __KERNEL__ 852 + 853 + __must_check 854 + static inline int copy_to_user_errcode(void __user *to, const void *from, unsigned long n) 855 + { 856 + return copy_to_user(to, from, n) ? -EFAULT : 0; 857 + } 858 + 859 + __must_check 860 + static inline int copy_from_user_errcode(void *to, const void __user *from, unsigned long n) 861 + { 862 + return copy_from_user(to, from, n) ? -EFAULT : 0; 863 + } 864 + 865 + #endif 866 + 851 867 #endif /* _BCACHEFS_UTIL_H */