mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-30 00:20:44 +09:00
fs: fat: usage basename in file_fat_write_at, fat_mkdir
This patch involves no functional change. It is just about code readability. Both in file_fat_write_at() and fat_mkdir() the incoming file or directory path are split into two parts: the parent directory and the base name. In file_fat_write_at() the value of the variable basename is assigned to the filename parameter and afterwards the variable filename is used instead of basename. It is more readable to use the variable basename and leave filename unchanged. In fat_mkdir() the base name variable is called directory. This is confusing. Call it basename like in file_fat_write_at(). This allows to rename parameter new_directory to directory in the implementation of fat_mkdir() to match the function declaration. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fdcb93e170
commit
4c4006b694
@ -1299,9 +1299,8 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = basename;
|
if (normalize_longname(l_filename, basename)) {
|
||||||
if (normalize_longname(l_filename, filename)) {
|
printf("FAT: illegal filename (%s)\n", basename);
|
||||||
printf("FAT: illegal filename (%s)\n", filename);
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -1365,7 +1364,7 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if long name is needed */
|
/* Check if long name is needed */
|
||||||
ndent = set_name(itr, filename, shortname);
|
ndent = set_name(itr, basename, shortname);
|
||||||
if (ndent < 0) {
|
if (ndent < 0) {
|
||||||
ret = ndent;
|
ret = ndent;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -1375,7 +1374,7 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer,
|
|||||||
goto exit;
|
goto exit;
|
||||||
if (ndent > 1) {
|
if (ndent > 1) {
|
||||||
/* Set long name entries */
|
/* Set long name entries */
|
||||||
ret = fill_dir_slot(itr, filename, shortname);
|
ret = fill_dir_slot(itr, basename, shortname);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -1611,31 +1610,31 @@ exit:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fat_mkdir(const char *new_dirname)
|
int fat_mkdir(const char *dirname)
|
||||||
{
|
{
|
||||||
dir_entry *retdent;
|
dir_entry *retdent;
|
||||||
fsdata datablock = { .fatbuf = NULL, };
|
fsdata datablock = { .fatbuf = NULL, };
|
||||||
fsdata *mydata = &datablock;
|
fsdata *mydata = &datablock;
|
||||||
fat_itr *itr = NULL;
|
fat_itr *itr = NULL;
|
||||||
char *dirname_copy, *parent, *dirname;
|
char *dirname_copy, *parent, *basename;
|
||||||
char l_dirname[VFAT_MAXLEN_BYTES];
|
char l_dirname[VFAT_MAXLEN_BYTES];
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
loff_t actwrite;
|
loff_t actwrite;
|
||||||
unsigned int bytesperclust;
|
unsigned int bytesperclust;
|
||||||
dir_entry *dotdent = NULL;
|
dir_entry *dotdent = NULL;
|
||||||
|
|
||||||
dirname_copy = strdup(new_dirname);
|
dirname_copy = strdup(dirname);
|
||||||
if (!dirname_copy)
|
if (!dirname_copy)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
split_filename(dirname_copy, &parent, &dirname);
|
split_filename(dirname_copy, &parent, &basename);
|
||||||
if (!strlen(dirname)) {
|
if (!strlen(basename)) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (normalize_longname(l_dirname, dirname)) {
|
if (normalize_longname(l_dirname, basename)) {
|
||||||
printf("FAT: illegal filename (%s)\n", dirname);
|
printf("FAT: illegal filename (%s)\n", basename);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -1678,7 +1677,7 @@ int fat_mkdir(const char *new_dirname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if long name is needed */
|
/* Check if long name is needed */
|
||||||
ndent = set_name(itr, dirname, shortname);
|
ndent = set_name(itr, basename, shortname);
|
||||||
if (ndent < 0) {
|
if (ndent < 0) {
|
||||||
ret = ndent;
|
ret = ndent;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -1688,7 +1687,7 @@ int fat_mkdir(const char *new_dirname)
|
|||||||
goto exit;
|
goto exit;
|
||||||
if (ndent > 1) {
|
if (ndent > 1) {
|
||||||
/* Set long name entries */
|
/* Set long name entries */
|
||||||
ret = fill_dir_slot(itr, dirname, shortname);
|
ret = fill_dir_slot(itr, basename, shortname);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user