support for disk without partition table
authorolivier.hardouin@gmail.com <olivier.hardouin@gmail.com>
Wed, 22 Jun 2016 07:51:19 +0000 (09:51 +0200)
committerJohn Crispin <john@phrozen.org>
Wed, 22 Jun 2016 09:51:34 +0000 (11:51 +0200)
if no partition found, try to mount the block device itself

Signed-off-by: Olivier Hardouin <olivier.hardouin@gmail.com>
mount.c

diff --git a/mount.c b/mount.c
index 0c2862a06f081e1323bff3e18063772526afb1b8..7cbb8fff365907a47b8b560f0d92f176c1611284 100644 (file)
--- 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]);
                }