mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
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>
This commit is contained in:
parent
ba81523eaa
commit
d64547999c
@ -22,12 +22,6 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
__must_check
|
|
||||||
static int copy_to_user_errcode(void __user *to, const void *from, unsigned long n)
|
|
||||||
{
|
|
||||||
return copy_to_user(to, from, n) ? -EFAULT : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* returns with ref on ca->ref */
|
/* returns with ref on ca->ref */
|
||||||
static struct bch_dev *bch2_device_lookup(struct bch_fs *c, u64 dev,
|
static struct bch_dev *bch2_device_lookup(struct bch_fs *c, u64 dev,
|
||||||
unsigned flags)
|
unsigned flags)
|
||||||
|
@ -848,4 +848,20 @@ static inline bool qstr_eq(const struct qstr l, const struct qstr r)
|
|||||||
void bch2_darray_str_exit(darray_str *);
|
void bch2_darray_str_exit(darray_str *);
|
||||||
int bch2_split_devs(const char *, 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 */
|
#endif /* _BCACHEFS_UTIL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user