Provide a set of sysctls and tunables to disable device node creation

for specific "kinds" of disk labels - for example, GPT UUIDs.  Reason
for this is that sometimes, other GEOM classes attach to these device
nodes instead of the proper ones - e.g. they attach to /dev/gptid/XXX
instead of /dev/ada0p2, which is annoying.

Reviewed by:	pjd (earlier version)
MFC after:	1 month
This commit is contained in:
Edward Tomasz Napierala 2009-11-28 11:57:43 +00:00
parent ea74c11fae
commit 3ce9ca8947
9 changed files with 68 additions and 29 deletions

View File

@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/bio.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/libkern.h>
#include <geom/geom.h>
@ -316,6 +315,8 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
for (i = 0; g_labels[i] != NULL; i++) {
char label[64];
if (g_labels[i]->ld_enabled == 0)
continue;
g_topology_unlock();
g_labels[i]->ld_taste(cp, label, sizeof(label));
g_topology_lock();

View File

@ -30,6 +30,9 @@
#define _G_LABEL_H_
#include <sys/endian.h>
#ifdef _KERNEL
#include <sys/sysctl.h>
#endif
#define G_LABEL_CLASS_NAME "LABEL"
@ -56,23 +59,34 @@ extern u_int g_label_debug;
} \
} while (0)
SYSCTL_DECL(_kern_geom_label);
#define G_LABEL_INIT(kind, label, descr) \
SYSCTL_NODE(_kern_geom_label, OID_AUTO, kind, CTLFLAG_RD, \
NULL, ""); \
SYSCTL_INT(_kern_geom_label_##kind, OID_AUTO, enable, \
CTLFLAG_RW, &label.ld_enabled, 1, descr); \
TUNABLE_INT("kern.geom.label." __XSTRING(kind) ".enable", \
&label.ld_enabled)
typedef void g_label_taste_t (struct g_consumer *cp, char *label, size_t size);
struct g_label_desc {
g_label_taste_t *ld_taste;
char *ld_dir;
int ld_enabled;
};
/* Supported labels. */
extern const struct g_label_desc g_label_ufs_id;
extern const struct g_label_desc g_label_ufs_volume;
extern const struct g_label_desc g_label_iso9660;
extern const struct g_label_desc g_label_msdosfs;
extern const struct g_label_desc g_label_ext2fs;
extern const struct g_label_desc g_label_reiserfs;
extern const struct g_label_desc g_label_ntfs;
extern const struct g_label_desc g_label_gpt;
extern const struct g_label_desc g_label_gpt_uuid;
extern struct g_label_desc g_label_ufs_id;
extern struct g_label_desc g_label_ufs_volume;
extern struct g_label_desc g_label_iso9660;
extern struct g_label_desc g_label_msdosfs;
extern struct g_label_desc g_label_ext2fs;
extern struct g_label_desc g_label_reiserfs;
extern struct g_label_desc g_label_ntfs;
extern struct g_label_desc g_label_gpt;
extern struct g_label_desc g_label_gpt_uuid;
#endif /* _KERNEL */
struct g_label_metadata {

View File

@ -86,7 +86,10 @@ g_label_ext2fs_taste(struct g_consumer *cp, char *label, size_t size)
g_free(fs);
}
const struct g_label_desc g_label_ext2fs = {
struct g_label_desc g_label_ext2fs = {
.ld_taste = g_label_ext2fs_taste,
.ld_dir = "ext2fs"
.ld_dir = "ext2fs",
.ld_enabled = 1
};
G_LABEL_INIT(ext2fs, g_label_ext2fs, "Create device nodes for EXT2FS volumes");

View File

@ -153,12 +153,17 @@ g_label_gpt_uuid_taste(struct g_consumer *cp, char *label, size_t size)
snprintf_uuid(label, size, &part_gpt_entry->ent.ent_uuid);
}
const struct g_label_desc g_label_gpt = {
struct g_label_desc g_label_gpt = {
.ld_taste = g_label_gpt_taste,
.ld_dir = G_LABEL_GPT_VOLUME_DIR
.ld_dir = G_LABEL_GPT_VOLUME_DIR,
.ld_enabled = 1
};
const struct g_label_desc g_label_gpt_uuid = {
struct g_label_desc g_label_gpt_uuid = {
.ld_taste = g_label_gpt_uuid_taste,
.ld_dir = G_LABEL_GPT_ID_DIR
.ld_dir = G_LABEL_GPT_ID_DIR,
.ld_enabled = 1
};
G_LABEL_INIT(gpt, g_label_gpt, "Create device nodes for GPT labels");
G_LABEL_INIT(gptid, g_label_gpt_uuid, "Create device nodes for GPT UUIDs");

View File

@ -78,7 +78,10 @@ g_label_iso9660_taste(struct g_consumer *cp, char *label, size_t size)
}
}
const struct g_label_desc g_label_iso9660 = {
struct g_label_desc g_label_iso9660 = {
.ld_taste = g_label_iso9660_taste,
.ld_dir = G_LABEL_ISO9660_DIR
.ld_dir = G_LABEL_ISO9660_DIR,
.ld_enabled = 1
};
G_LABEL_INIT(iso9660, g_label_iso9660, "Create device nodes for ISO9660 volume names");

View File

@ -216,7 +216,10 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size)
g_free(sector);
}
const struct g_label_desc g_label_msdosfs = {
struct g_label_desc g_label_msdosfs = {
.ld_taste = g_label_msdosfs_taste,
.ld_dir = G_LABEL_MSDOSFS_DIR
.ld_dir = G_LABEL_MSDOSFS_DIR,
.ld_enabled = 1
};
G_LABEL_INIT(msdosfs, g_label_msdosfs, "Create device nodes for MSDOSFS volumes");

View File

@ -114,7 +114,10 @@ g_label_ntfs_taste(struct g_consumer *cp, char *label, size_t size)
g_free(filerecp);
}
const struct g_label_desc g_label_ntfs = {
struct g_label_desc g_label_ntfs = {
.ld_taste = g_label_ntfs_taste,
.ld_dir = G_LABEL_NTFS_DIR
.ld_dir = G_LABEL_NTFS_DIR,
.ld_enabled = 1
};
G_LABEL_INIT(ntfs, g_label_ntfs, "Create device nodes for NTFS volumes");

View File

@ -111,7 +111,10 @@ g_label_reiserfs_taste(struct g_consumer *cp, char *label, size_t size)
g_free(fs);
}
const struct g_label_desc g_label_reiserfs = {
struct g_label_desc g_label_reiserfs = {
.ld_taste = g_label_reiserfs_taste,
.ld_dir = "reiserfs"
.ld_dir = "reiserfs",
.ld_enabled = 1
};
G_LABEL_INIT(reiserfs, g_label_reiserfs, "Create device nodes for REISERFS volumes");

View File

@ -137,13 +137,17 @@ g_label_ufs_id_taste(struct g_consumer *cp, char *label, size_t size)
g_label_ufs_taste_common(cp, label, size, G_LABEL_UFS_ID);
}
const struct g_label_desc g_label_ufs_volume = {
struct g_label_desc g_label_ufs_volume = {
.ld_taste = g_label_ufs_volume_taste,
.ld_dir = G_LABEL_UFS_VOLUME_DIR
.ld_dir = G_LABEL_UFS_VOLUME_DIR,
.ld_enabled = 1
};
const struct g_label_desc g_label_ufs_id = {
struct g_label_desc g_label_ufs_id = {
.ld_taste = g_label_ufs_id_taste,
.ld_dir = G_LABEL_UFS_ID_DIR
.ld_dir = G_LABEL_UFS_ID_DIR,
.ld_enabled = 1
};
G_LABEL_INIT(ufsid, g_label_ufs_id, "Create device nodes for UFS file system IDs");
G_LABEL_INIT(ufs, g_label_ufs_volume, "Create device nodes for UFS volume names");