Page MenuHomeFreeBSD

D25969.id75464.diff
No OneTemporary

D25969.id75464.diff

Index: sbin/mount/mount.c
===================================================================
--- sbin/mount/mount.c
+++ sbin/mount/mount.c
@@ -697,9 +697,9 @@
(uintmax_t)sfp->f_syncreads,
(uintmax_t)sfp->f_asyncreads);
if (sfp->f_fsid.val[0] != 0 || sfp->f_fsid.val[1] != 0) {
- printf(", fsid ");
+ (void)printf(", fsid ");
for (i = 0; i < sizeof(sfp->f_fsid); i++)
- printf("%02x", ((u_char *)&sfp->f_fsid)[i]);
+ (void)printf("%02x", ((u_char *)&sfp->f_fsid)[i]);
}
}
(void)printf(")\n");
Index: sys/kern/subr_bus.c
===================================================================
--- sys/kern/subr_bus.c
+++ sys/kern/subr_bus.c
@@ -43,6 +43,7 @@
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/module.h>
+#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/poll.h>
#include <sys/priv.h>
@@ -156,6 +157,7 @@
EVENTHANDLER_LIST_DEFINE(device_detach);
EVENTHANDLER_LIST_DEFINE(dev_lookup);
+static void dev_vfs_init(void);
static void devctl2_init(void);
static bool device_frozen;
@@ -234,7 +236,6 @@
static void
devclass_sysctl_init(devclass_t dc)
{
-
if (dc->sysctl_tree != NULL)
return;
sysctl_ctx_init(&dc->sysctl_ctx);
@@ -448,12 +449,12 @@
TAILQ_INIT(&devsoftc.devq);
knlist_init_mtx(&devsoftc.sel.si_note, &devsoftc.mtx);
devctl2_init();
+ dev_vfs_init();
}
static int
devopen(struct cdev *dev, int oflags, int devtype, struct thread *td)
{
-
mtx_lock(&devsoftc.mtx);
if (devsoftc.inuse) {
mtx_unlock(&devsoftc.mtx);
@@ -468,7 +469,6 @@
static int
devclose(struct cdev *dev, int fflag, int devtype, struct thread *td)
{
-
mtx_lock(&devsoftc.mtx);
devsoftc.inuse = 0;
devsoftc.nonblock = 0;
@@ -522,7 +522,6 @@
devioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
{
switch (cmd) {
-
case FIONBIO:
if (*(int*)data)
devsoftc.nonblock = 1;
@@ -585,7 +584,6 @@
static void
filt_devctl_detach(struct knote *kn)
{
-
knlist_remove(&devsoftc.sel.si_note, kn, 0);
}
@@ -661,7 +659,6 @@
void
devctl_queue_data(char *data)
{
-
devctl_queue_data_f(data, M_NOWAIT);
}
@@ -704,7 +701,6 @@
devctl_notify(const char *system, const char *subsystem, const char *type,
const char *data)
{
-
devctl_notify_f(system, subsystem, type, data, M_NOWAIT);
}
@@ -876,7 +872,6 @@
void
devctl_safe_quote_sb(struct sbuf *sb, const char *src)
{
-
while (*src != '\0') {
if (*src == '"' || *src == '\\')
sbuf_putc(sb, '\\');
@@ -2597,7 +2592,6 @@
void *
device_get_ivars(device_t dev)
{
-
KASSERT(dev != NULL, ("device_get_ivars(NULL, ...)"));
return (dev->ivars);
}
@@ -2608,7 +2602,6 @@
void
device_set_ivars(device_t dev, void * ivars)
{
-
KASSERT(dev != NULL, ("device_set_ivars(NULL, ...)"));
dev->ivars = ivars;
}
@@ -3087,7 +3080,6 @@
int
device_quiesce(device_t dev)
{
-
PDEBUG(("%s", DEVICENAME(dev)));
if (dev->state == DS_BUSY)
return (EBUSY);
@@ -3148,7 +3140,6 @@
void
resource_init_map_request_impl(struct resource_map_request *args, size_t sz)
{
-
bzero(args, sz);
args->size = sz;
args->memattr = VM_MEMATTR_UNCACHEABLE;
@@ -3704,7 +3695,6 @@
device_t
bus_generic_add_child(device_t dev, u_int order, const char *name, int unit)
{
-
return (device_add_child_ordered(dev, order, name, unit));
}
@@ -3852,7 +3842,6 @@
int
bus_generic_resume_child(device_t dev, device_t child)
{
-
DEVICE_RESUME(child);
child->flags &= ~DF_SUSPENDED;
@@ -3944,7 +3933,6 @@
static void
bus_helper_reset_prepare_rollback(device_t dev, device_t child, int flags)
{
-
child = TAILQ_NEXT(child, link);
if (child == NULL)
return;
@@ -4356,7 +4344,6 @@
bus_generic_bind_intr(device_t dev, device_t child, struct resource *irq,
int cpu)
{
-
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
return (BUS_BIND_INTR(dev->parent, child, irq, cpu));
@@ -4373,7 +4360,6 @@
bus_generic_config_intr(device_t dev, int irq, enum intr_trigger trig,
enum intr_polarity pol)
{
-
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
return (BUS_CONFIG_INTR(dev->parent, irq, trig, pol));
@@ -4390,7 +4376,6 @@
bus_generic_describe_intr(device_t dev, device_t child, struct resource *irq,
void *cookie, const char *descr)
{
-
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent)
return (BUS_DESCRIBE_INTR(dev->parent, child, irq, cookie,
@@ -4408,7 +4393,6 @@
bus_generic_get_cpus(device_t dev, device_t child, enum cpu_sets op,
size_t setsize, cpuset_t *cpuset)
{
-
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent != NULL)
return (BUS_GET_CPUS(dev->parent, child, op, setsize, cpuset));
@@ -4424,7 +4408,6 @@
bus_dma_tag_t
bus_generic_get_dma_tag(device_t dev, device_t child)
{
-
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent != NULL)
return (BUS_GET_DMA_TAG(dev->parent, child));
@@ -4440,7 +4423,6 @@
bus_space_tag_t
bus_generic_get_bus_tag(device_t dev, device_t child)
{
-
/* Propagate up the bus hierarchy until someone handles it. */
if (dev->parent != NULL)
return (BUS_GET_BUS_TAG(dev->parent, child));
@@ -4587,7 +4569,6 @@
int
bus_generic_get_domain(device_t dev, device_t child, int *domain)
{
-
if (dev->parent)
return (BUS_GET_DOMAIN(dev->parent, dev, domain));
@@ -4603,7 +4584,6 @@
int
bus_null_rescan(device_t dev)
{
-
return (ENXIO);
}
@@ -5101,7 +5081,6 @@
root_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize,
cpuset_t *cpuset)
{
-
switch (op) {
case INTR_CPUS:
/* Default to returning the set of all CPUs. */
@@ -5182,7 +5161,6 @@
void
root_bus_configure(void)
{
-
PDEBUG(("."));
/* Eventually this will be split up, but this is sufficient for now. */
@@ -5556,7 +5534,6 @@
void
bus_data_generation_update(void)
{
-
atomic_add_int(&bus_data_generation, 1);
}
@@ -5935,6 +5912,141 @@
return (error);
}
+/* Map from mount options to printable formats. */
+static struct flag2opt {
+ unsigned long long o_opt;
+ const char *o_name;
+} optnames[] = {
+ { MNT_ASYNC, "asynchronous" },
+ { MNT_EXPORTED, "NFS-exported" },
+ { MNT_LOCAL, "local" },
+ { MNT_NOATIME, "noatime" },
+ { MNT_NOEXEC, "noexec" },
+ { MNT_NOSUID, "nosuid" },
+ { MNT_NOSYMFOLLOW, "nosymfollow" },
+ { MNT_QUOTA, "with-quotas" },
+ { MNT_RDONLY, "read-only" },
+ { MNT_SYNCHRONOUS, "synchronous" },
+ { MNT_UNION, "union" },
+ { MNT_NOCLUSTERR, "noclusterr" },
+ { MNT_NOCLUSTERW, "noclusterw" },
+ { MNT_SUIDDIR, "suiddir" },
+ { MNT_SOFTDEP, "soft-updates" },
+ { MNT_SUJ, "journaled soft-updates" },
+ { MNT_MULTILABEL, "multilabel" },
+ { MNT_ACLS, "acls" },
+ { MNT_NFS4ACLS, "nfsv4acls" },
+ { MNT_GJOURNAL, "gjournal" },
+ { MNT_AUTOMOUNTED, "automounted" },
+ { MNT_VERIFIED, "verified" },
+ { MNT_UNTRUSTED, "untrusted" },
+ { MNT_NOCOVER, "nocover" },
+ { MNT_EMPTYDIR, "emptydir" },
+ { MNT_UPDATE, "update" },
+ { MNT_DELEXPORT, "delexport" },
+ { MNT_RELOAD, "reload" },
+ { MNT_FORCE, "force" },
+ { MNT_SNAPSHOT, "snapshot" },
+ { 0, NULL }
+};
+
+static void
+dev_vfs_event_mntopt(struct sbuf *sb, const char *what, struct vfsoptlist *opts)
+{
+ struct vfsopt *opt;
+
+ if (opts == NULL || TAILQ_EMPTY(opts))
+ return;
+ sbuf_printf(sb, " %s=\"", what);
+ TAILQ_FOREACH(opt, opts, link) {
+ /* Skip options with no name, but why are they here? */
+ if (opt->name[0] == '\0') {
+ printf("Skipping empty\n");
+ continue;
+ }
+ devctl_safe_quote_sb(sb, opt->name);
+ if (opt->len > 0) {
+ sbuf_putc(sb, '=');
+ devctl_safe_quote_sb(sb, opt->value);
+ }
+ sbuf_putc(sb, ';');
+ }
+ sbuf_putc(sb, '"');
+}
+
+
+static void
+dev_vfs_event(const char *type, struct mount *mp, bool donew)
+{
+ const uint8_t *cp;
+ struct flag2opt *fp;
+ struct sbuf *sb;
+ struct statfs *sfp = &mp->mnt_stat;
+ bool comma = false;
+
+ sb = sbuf_new_auto();
+ sbuf_cpy(sb, "mount-point=\"");
+ devctl_safe_quote_sb(sb, sfp->f_mntonname);
+ sbuf_cat(sb, "\" mount-dev=\"");
+ devctl_safe_quote_sb(sb, sfp->f_mntfromname);
+ sbuf_cat(sb, "\" mount-type=\"");
+ devctl_safe_quote_sb(sb, sfp->f_fstypename);
+ sbuf_cat(sb, "\" fsid=0x");
+ cp = (const uint8_t *)&sfp->f_fsid.val[0];
+ for (int i = 0; i < sizeof(sfp->f_fsid); i++)
+ sbuf_printf(sb, "%02x", cp[i]);
+ sbuf_printf(sb, " owner=%u flags=\"", sfp->f_owner);
+ for (fp = optnames; fp->o_opt != 0; fp++) {
+ if (mp->mnt_flag & fp->o_opt) {
+ if (comma)
+ sbuf_putc(sb, ',');
+ comma = true;
+ sbuf_cat(sb, fp->o_name);
+ }
+ }
+ sbuf_putc(sb, '"');
+ dev_vfs_event_mntopt(sb, "opt", mp->mnt_opt);
+ if (donew)
+ dev_vfs_event_mntopt(sb, "optnew", mp->mnt_optnew);
+ sbuf_finish(sb);
+
+ devctl_notify("VFS", "FS", type, sbuf_data(sb));
+ printf("%s: %s\n", type, sbuf_data(sb));
+ sbuf_delete(sb);
+}
+
+static void
+dev_vfs_mounted(void *arg __unused, struct mount *mp,
+ struct vnode *fsrootvp __unused, struct thread *td __unused)
+{
+ dev_vfs_event("MOUNT", mp, false);
+}
+
+static void
+dev_vfs_remounted(void *arg __unused, struct mount *mp,
+ struct thread *td __unused)
+{
+ dev_vfs_event("REMOUNT", mp, true);
+}
+
+static void
+dev_vfs_unmounted(void *arg __unused, struct mount *mp,
+ struct thread *td __unused)
+{
+ dev_vfs_event("UNMOUNT", mp, false);
+}
+
+static void
+dev_vfs_init(void)
+{
+ EVENTHANDLER_REGISTER(vfs_mounted, dev_vfs_mounted, NULL,
+ EVENTHANDLER_PRI_ANY);
+ EVENTHANDLER_REGISTER(vfs_remounted, dev_vfs_remounted, NULL,
+ EVENTHANDLER_PRI_ANY);
+ EVENTHANDLER_REGISTER(vfs_unmounted, dev_vfs_unmounted, NULL,
+ EVENTHANDLER_PRI_ANY);
+}
+
static struct cdevsw devctl2_cdevsw = {
.d_version = D_VERSION,
.d_ioctl = devctl2_ioctl,
@@ -5944,7 +6056,6 @@
static void
devctl2_init(void)
{
-
make_dev_credf(MAKEDEV_ETERNAL, &devctl2_cdevsw, 0, NULL,
UID_ROOT, GID_WHEEL, 0600, "devctl2");
}
@@ -5960,7 +6071,6 @@
static void
gone_panic(int major, int running, const char *msg)
{
-
switch (obsolete_panic)
{
case 0:
@@ -5977,7 +6087,6 @@
void
_gone_in(int major, const char *msg)
{
-
gone_panic(major, P_OSREL_MAJOR(__FreeBSD_version), msg);
if (P_OSREL_MAJOR(__FreeBSD_version) >= major)
printf("Obsolete code will be removed soon: %s\n", msg);
@@ -5989,7 +6098,6 @@
void
_gone_in_dev(device_t dev, int major, const char *msg)
{
-
gone_panic(major, P_OSREL_MAJOR(__FreeBSD_version), msg);
if (P_OSREL_MAJOR(__FreeBSD_version) >= major)
device_printf(dev,
Index: sys/kern/vfs_mount.c
===================================================================
--- sys/kern/vfs_mount.c
+++ sys/kern/vfs_mount.c
@@ -99,6 +99,7 @@
MTX_SYSINIT(mountlist, &mountlist_mtx, "mountlist", MTX_DEF);
EVENTHANDLER_LIST_DEFINE(vfs_mounted);
+EVENTHANDLER_LIST_DEFINE(vfs_remounted);
EVENTHANDLER_LIST_DEFINE(vfs_unmounted);
/*
@@ -1221,6 +1222,7 @@
if (error != 0)
goto end;
+ EVENTHANDLER_DIRECT_INVOKE(vfs_remounted, mp, td);
if (mp->mnt_opt != NULL)
vfs_freeopts(mp->mnt_opt);
mp->mnt_opt = mp->mnt_optnew;
Index: sys/sys/eventhandler.h
===================================================================
--- sys/sys/eventhandler.h
+++ sys/sys/eventhandler.h
@@ -216,9 +216,12 @@
struct thread;
typedef void (*vfs_mounted_notify_fn)(void *, struct mount *, struct vnode *,
struct thread *);
+typedef void (*vfs_remounted_notify_fn)(void *, struct mount *,
+ struct thread *);
typedef void (*vfs_unmounted_notify_fn)(void *, struct mount *,
struct thread *);
EVENTHANDLER_DECLARE(vfs_mounted, vfs_mounted_notify_fn);
+EVENTHANDLER_DECLARE(vfs_remounted, vfs_remounted_notify_fn);
EVENTHANDLER_DECLARE(vfs_unmounted, vfs_unmounted_notify_fn);
/*

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 31, 2:38 AM (10 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30574432
Default Alt Text
D25969.id75464.diff (11 KB)

Event Timeline