[FATTEN]: Set the directory volume label in addition to the bootsector label.

[FATFS]: For FAT12 volumes, do not expand the FAT size.

svn path=/trunk/; revision=70548
This commit is contained in:
Hermès Bélusca-Maïto 2016-01-08 13:51:45 +00:00
parent dce360ba2c
commit 6d8ed09fbe
2 changed files with 14 additions and 7 deletions

View file

@ -4162,9 +4162,9 @@ FRESULT f_mkfs (
if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */
n_rsv += n;
b_fat += n;
} else { /* FAT12/16: Expand FAT size */
} else if (fmt == FS_FAT16) { /* FAT16: Expand FAT size */
n_fat += n;
}
} // else /* if (fmt == FS_FAT12) */ {} /* FAT12: Do nothing */
/* Determine number of clusters and final check of validity of the FAT sub-type */
n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au;

View file

@ -208,13 +208,15 @@ int main(int oargc, char* oargv[])
// Arg 2: custom header label (optional)
if (nargs > 1)
{
char label[11];
#define FAT_VOL_LABEL_LEN 11
char vol_label[2 + FAT_VOL_LABEL_LEN + 1]; // Null-terminated buffer
char* label = vol_label + 2; // The first two characters are reserved for the drive number "0:"
char ch;
int i, invalid = 0;
int len = strlen(argv[1]);
if (len <= sizeof(label))
if (len <= FAT_VOL_LABEL_LEN)
{
// Verify each character (should be printable ASCII)
// and copy it in uppercase.
@ -233,7 +235,7 @@ int main(int oargc, char* oargv[])
if (!invalid)
{
// Pad the label with spaces
while (len < sizeof(label))
while (len < FAT_VOL_LABEL_LEN)
{
label[len++] = ' ';
}
@ -260,11 +262,11 @@ int main(int oargc, char* oargv[])
if (g_Filesystem.fs_type == FS_FAT32)
{
memcpy(buff + 71, label, sizeof(label));
memcpy(buff + 71, label, FAT_VOL_LABEL_LEN);
}
else
{
memcpy(buff + 43, label, sizeof(label));
memcpy(buff + 43, label, FAT_VOL_LABEL_LEN);
}
if (disk_write(0, buff, 0, 1))
@ -273,6 +275,11 @@ int main(int oargc, char* oargv[])
ret = 1;
goto exit;
}
// Set also the directory volume label
memcpy(vol_label, "0:", 2);
vol_label[2 + FAT_VOL_LABEL_LEN] = '\0';
f_setlabel(vol_label);
}
}
else if (strcmp(parg, "boot") == 0)