* Applied slightly cleaned up patch by romain that sanitizes the volume names.
* This closes bug #4602. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35523 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -765,6 +765,7 @@ dosfs_identify_partition(int fd, partition_data *partition, void **_cookie)
|
||||
|
||||
cookie->bytes_per_sector = bytes_per_sector;
|
||||
cookie->total_sectors = total_sectors;
|
||||
sanitize_name(name, 12);
|
||||
strlcpy(cookie->name, name, 12);
|
||||
*_cookie = cookie;
|
||||
|
||||
@@ -994,7 +995,6 @@ static status_t
|
||||
dosfs_read_fs_stat(fs_volume *_vol, struct fs_info * fss)
|
||||
{
|
||||
nspace* vol = (nspace*)_vol->private_volume;
|
||||
int i;
|
||||
|
||||
LOCK_VOL(vol);
|
||||
|
||||
@@ -1021,19 +1021,11 @@ dosfs_read_fs_stat(fs_volume *_vol, struct fs_info * fss)
|
||||
strncpy(fss->device_name, vol->device, sizeof(fss->device_name));
|
||||
|
||||
if (vol->vol_entry > -2)
|
||||
strncpy(fss->volume_name, vol->vol_label, sizeof(fss->volume_name));
|
||||
strlcpy(fss->volume_name, vol->vol_label, sizeof(fss->volume_name));
|
||||
else
|
||||
strcpy(fss->volume_name, "no name");
|
||||
|
||||
// XXX: should sanitize name as well
|
||||
for (i=10;i>0;i--)
|
||||
if (fss->volume_name[i] != ' ')
|
||||
break;
|
||||
fss->volume_name[i+1] = 0;
|
||||
for (;i>=0;i--) {
|
||||
if ((fss->volume_name[i] >= 'A') && (fss->volume_name[i] <= 'Z'))
|
||||
fss->volume_name[i] += 'a' - 'A';
|
||||
}
|
||||
sanitize_name(fss->volume_name, 12);
|
||||
|
||||
// File system name
|
||||
strcpy(fss->fsh_name, "fat");
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Copyright 1999-2001, Be Incorporated. All Rights Reserved.
|
||||
This file may be used under the terms of the Be Sample Code License.
|
||||
*/
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <KernelExport.h>
|
||||
|
||||
@@ -164,3 +166,20 @@ hash_msdos_name(const char *name)
|
||||
c = (c << 7) + (c >> 1) + *(p++);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sanitize_name(char *name, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = length - 1; i > 0; i--) {
|
||||
if (name[i] != ' ')
|
||||
break;
|
||||
}
|
||||
name[i + 1] = 0;
|
||||
for (; i >= 0; i--) {
|
||||
if (name[i] >= 'A' && name[i] <= 'Z')
|
||||
name[i] += 'a' - 'A';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#ifndef _DOSFS_UTIL_H_
|
||||
#define _DOSFS_UTIL_H_
|
||||
|
||||
|
||||
#include <ByteOrder.h>
|
||||
|
||||
|
||||
// debugging functions
|
||||
#ifndef ASSERT
|
||||
#ifndef DEBUG
|
||||
@@ -25,6 +27,7 @@ time_t dos2time_t(uint32 t);
|
||||
uint32 time_t2dos(time_t s);
|
||||
|
||||
uint8 hash_msdos_name(const char *name);
|
||||
void sanitize_name(char *name, int length);
|
||||
|
||||
#if 0
|
||||
#define read32(buffer,off) \
|
||||
@@ -41,4 +44,4 @@ uint8 hash_msdos_name(const char *name);
|
||||
#define read16(buffer,off) \
|
||||
B_LENDIAN_TO_HOST_INT16(*(uint16 *)&buffer[off])
|
||||
|
||||
#endif
|
||||
#endif /* _DOSFS_UTIL_H_ */
|
||||
|
||||
Reference in New Issue
Block a user