]> www.infradead.org Git - linux.git/commitdiff
bcachefs: copy_(to|from)_user_errcode()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 2 Mar 2024 20:30:33 +0000 (15:30 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 14 Mar 2024 01:22:26 +0000 (21:22 -0400)
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>
fs/bcachefs/chardev.c
fs/bcachefs/util.h

index b584d78cb39cc6cccab565f2abed217930c567de..38defa19d52d701762fa95a02cb1e22e7a0c182c 100644 (file)
 #include <linux/slab.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 */
 static struct bch_dev *bch2_device_lookup(struct bch_fs *c, u64 dev,
                                          unsigned flags)
index b3d3a7349814cbb0d6c40924eca09918ef27ad15..adff17f6f524bce6e5cfaec28772eeaee1522588 100644 (file)
@@ -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 */