diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-02 23:30:33 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-14 04:22:26 +0300 |
commit | d64547999c591c47bfac279fa4027bdbd29c7ea0 (patch) | |
tree | 7365075ce7f4a064fdf56495e5392558acf92562 /fs/bcachefs/util.h | |
parent | ba81523eaac3df20ea884603bd67a74089900814 (diff) | |
download | linux-d64547999c591c47bfac279fa4027bdbd29c7ea0.tar.xz |
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>
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r-- | fs/bcachefs/util.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index b3d3a7349814..adff17f6f524 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -848,4 +848,20 @@ static inline bool qstr_eq(const struct qstr l, const struct qstr r) void bch2_darray_str_exit(darray_str *); int bch2_split_devs(const char *, darray_str *); +#ifdef __KERNEL__ + +__must_check +static inline int copy_to_user_errcode(void __user *to, const void *from, unsigned long n) +{ + return copy_to_user(to, from, n) ? -EFAULT : 0; +} + +__must_check +static inline int copy_from_user_errcode(void *to, const void __user *from, unsigned long n) +{ + return copy_from_user(to, from, n) ? -EFAULT : 0; +} + +#endif + #endif /* _BCACHEFS_UTIL_H */ |