Skip to content

Commit d645479

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent ba81523 commit d645479

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

fs/bcachefs/chardev.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
#include <linux/slab.h>
2323
#include <linux/uaccess.h>
2424

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-
3125
/* returns with ref on ca->ref */
3226
static struct bch_dev *bch2_device_lookup(struct bch_fs *c, u64 dev,
3327
unsigned flags)

fs/bcachefs/util.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,4 +848,20 @@ static inline bool qstr_eq(const struct qstr l, const struct qstr r)
848848
void bch2_darray_str_exit(darray_str *);
849849
int bch2_split_devs(const char *, darray_str *);
850850

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+
851867
#endif /* _BCACHEFS_UTIL_H */

0 commit comments

Comments
 (0)