summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6b0f234)
Code cleanup around obd_class_*() functions and sanity test for non-root lfs check
i=adilger
i=andrew.perepechko
#define LNET_DEV_MAJOR 10
#define LNET_DEV_MINOR 240
#define OBD_DEV_ID 1
#define LNET_DEV_MAJOR 10
#define LNET_DEV_MINOR 240
#define OBD_DEV_ID 1
-#define OBD_DEV_PATH "/dev/obd"
+#define OBD_DEV_NAME "obd"
+#define OBD_DEV_PATH "/dev/" OBD_DEV_NAME
#define OBD_DEV_MAJOR 10
#define OBD_DEV_MINOR 241
#define SMFS_DEV_ID 2
#define OBD_DEV_MAJOR 10
#define OBD_DEV_MINOR 241
#define SMFS_DEV_ID 2
/* OBD Operations Declarations */
extern struct obd_device *class_conn2obd(struct lustre_handle *);
extern struct obd_device *class_exp2obd(struct obd_export *);
/* OBD Operations Declarations */
extern struct obd_device *class_conn2obd(struct lustre_handle *);
extern struct obd_device *class_exp2obd(struct obd_export *);
+extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
#include <obd_support.h>
#include <obd_class.h>
#include <obd_support.h>
#include <obd_class.h>
+#include <lnet/lnetctl.h>
#include <lustre_debug.h>
#include <lprocfs_status.h>
#include <lustre/lustre_build_version.h>
#include <lustre_debug.h>
#include <lprocfs_status.h>
#include <lustre/lustre_build_version.h>
CWARN("obd_fail_loc = %lx\n", obd_fail_loc);
return obd_fail_loc;
}
CWARN("obd_fail_loc = %lx\n", obd_fail_loc);
return obd_fail_loc;
}
-
-/* opening /dev/obd */
-static int obd_class_open(unsigned long flags, void *args)
-{
- ENTRY;
-
- PORTAL_MODULE_USE;
- RETURN(0);
-}
-
-/* closing /dev/obd */
-static int obd_class_release(unsigned long flags, void *args)
-{
- ENTRY;
-
- PORTAL_MODULE_UNUSE;
- RETURN(0);
-}
#endif
static inline void obd_data2conn(struct lustre_handle *conn,
#endif
static inline void obd_data2conn(struct lustre_handle *conn,
-/* to control /dev/obd */
-static int obd_class_ioctl (struct cfs_psdev_file *pfile, unsigned long cmd,
- void *arg)
-{
- return class_handle_ioctl(cmd, (unsigned long)arg);
-}
-
-/* declare character device */
-struct cfs_psdev_ops obd_psdev_ops = {
- /* .p_open = */ obd_class_open, /* open */
- /* .p_close = */ obd_class_release, /* release */
- /* .p_read = */ NULL,
- /* .p_write = */ NULL,
- /* .p_ioctl = */ obd_class_ioctl /* ioctl */
-};
-
extern cfs_psdev_t obd_psdev;
#else
void *obd_psdev = NULL;
extern cfs_psdev_t obd_psdev;
#else
void *obd_psdev = NULL;
err = cfs_psdev_register(&obd_psdev);
if (err) {
err = cfs_psdev_register(&obd_psdev);
if (err) {
- CERROR("cannot register %d err %d\n", OBD_MINOR, err);
+ CERROR("cannot register %d err %d\n", OBD_DEV_MINOR, err);
-/*
- * cfs pseudo device
- */
-extern struct cfs_psdev_ops obd_psdev_ops;
static int
obd_class_open(dev_t dev, int flags, int devtype, struct proc *p)
{
static int
obd_class_open(dev_t dev, int flags, int devtype, struct proc *p)
{
- if (obd_psdev_ops.p_open != NULL)
- return -obd_psdev_ops.p_open(0, NULL);
- return EPERM;
}
/* closing /dev/obd */
static int
obd_class_release(dev_t dev, int flags, int mode, struct proc *p)
{
}
/* closing /dev/obd */
static int
obd_class_release(dev_t dev, int flags, int mode, struct proc *p)
{
- if (obd_psdev_ops.p_close != NULL)
- return -obd_psdev_ops.p_close(0, NULL);
- return EPERM;
if (!is_suser())
RETURN (EPERM);
if (!is_suser())
RETURN (EPERM);
- if (obd_psdev_ops.p_ioctl != NULL)
- err = -obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
- else
- err = EPERM;
+
+ err = class_handle_ioctl(cmd, (unsigned long)arg);
#include <libcfs/libcfs.h>
#include <obd_support.h>
#include <obd_class.h>
#include <libcfs/libcfs.h>
#include <obd_support.h>
#include <obd_class.h>
+#include <lnet/lnetctl.h>
#include <lprocfs_status.h>
#include <lustre_ver.h>
#include <lustre/lustre_build_version.h>
#include <lprocfs_status.h>
#include <lustre_ver.h>
#include <lustre/lustre_build_version.h>
EXPORT_SYMBOL(obd_ioctl_getdata);
EXPORT_SYMBOL(obd_ioctl_popdata);
EXPORT_SYMBOL(obd_ioctl_getdata);
EXPORT_SYMBOL(obd_ioctl_popdata);
-#define OBD_MINOR 241
-extern struct cfs_psdev_ops obd_psdev_ops;
-
/* opening /dev/obd */
static int obd_class_open(struct inode * inode, struct file * file)
{
/* opening /dev/obd */
static int obd_class_open(struct inode * inode, struct file * file)
{
- if (obd_psdev_ops.p_open != NULL)
- return obd_psdev_ops.p_open(0, NULL);
- return -EPERM;
+ ENTRY;
+
+ PORTAL_MODULE_USE;
+ RETURN(0);
}
/* closing /dev/obd */
static int obd_class_release(struct inode * inode, struct file * file)
{
}
/* closing /dev/obd */
static int obd_class_release(struct inode * inode, struct file * file)
{
- if (obd_psdev_ops.p_close != NULL)
- return obd_psdev_ops.p_close(0, NULL);
- return -EPERM;
+ ENTRY;
+
+ PORTAL_MODULE_UNUSE;
+ RETURN(0);
}
/* to control /dev/obd */
}
/* to control /dev/obd */
if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
RETURN(err = -ENOTTY);
if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
RETURN(err = -ENOTTY);
- if (obd_psdev_ops.p_ioctl != NULL)
- err = obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
- else
- err = -EPERM;
+ err = class_handle_ioctl(cmd, (unsigned long)arg);
/* modules setup */
cfs_psdev_t obd_psdev = {
/* modules setup */
cfs_psdev_t obd_psdev = {
- .minor = OBD_MINOR,
- .name = "obd_psdev",
+ .minor = OBD_DEV_MINOR,
+ .name = OBD_DEV_NAME,
.fops = &obd_psdev_fops,
};
.fops = &obd_psdev_fops,
};
}
run_test 103 "acl test ========================================="
}
run_test 103 "acl test ========================================="
touch $DIR/$tfile
lfs df || error "lfs df failed"
lfs df -ih || error "lfs df -ih failed"
touch $DIR/$tfile
lfs df || error "lfs df failed"
lfs df -ih || error "lfs df -ih failed"
lfs df || error "lfs df with reactivated OSC failed"
rm -f $DIR/$tfile
}
lfs df || error "lfs df with reactivated OSC failed"
rm -f $DIR/$tfile
}
-run_test 104 "lfs df [-ih] [path] test ========================="
+run_test 104a "lfs df [-ih] [path] test ========================="
+
+test_104b() {
+ [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+ chmod 666 /dev/obd
+ denied_cnt=$((`$RUNAS $LFS check servers 2>&1 | grep "Permission denied" | wc -l`))
+ if [ $denied_cnt -ne 0 ];
+ then
+ error "lfs check servers test failed"
+ fi
+}
+run_test 104b "$RUNAS lfs check servers test ===================="
test_105a() {
# doesn't work on 2.4 kernels
test_105a() {
# doesn't work on 2.4 kernels