diff --git a/reactos/tools/fatten/fatfs/ff.c b/reactos/tools/fatten/fatfs/ff.c index 9c84928d994..4e4f2160038 100644 --- a/reactos/tools/fatten/fatfs/ff.c +++ b/reactos/tools/fatten/fatfs/ff.c @@ -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; diff --git a/reactos/tools/fatten/fatten.c b/reactos/tools/fatten/fatten.c index 315e2933c43..ae50aeaf966 100644 --- a/reactos/tools/fatten/fatten.c +++ b/reactos/tools/fatten/fatten.c @@ -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)