aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_util.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2020-10-20 17:19:10 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2020-10-20 17:19:10 +0000
commit1a34e9fad6b6d894eb81002bd966684be1d1fe86 (patch)
treed8b18b71227f510e9457f9c3e35427c3e49c51f6 /sys/compat/linux/linux_util.c
parentbc3d5698008e9b3b19495e853cbc2598979ccf8a (diff)
Fix potential race condition in linux stat(2).
Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25618
Notes
Notes: svn path=/head/; revision=366899
Diffstat (limited to 'sys/compat/linux/linux_util.c')
-rw-r--r--sys/compat/linux/linux_util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
index 59fc844e1cbe..5febafef08c7 100644
--- a/sys/compat/linux/linux_util.c
+++ b/sys/compat/linux/linux_util.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/bus.h>
+#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -195,6 +196,24 @@ linux_driver_get_major_minor(const char *node, int *major, int *minor)
return (1);
}
+int
+linux_vn_get_major_minor(const struct vnode *vp, int *major, int *minor)
+{
+ int error;
+
+ if (vp->v_type != VCHR)
+ return (ENOTBLK);
+ dev_lock();
+ if (vp->v_rdev == NULL) {
+ dev_unlock();
+ return (ENXIO);
+ }
+ error = linux_driver_get_major_minor(devtoname(vp->v_rdev),
+ major, minor);
+ dev_unlock();
+ return (error);
+}
+
char *
linux_get_char_devices()
{