handle_swapfiles(true);
- hotplug_call_mount("add", device);
+ if (type != TYPE_AUTOFS)
+ hotplug_call_mount("add", device);
return 0;
}
-static int umount_device(char *path)
+static int umount_device(char *path, int type)
{
char *mp;
int err;
if (!mp)
return -1;
- hotplug_call_mount("remove", basename(path));
+ if (type != TYPE_AUTOFS)
+ hotplug_call_mount("remove", basename(path));
err = umount2(mp, MNT_DETACH);
if (err) {
if (type == TYPE_HOTPLUG)
blockd_notify(device, NULL, NULL);
- umount_device(path);
+ umount_device(path, type);
return 0;
} else if (strcmp(action, "add")) {
static int main_autofs(int argc, char **argv)
{
+ int err = 0;
+
if (argc < 3)
return -1;
blockd_notify(pr->dev, m, pr);
}
- return 0;
+ } else if (!strcmp(argv[2], "available")) {
+ err = hotplug_call_mount("add", argv[3]);
+ } else if (!strcmp(argv[2], "unavailable")) {
+ err = hotplug_call_mount("remove", argv[3]);
+ } else {
+ if (argc < 4)
+ return -EINVAL;
+
+ err = mount_action(argv[2], argv[3], TYPE_AUTOFS);
}
- if (argc < 4)
- return -EINVAL;
+ if (err) {
+ ULOG_ERR("autofs: \"%s\" action has failed: %d\n", argv[2], err);
+ }
- return mount_action(argv[2], argv[3], TYPE_AUTOFS);
+ return err;
}
static int find_block_mtd(char *name, char *part, int plen)
if (m && m->extroot)
continue;
- umount_device(pr->dev);
+ umount_device(pr->dev, TYPE_DEV);
}
return 0;
if (!device->autofs)
return;
+ block("autofs", "unavailable", device->name);
+
if (device->target)
unlink(device->target);
snprintf(path, sizeof(path), "/tmp/run/blockd/%s", device->name);
if (symlink(path, device->target))
ULOG_ERR("failed to symlink %s->%s\n", device->target, path);
+ else
+ block("autofs", "available", device->name);
}
static int