Re: [OpenWrt-Devel] [PATCH mountd 2/2] support for disk without partition table

2016-06-23 Thread Olivier Hardouin
I have a USB flash drive fat32 formatted without any partition table.
I agree this is unusual nowadays (manufacturers usually put a
partition table on their devices), but as it mounts ok on my laptop, I
wanted the same behavior.


On Thu, Jun 23, 2016 at 9:24 AM, John Crispin  wrote:
>
>
> On 22/06/2016 09:51, olivier.hardo...@gmail.com wrote:
>> if no partition found, try to mount the block device itself
>>
>> Signed-off-by: Olivier Hardouin 
>
> Hi,
>
> looks ok, just wondering what kind of storage you see this on. i have
> only seen superfloppy type formating on mmc cards and that is almost a
> decade ago.
>
> John
>
>> ---
>>  mount.c | 14 ++
>>  1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/mount.c b/mount.c
>> index 0c2862a..7cbb8ff 100644
>> --- a/mount.c
>> +++ b/mount.c
>> @@ -693,13 +693,19 @@ static void mount_enum_drives(void)
>>   char tmp[64];
>>   snprintf(tmp, 64, "/sys/block/%s/", 
>> namelist[n]->d_name);
>>   m = scandir(tmp, &namelist2, dir_filter2, 
>> dir_sort);
>> - while(m--)
>> + if(m > 0)
>>   {
>> - strncpy(&block[blk_cnt][0], 
>> namelist2[m]->d_name, MAX_BLOCK);
>> + while(m--)
>> + {
>> + strncpy(&block[blk_cnt][0], 
>> namelist2[m]->d_name, MAX_BLOCK);
>> + blk_cnt++;
>> + free(namelist2[m]);
>> + }
>> + free(namelist2);
>> + } else {
>> + strncpy(&block[blk_cnt][0], 
>> namelist[n]->d_name, MAX_BLOCK);
>>   blk_cnt++;
>> - free(namelist2[m]);
>>   }
>> - free(namelist2);
>>   }
>>   free(namelist[n]);
>>   }
>>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH mountd 2/2] support for disk without partition table

2016-06-22 Thread olivier . hardouin
if no partition found, try to mount the block device itself

Signed-off-by: Olivier Hardouin 
---
 mount.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mount.c b/mount.c
index 0c2862a..7cbb8ff 100644
--- a/mount.c
+++ b/mount.c
@@ -693,13 +693,19 @@ static void mount_enum_drives(void)
char tmp[64];
snprintf(tmp, 64, "/sys/block/%s/", 
namelist[n]->d_name);
m = scandir(tmp, &namelist2, dir_filter2, 
dir_sort);
-   while(m--)
+   if(m > 0)
{
-   strncpy(&block[blk_cnt][0], 
namelist2[m]->d_name, MAX_BLOCK);
+   while(m--)
+   {
+   strncpy(&block[blk_cnt][0], 
namelist2[m]->d_name, MAX_BLOCK);
+   blk_cnt++;
+   free(namelist2[m]);
+   }
+   free(namelist2);
+   } else {
+   strncpy(&block[blk_cnt][0], 
namelist[n]->d_name, MAX_BLOCK);
blk_cnt++;
-   free(namelist2[m]);
}
-   free(namelist2);
}
free(namelist[n]);
}
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH mountd 1/2] hfs+ journal partition support as read only

2016-06-22 Thread olivier . hardouin
use hfsplus driver to mount hfs+ partition marked as journalled,
read only mounting since partial support from the kernel for write 
access (as stated in Documentatiom/filesystems/hfsplus.txt)
add new index 'LASTFS' to be used in case of support for another
driver

Signed-off-by: Olivier Hardouin 
---
 fs.c |  4 ++--
 include/fs.h | 25 ++---
 mount.c  | 16 +++-
 3 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/fs.c b/fs.c
index fee6608..ca77a76 100644
--- a/fs.c
+++ b/fs.c
@@ -153,8 +153,8 @@ static int detect_hfsplus(int fd)
{
if(!journal)
ret = HFSPLUS;
-   //  else
-   //  ret = HFSPLUSJOURNAL;
+   else
+   ret = HFSPLUSJOURNAL;
}
 out:
free(buffer);
diff --git a/include/fs.h b/include/fs.h
index 1c66db3..b86f383 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -1,13 +1,16 @@
-#define NONE   -1
-#define MBR2
-#define EXT2   3
-#define EXT3   4
-#define FAT5
-#define HFSPLUS6
-#define EFI7
-#define NTFS   8
-#define EXTENDED   9
-#define EXFAT  10
-#define EXT4   11
+#define NONE   -1
+#define MBR2
+#define EXT2   3
+#define EXT3   4
+#define FAT5
+#define HFSPLUS6
+#define EFI7
+#define NTFS   8
+#define EXTENDED   9
+#define EXFAT  10
+#define EXT4   11
+#define HFSPLUSJOURNAL 12
+
+#define LASTFS HFSPLUSJOURNAL
 
 int detect_fs(char *device);
diff --git a/mount.c b/mount.c
index 219146b..0c2862a 100644
--- a/mount.c
+++ b/mount.c
@@ -60,7 +60,8 @@ char *fs_names[] = {
"ntfs",
"",
"exfat",
-   "ext4"
+   "ext4",
+   "hfsplusjournal"
 };
 
 #define MAX_MOUNTED32
@@ -100,7 +101,7 @@ static void mount_dump_uci_state(void)
ucix_add_option(ctx, mountd, q->serial, "rev", q->rev);
snprintf(t, 64, "size%d", atoi(&q->dev[3]));
ucix_add_option(ctx, mountd, q->serial, t, q->size);
-   if(q->fs > MBR && q->fs <= EXT4)
+   if(q->fs > MBR && q->fs <= LASTFS)
{
snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
ucix_add_option(ctx, mountd, q->serial, t, 
fs_names[q->fs]);
@@ -138,7 +139,7 @@ static void mount_add_list(char *name, char *dev, char 
*serial,
 {
struct mount *mount;
char tmp[64], tmp2[64];
-   if(fs <= MBR || fs > EXT4)
+   if(fs <= MBR || fs > LASTFS)
return;
mount  = malloc(sizeof(struct mount));
INIT_LIST_HEAD(&mount->list);
@@ -154,7 +155,7 @@ static void mount_add_list(char *name, char *dev, char 
*serial,
mount->mounted = 0;
mount->fs = fs;
list_add(&mount->list, &mounts);
-   if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= EXT4))
+   if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= LASTFS))
{
log_printf("new mount : %s -> %s (%s)\n", name, dev, 
fs_names[mount->fs]);
snprintf(tmp, 64, "%s%s", uci_path, name);
@@ -260,12 +261,17 @@ int mount_new(char *path, char *dev)
options = "rw,defaults,uid=1000,gid=1000";
fstype = "hfsplus";
}
+   if(mount->fs == HFSPLUSJOURNAL)
+   {
+   options = "ro,defaults,uid=1000,gid=1000";
+   fstype = "hfsplus";
+   }
if(mount->fs == NTFS)
{
options = "force";
fstype = "ntfs-3g";
}
-   if(mount->fs > MBR && mount->fs <= EXT4)
+   if(mount->fs > MBR && mount->fs <= LASTFS)
{
struct uci_context *ctx;
char *uci_options, *uci_fstype;
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH mountd 4/4] filesystem mount options in uci as optional parameter

2016-06-17 Thread olivier . hardouin
Possibility to overwrite the default hardcoded settings by adding 'options' 
and 'fstype' in the uci configuration. The fs names are changed in lowercase 
to comply with UCI general naming.

Signed-off-by: Olivier Hardouin 
---
replaces patch "filesystem mount options in uci config" according to review 
comments
obsoletes patch "uci config for mountd fileystem options"

 mount.c | 63 +--
 1 file changed, 41 insertions(+), 22 deletions(-)

diff --git a/mount.c b/mount.c
index 36b99f5..aaddb70 100644
--- a/mount.c
+++ b/mount.c
@@ -51,16 +51,16 @@ struct mount {
 char *fs_names[] = {
"",
"",
-   "MBR",
-   "EXT2",
-   "EXT3",
-   "FAT",
-   "HFSPLUS",
+   "mbr",
+   "ext2",
+   "ext3",
+   "fat",
+   "hfsplus",
"",
-   "NTFS",
+   "ntfs",
"",
-   "EXFAT",
-   "EXT4"
+   "exfat",
+   "ext4"
 };
 
 #define MAX_MOUNTED32
@@ -228,40 +228,59 @@ int mount_new(char *path, char *dev)
pid = autofs_safe_fork();
if(!pid)
{
+   char *options, *fstype;
if(mount->fs == EXFAT)
{
-   log_printf("mount -t exfat -o rw,uid=1000,gid=1000 
/dev/%s %s", mount->dev, tmp);
-   ret = system_printf("mount -t exfat -o 
rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
+   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], "fstyp

[OpenWrt-Devel] [PATCH mountd 3/4] add hotplug events

2016-06-17 Thread olivier . hardouin
add hotplug events (add, remove) to inform other subsystems
remove obsolete /etc/mountd/event call

Signed-off-by: Olivier Hardouin 
---
 mount.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mount.c b/mount.c
index aaddb70..219146b 100644
--- a/mount.c
+++ b/mount.c
@@ -161,6 +161,7 @@ static void mount_add_list(char *name, char *dev, char 
*serial,
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);
}
 }
 
@@ -734,7 +735,7 @@ static void mount_enum_drives(void)
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");
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH mountd 1/4] align fs_names table to indexes defined in include/fs.h

2016-06-17 Thread olivier . hardouin
Signed-off-by: Olivier Hardouin 
---
 mount.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mount.c b/mount.c
index 8892040..36b99f5 100644
--- a/mount.c
+++ b/mount.c
@@ -59,6 +59,7 @@ char *fs_names[] = {
"",
"NTFS",
"",
+   "EXFAT",
"EXT4"
 };
 
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH mountd 2/4] fix crash if no uci config file present

2016-06-17 Thread olivier . hardouin
fix also possible null dereferenced pointers 

Signed-off-by: Olivier Hardouin 
---
 uci.c  | 6 ++
 ucix.c | 9 -
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/uci.c b/uci.c
index f5aad02..46c3922 100644
--- a/uci.c
+++ b/uci.c
@@ -54,6 +54,9 @@ char* uci_get_option(struct uci_context *ctx, char *section, 
char *option)
char *value = NULL;
struct uci_ptr ptr;
 
+   if (!p)
+   return NULL;
+
memset(&ptr, 0, sizeof(ptr));
ptr.package = p->e.name;
ptr.section = section;
@@ -101,6 +104,9 @@ void uci_for_each_section_type(char *type, void 
(*cb)(char*, void*), void *priv)
 {
struct uci_element *e;
 
+   if (!p)
+   return;
+
uci_foreach_element(&p->sections, e)
if (!strcmp(type, uci_to_section(e)->type))
cb(e->name, priv);
diff --git a/ucix.c b/ucix.c
index e2a6780..1e4d1e6 100644
--- a/ucix.c
+++ b/ucix.c
@@ -18,6 +18,8 @@ static inline int ucix_get_ptr(struct uci_context *ctx, const 
char *p, const cha
 struct uci_context* ucix_init(const char *config_file)
 {
struct uci_context *ctx = uci_alloc_context();
+   if(!ctx)
+   return NULL;
uci_add_delta_path(ctx, "/var/state");
if(uci_load(ctx, config_file, NULL) != UCI_OK)
{
@@ -30,6 +32,8 @@ struct uci_context* ucix_init(const char *config_file)
 struct uci_context* ucix_init_path(const char *path, const char *config_file)
 {
struct uci_context *ctx = uci_alloc_context();
+   if(!ctx)
+   return NULL;
if(path)
{
uci_set_savedir(ctx, path);
@@ -44,7 +48,10 @@ struct uci_context* ucix_init_path(const char *path, const 
char *config_file)
 
 void ucix_cleanup(struct uci_context *ctx)
 {
-   uci_free_context(ctx);
+   if(ctx)
+   {
+   uci_free_context(ctx);
+   }
 }
 
 int ucix_save(struct uci_context *ctx, const char *p)
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH package mountd] uci config for mountd fileystem options

2016-06-10 Thread Olivier Hardouin
Yes, you're right both patch are related.
I'm trying to get more flexibility in mountd by passing the mount command
options through UCI.

On Fri, Jun 10, 2016 at 12:02 PM, John Crispin  wrote:

>
>
> On 10/06/2016 12:00, Mathias Kresin wrote:
> > Hi Oliver,
> >
> > 2016-06-10 11:37 GMT+02:00  :
> >> Signed-off-by: Olivier Hardouin 
> >> ---
> >
> > Your patch doesn't have a commit message, which explains why these
> > options are required by default.
> >
> > I've used mountd recently with ext4 and was able to read/write the
> > mounted filesystem out of the box.
> >
> > Mathias
>
> looks like these are the defaults removed from the c code int he patch
> he sent 5 minutes before this patch
>
> John
>
> >
> >>  package/system/mountd/files/mountd.config | 28
> 
> >>  1 file changed, 28 insertions(+)
> >>
> >> diff --git a/package/system/mountd/files/mountd.config
> b/package/system/mountd/files/mountd.config
> >> index 5610129..c105606 100644
> >> --- a/package/system/mountd/files/mountd.config
> >> +++ b/package/system/mountd/files/mountd.config
> >> @@ -1,3 +1,31 @@
> >>  config mountd mountd
> >> option  timeout 60
> >> option  path/tmp/mounts/
> >> +
> >> +config filesystem ext2
> >> +   option options  'rw,defaults'
> >> +   option fstype   'ext2'
> >> +
> >> +config filesystem ext3
> >> +   option options  'rw,defaults'
> >> +   option fstype   'ext3'
> >> +
> >> +config filesystem ext4
> >> +   option options  'rw,defaults'
> >> +   option fstype   'ext4'
> >> +
> >> +config filesystem fat
> >> +   option options  'rw,uid=1000,gid=1000'
> >> +   option fstype   'vfat'
> >> +
> >> +config filesystem exfat
> >> +   option options  'rw,uid=1000,gid=1000'
> >> +   option fstype   'exfat'
> >> +
> >> +config filesystem hfsplus
> >> +   option options  'rw,defaults,uid=1000,gid=1000'
> >> +   option fstype   'hfsplus'
> >> +
> >> +config filesystem ntfs
> >> +   option options  'force'
> >> +   option fstype   'ntfs'
> >> --
> >> 1.9.1
> >> ___
> >> openwrt-devel mailing list
> >> openwrt-devel@lists.openwrt.org
> >> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> > ___
> > openwrt-devel mailing list
> > openwrt-devel@lists.openwrt.org
> > https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> >
>
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH package mountd] uci config for mountd fileystem options

2016-06-10 Thread olivier . hardouin
Signed-off-by: Olivier Hardouin 
---
 package/system/mountd/files/mountd.config | 28 
 1 file changed, 28 insertions(+)

diff --git a/package/system/mountd/files/mountd.config 
b/package/system/mountd/files/mountd.config
index 5610129..c105606 100644
--- a/package/system/mountd/files/mountd.config
+++ b/package/system/mountd/files/mountd.config
@@ -1,3 +1,31 @@
 config mountd mountd
option  timeout 60
option  path/tmp/mounts/
+
+config filesystem ext2
+   option options  'rw,defaults'
+   option fstype   'ext2'
+
+config filesystem ext3
+   option options  'rw,defaults'
+   option fstype   'ext3'
+
+config filesystem ext4
+   option options  'rw,defaults'
+   option fstype   'ext4'
+
+config filesystem fat
+   option options  'rw,uid=1000,gid=1000'
+   option fstype   'vfat'
+
+config filesystem exfat
+   option options  'rw,uid=1000,gid=1000'
+   option fstype   'exfat'
+
+config filesystem hfsplus
+   option options  'rw,defaults,uid=1000,gid=1000'
+   option fstype   'hfsplus'
+
+config filesystem ntfs
+   option options  'force'
+   option fstype   'ntfs'
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH mountd] filesystem mount options in uci config

2016-06-10 Thread olivier . hardouin
Move (previously hardcoded) mount option to UCI to allow different 
configuration 
like charset (utf-8 or iso) and filesystem driver (if alternative ones are 
used).
The fs names are changed in lowercase to comply with UCI general naming.

Signed-off-by: Olivier Hardouin 
---
 mount.c | 69 ++---
 1 file changed, 28 insertions(+), 41 deletions(-)

diff --git a/mount.c b/mount.c
index 8892040..c8f7ea6 100644
--- a/mount.c
+++ b/mount.c
@@ -51,15 +51,15 @@ struct mount {
 char *fs_names[] = {
"",
"",
-   "MBR",
-   "EXT2",
-   "EXT3",
-   "FAT",
-   "HFSPLUS",
+   "mbr",
+   "ext2",
+   "ext3",
+   "fat",
+   "hfsplus",
"",
-   "NTFS",
+   "ntfs",
"",
-   "EXT4"
+   "ext4"
 };
 
 #define MAX_MOUNTED32
@@ -227,42 +227,29 @@ int mount_new(char *path, char *dev)
pid = autofs_safe_fork();
if(!pid)
{
-   if(mount->fs == EXFAT)
+   if(mount->fs > MBR && mount->fs <= EXT4)
{
-   log_printf("mount -t exfat -o rw,uid=1000,gid=1000 
/dev/%s %s", mount->dev, tmp);
-   ret = system_printf("mount -t exfat -o 
rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
-   }
-   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);
-   }
-   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);
-   }
-   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);
-   }
-   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);
-   }
-   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);
-   }
-   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);
+   struct uci_context *ctx;
+   char *options, *fstype;
+   ctx = ucix_init("mountd");
+   options = ucix_get_option(ctx, "mountd", 
fs_names[mount->fs], "options");
+   fstype = ucix_get_option(ctx, "mountd", 
fs_names[mount->fs], "fstype");
+   ucix_cleanup(ctx);
+   if(!fstype)
+   {
+   log_printf("mounting /dev/%s failed, expecting 
'fstype' uci parameter (kernel driver) for %s", mount->dev, 
fs_names[mount->fs]);
+   } else {
+   if(!options)
+   {
+   log_printf("mount -t %s /dev/%s %s", 
fstype, mount->dev, tmp);
+   ret = system_printf("mount -t %s 
/dev/%s %s", fstype, mount->dev, tmp);
+   } else {
+   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);
+   }
+   }
+   exit(WEXITSTATUS(ret));
}
-   exit(WEXITSTATUS(ret));
}
pid = waitpid(pid, &ret, 0);
ret = WEXITSTATUS(ret);
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel