#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/kthread.h>
-#include <linux/miscdevice.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
/* FIXME - rename these to libcfs_ */
int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf, int max);
void libcfs_ioctl_unpack(struct libcfs_ioctl_data *data, char *pbuf);
-int register_ioc_dev(int dev_id, const char *dev_name, int major, int minor);
+int register_ioc_dev(int dev_id, const char *dev_name);
void unregister_ioc_dev(int dev_id);
int l_ioctl(int dev_id, unsigned int opc, void *buf);
#endif
#include <linux/fs.h>
#include <linux/stat.h>
#include <asm/uaccess.h>
-#include <linux/miscdevice.h>
#include <linux/version.h>
# define DEBUG_SUBSYSTEM S_LNET
#define DEBUG_SUBSYSTEM S_LNET
+#include <linux/miscdevice.h>
#include <libcfs/libcfs.h>
-#define LNET_MINOR 240
-
static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
{
size_t len = sizeof(*data);
};
struct miscdevice libcfs_dev = {
- .minor = LNET_MINOR,
+ .minor = MISC_DYNAMIC_MINOR,
.name = "lnet",
.fops = &libcfs_fops
};
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
+#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/lnet/lnetctl.h>
struct ioc_dev {
- const char * dev_name;
- int dev_fd;
- int dev_major;
- int dev_minor;
+ const char *dev_name;
+ int dev_fd;
};
static struct ioc_dev ioc_dev_list[10];
-struct dump_hdr {
- int magic;
- int dev_id;
- unsigned int opc;
-};
-
-/* Catamount has no <linux/kdev_t.h>, so just define it here */
-#ifndef MKDEV
-# define MKDEV(a,b) (((a) << 8) | (b))
-#endif
-
static int
open_ioc_dev(int dev_id)
{
if (ioc_dev_list[dev_id].dev_fd < 0) {
int fd = open(dev_name, O_RDWR);
- /* Make the /dev/ node if we need to */
- if (fd < 0 && errno == ENOENT) {
- if (mknod(dev_name, S_IFCHR|S_IWUSR|S_IRUSR,
- MKDEV(ioc_dev_list[dev_id].dev_major,
- ioc_dev_list[dev_id].dev_minor)) == 0)
- fd = open(dev_name, O_RDWR);
- else
- fprintf(stderr, "mknod %s failed: %s\n",
- dev_name, strerror(errno));
- }
-
if (fd < 0) {
fprintf(stderr, "opening %s failed: %s\n"
"hint: the kernel modules may not be loaded\n",
/* register a device to send ioctls to. */
int
-register_ioc_dev(int dev_id, const char *dev_name, int major, int minor)
+register_ioc_dev(int dev_id, const char *dev_name)
{
-
if (dev_id < 0 ||
dev_id >= sizeof(ioc_dev_list) / sizeof(ioc_dev_list[0]))
return -EINVAL;
ioc_dev_list[dev_id].dev_name = dev_name;
ioc_dev_list[dev_id].dev_fd = -1;
- ioc_dev_list[dev_id].dev_major = major;
- ioc_dev_list[dev_id].dev_minor = minor;
return dev_id;
}
#define LNET_DEV_ID 0
#define LNET_DEV_PATH "/dev/lnet"
-#define LNET_DEV_MAJOR 10
-#define LNET_DEV_MINOR 240
#endif
int lustre_lnet_config_lib_init(void)
{
- return register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH,
- LNET_DEV_MAJOR, LNET_DEV_MINOR);
+ return register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH);
}
void lustre_lnet_config_lib_uninit(void)
#ifdef USE_DLC
rc = lustre_lnet_config_lib_init();
#else
- rc = register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH,
- LNET_DEV_MAJOR, LNET_DEV_MINOR);
+ rc = register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH);
#endif
if (rc < 0)
goto errorout;
#define OBD_DEV_ID 1
#define OBD_DEV_NAME "obd"
#define OBD_DEV_PATH "/dev/" OBD_DEV_NAME
-#define OBD_DEV_MAJOR 10
-#define OBD_DEV_MINOR 241
#define OBD_IOCTL_VERSION 0x00010004
#define OBD_DEV_BY_DEVNAME 0xffffd0de
#define DEBUG_SUBSYSTEM S_CLASS
+#include <linux/miscdevice.h>
#include <linux/user_namespace.h>
#ifdef HAVE_UIDGID_HEADER
# include <linux/uidgid.h>
err = misc_register(&obd_psdev);
if (err) {
- CERROR("cannot register %d err %d\n", OBD_DEV_MINOR, err);
+ CERROR("cannot register OBD miscdevice: err = %d\n", err);
goto cleanup_class_handle;
}
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
-#include <linux/major.h>
#include <linux/sched.h>
#include <linux/lp.h>
#include <linux/slab.h>
/* modules setup */
struct miscdevice obd_psdev = {
- .minor = OBD_DEV_MINOR,
- .name = OBD_DEV_NAME,
- .fops = &obd_psdev_fops,
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = OBD_DEV_NAME,
+ .fops = &obd_psdev_fops,
};
static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
/* This plumbing is needed for some of the ioctls behind
llapi calls to work. */
- register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH,
- OBD_DEV_MAJOR, OBD_DEV_MINOR);
+ register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH);
rc = lr_locate_rsync();
if (use_rsync && rc != 0) {
if (shmem_setup() != 0)
return -1;
- register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH,
- OBD_DEV_MAJOR, OBD_DEV_MINOR);
+ register_ioc_dev(OBD_DEV_ID, OBD_DEV_PATH);
return 0;
}
if (argc > 1)
g_net_interactive = true;
- register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH,
- LNET_DEV_MAJOR, LNET_DEV_MINOR);
+ register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH);
+
return 0;
}