#include <libgen.h>
#include <poll.h>
#include <dirent.h>
+#include <syslog.h>
#include "include/log.h"
#include "include/list.h"
char *fs_names[] = {
"",
"",
- "MBR",
- "EXT2",
- "EXT3",
- "FAT",
- "HFSPLUS",
+ "mbr",
+ "ext2",
+ "ext3",
+ "fat",
+ "hfsplus",
"",
- "NTFS",
+ "ntfs",
"",
- "EXT4"
+ "exfat",
+ "ext4"
};
#define MAX_MOUNTED 32
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);
}
}
pid = autofs_safe_fork();
if(!pid)
{
+ char *options, *fstype;
+ if(mount->fs == EXFAT)
+ {
+ options = "rw,uid=1000,gid=1000";
+ fstype = "exfat";
+ }
if(mount->fs == FAT)
{
- log_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
- ret = system_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ options = "rw,uid=1000,gid=1000";
+ fstype = "vfat";
}
if(mount->fs == EXT4)
{
- log_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
- ret = system_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
+ options = "rw,defaults";
+ fstype = "ext4";
}
if(mount->fs == EXT3)
{
- log_printf("mount -t ext3 -o rw,defaults /dev/%s %s", mount->dev, tmp);
- ret = system_printf("mount -t ext3 -o rw,defaults /dev/%s %s", mount->dev, tmp);
+ options = "rw,defaults";
+ fstype = "ext3";
}
if(mount->fs == EXT2)
{
- log_printf("mount -t ext2 -o rw,defaults /dev/%s %s", mount->dev, tmp);
- ret = system_printf("mount -t ext2 -o rw,defaults /dev/%s %s", mount->dev, tmp);
+ options = "rw,defaults";
+ fstype = "ext2";
}
if(mount->fs == HFSPLUS)
{
- log_printf("mount -t hfsplus -o rw,defaults,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
- ret = system_printf("mount -t hfsplus -o rw,defaults,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+ options = "rw,defaults,uid=1000,gid=1000";
+ fstype = "hfsplus";
}
if(mount->fs == NTFS)
{
- log_printf("ntfs-3g /dev/%s %s -o force", mount->dev, tmp);
- ret = system_printf("ntfs-3g /dev/%s %s -o force", mount->dev, tmp);
+ options = "force";
+ fstype = "ntfs-3g";
+ }
+ if(mount->fs > MBR && mount->fs <= EXT4)
+ {
+ struct uci_context *ctx;
+ char *uci_options, *uci_fstype;
+ ctx = ucix_init("mountd");
+ if(fs_names[mount->fs])
+ {
+ uci_options = ucix_get_option(ctx, "mountd", fs_names[mount->fs], "options");
+ uci_fstype = ucix_get_option(ctx, "mountd", fs_names[mount->fs], "fstype");
+ if(uci_options)
+ options = uci_options;
+ if(uci_fstype)
+ fstype = uci_fstype;
+ log_printf("mount -t %s -o %s /dev/%s %s", fstype, options, mount->dev, tmp);
+ ret = system_printf("mount -t %s -o %s /dev/%s %s", fstype, options, mount->dev, tmp);
+ }
+ ucix_cleanup(ctx);
}
exit(WEXITSTATUS(ret));
}
static struct hd_driveid hd;
int i;
static char *serial;
+ static char disc_id[13];
snprintf(tmp, 64, "/dev/%s", dev);
disc = open(tmp, O_RDONLY);
if(!disc)
unsigned int *u = (unsigned int*) uniq;
int l = strlen(serial);
int i;
- static char disc_id[13];
memset(disc_id, 0, 13);
memset(uniq, 0, 6);
for(i = 0; i < l; i++)
//log_printf("Serial number - %s %s\n", serial, disc_id);
return disc_id;
}
- return 0;
+ sprintf(disc_id, "000000000000");
+ return disc_id;
}
static void mount_dev_add(char *dev)
char size[64];
char sector_size[64];
FILE *fp;
+ int offset = 3;
+
strcpy(name, dev);
- name[3] = '\0';
+ if (!strncmp(name, "mmcblk", 6))
+ offset = 7;
+ name[offset] = '\0';
s = mount_get_serial(name);
- if(!s)
+ if(!s) {
return;
- snprintf(tmp, 64, "part%s", &dev[3]);
- snprintf(node, 64, "Disc-%s", &dev[2]);
- if(node[5] >= 'a' && node[5] <= 'z')
+ }
+ if (!strncmp(name, "mmcblk", 6)) {
+ snprintf(tmp, 64, "part%s", &dev[8]);
+ snprintf(node, 64, "SD-P%s", &dev[8]);
+
+ } else {
+ snprintf(tmp, 64, "part%s", &dev[3]);
+ snprintf(node, 64, "USB-%s", &dev[2]);
+ }
+ if(node[4] >= 'a' && node[4] <= 'z')
{
- node[5] -= 'a';
- node[5] += 'A';
+ node[4] -= 'a';
+ node[4] += 'A';
}
ctx = ucix_init("mountd");
p = ucix_get_option(ctx, "mountd", s, tmp);
/* FIXME: we need more intelligence here */
static int dir_filter2(const struct dirent *a)
{
- if(/*strcmp(a->d_name, "sda") &&*/(!strncmp(a->d_name, "sd", 2)))
+ if(!strncmp(a->d_name, "mmcblk", 6) || !strncmp(a->d_name, "sd", 2))
return 1;
return 0;
}
log_printf("removing %s\n", q->dev);
snprintf(tmp, 64, "%s%s", uci_path, q->name);
unlink(tmp);
- system_printf("/etc/mountd/event remove %s %s", q->dev, q->name);
+ 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");