diff mbox

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

Message ID 1466581879-9862-2-git-send-email-olivier.hardouin@gmail.com
State Changes Requested
Delegated to: John Crispin
Headers show

Commit Message

olivier.hardouin@gmail.com June 22, 2016, 7:51 a.m. UTC
if no partition found, try to mount the block device itself

Signed-off-by: Olivier Hardouin <olivier.hardouin@gmail.com>
---
 mount.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

John Crispin June 23, 2016, 7:24 a.m. UTC | #1
On 22/06/2016 09:51, olivier.hardouin@gmail.com wrote:
> if no partition found, try to mount the block device itself
> 
> Signed-off-by: Olivier Hardouin <olivier.hardouin@gmail.com>

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]);
>  		}
>
olivier.hardouin@gmail.com June 23, 2016, 8:17 a.m. UTC | #2
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 <john@phrozen.org> wrote:
>
>
> On 22/06/2016 09:51, olivier.hardouin@gmail.com wrote:
>> if no partition found, try to mount the block device itself
>>
>> Signed-off-by: Olivier Hardouin <olivier.hardouin@gmail.com>
>
> 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]);
>>               }
>>
John Crispin June 23, 2016, 9:37 a.m. UTC | #3
On 23/06/2016 10:17, Olivier Hardouin wrote:
> 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.


Hi,

that is called superfloppy iirc. not seen those in a while. i've pushed
the changes to the mountd repo

	John

> 
> 
> On Thu, Jun 23, 2016 at 9:24 AM, John Crispin <john@phrozen.org> wrote:
>>
>>
>> On 22/06/2016 09:51, olivier.hardouin@gmail.com wrote:
>>> if no partition found, try to mount the block device itself
>>>
>>> Signed-off-by: Olivier Hardouin <olivier.hardouin@gmail.com>
>>
>> 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]);
>>>               }
>>>
> 
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
>
diff mbox

Patch

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]);
 		}