{
struct mount *mount;
char tmp[64], tmp2[64];
- if(fs <= MBR || fs > LASTFS)
- return;
+
mount = malloc(sizeof(struct mount));
INIT_LIST_HEAD(&mount->list);
strncpy(mount->vendor, vendor, 64);
mount->mounted = 0;
mount->fs = fs;
list_add(&mount->list, &mounts);
- if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= LASTFS))
+ if (!mount->ignore)
{
log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
snprintf(tmp, 64, "%s%s", uci_path, name);
snprintf(tmp2, 64, "/tmp/run/mountd/%s", dev);
symlink(tmp2, tmp);
- mount_new("/tmp/run/mountd/", dev);
- system_printf("ACTION=add DEVICE=%s NAME=%s /sbin/hotplug-call mount", dev, name);
+ if (!mount_new("/tmp/run/mountd/", dev))
+ system_printf("ACTION=add DEVICE=%s NAME=%s /sbin/hotplug-call mount", dev, name);
}
}
pid = waitpid(pid, &ret, 0);
ret = WEXITSTATUS(ret);
log_printf("----------> mount ret = %d\n", ret);
- if(ret && (ret != 0xff))
+ if (ret && ret != 0xff) {
+ rmdir(tmp);
return -1;
+ }
if(mount_wait_for_disc(mount->dev) == 0)
{
mount->mounted = 1;
char sector_size[64];
FILE *fp;
int offset = 3;
+ int fs;
strcpy(name, dev);
if (!strncmp(name, "mmcblk", 6))
fclose(fp);
}
snprintf(tmp, 64, "/dev/%s", dev);
- mount_add_list(node, dev, s, vendor, model, rev, ignore, size, sector_size, detect_fs(tmp));
+ fs = detect_fs(tmp);
+ if (fs <= MBR || fs > LASTFS) {
+ ignore = 1;
+ }
+ mount_add_list(node, dev, s, vendor, model, rev, ignore, size, sector_size, fs);
mount_dump_uci_state();
}
}
p->next->prev = p->prev;
p = p->next;
log_printf("removing %s\n", q->dev);
- snprintf(tmp, 64, "%s%s", "/tmp/run/mountd/", q->dev);
- rmdir(tmp);
- snprintf(tmp, 64, "%s%s", uci_path, q->name);
- unlink(tmp);
- system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
+ if (q->mounted) {
+ snprintf(tmp, 64, "%s%s", "/tmp/run/mountd/", q->dev);
+ rmdir(tmp);
+ snprintf(tmp, 64, "%s%s", uci_path, q->name);
+ unlink(tmp);
+ system_printf("ACTION=remove DEVICE=%s NAME=%s /sbin/hotplug-call mount", q->dev, q->name);
+ }
free(q);
mount_dump_uci_state();
system_printf("/etc/fonstated/ReloadSamba");