From a4b5f8c5b13cddff0ff27f5567f7426365e5c8d6 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 14 Jun 2015 15:46:30 +0000 Subject: [PATCH] ACTION_RENAME_DISK fixes: - Update the volume name in the root lock too. This makes the new volume name appear next to the current volume in C:Info output. - Don't generate an IECLASS_DISKINSERTED event. - Use the same capitalisation for the updated in-memory volume name as will be used when the disk is re-inserted. E.g. "flopPy" -> "Floppy". git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50820 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/filesys/fat/fat.c | 20 ++++++++++++++------ rom/filesys/fat/fat_struct.h | 9 +++++---- rom/filesys/fat/packet.c | 3 ++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/rom/filesys/fat/fat.c b/rom/filesys/fat/fat.c index 934cddb2cd..92031d172c 100644 --- a/rom/filesys/fat/fat.c +++ b/rom/filesys/fat/fat.c @@ -775,6 +775,10 @@ LONG SetVolumeName(struct FSSuper *sb, UBYTE *name, UWORD len) { ULONG bsize = dosenv->de_SizeBlock * 4; struct FATBootSector *boot; + /* truncate name if necessary */ + if (len > FAT_MAX_SHORT_NAME) + len = FAT_MAX_SHORT_NAME; + /* read boot block */ boot = AllocMem(bsize, MEMF_ANY); if (!boot) @@ -820,7 +824,7 @@ LONG SetVolumeName(struct FSSuper *sb, UBYTE *name, UWORD len) { /* copy the name in */ if (err == 0) { - for (i = 0; i < 11; i++) + for (i = 0; i < FAT_MAX_SHORT_NAME; i++) if (i < len) de.e.entry.name[i] = toupper(name[i]); else @@ -834,9 +838,11 @@ LONG SetVolumeName(struct FSSuper *sb, UBYTE *name, UWORD len) { /* copy name to boot block as well, and save */ if (sb->type == 32) - CopyMem(de.e.entry.name, boot->ebpbs.ebpb32.ebpb.bs_vollab, 11); + CopyMem(de.e.entry.name, boot->ebpbs.ebpb32.ebpb.bs_vollab, + FAT_MAX_SHORT_NAME); else - CopyMem(de.e.entry.name, boot->ebpbs.ebpb.bs_vollab, 11); + CopyMem(de.e.entry.name, boot->ebpbs.ebpb.bs_vollab, + FAT_MAX_SHORT_NAME); if ((err = AccessDisk(TRUE, sb->first_device_sector, 1, bsize, (UBYTE *)boot, glob)) != 0) @@ -844,9 +850,11 @@ LONG SetVolumeName(struct FSSuper *sb, UBYTE *name, UWORD len) { FreeMem(boot, bsize); /* update name in sb */ - sb->volume.name[0] = len <= 11 ? len : 11; - CopyMem(name, &(sb->volume.name[1]), sb->volume.name[0]); - sb->volume.name[sb->volume.name[0]+1] = '\0'; + sb->volume.name[0] = len; + sb->volume.name[1] = toupper(name[0]); + for (i = 1; i < len; i++) + sb->volume.name[i + 1] = tolower(name[i]); + sb->volume.name[len + 1] = '\0'; D(bug("[fat] new volume name is '%s'\n", &(sb->volume.name[1]))); diff --git a/rom/filesys/fat/fat_struct.h b/rom/filesys/fat/fat_struct.h index 8d88321d03..cc94fab443 100644 --- a/rom/filesys/fat/fat_struct.h +++ b/rom/filesys/fat/fat_struct.h @@ -10,12 +10,15 @@ * $Id$ */ +#define FAT_MAX_SHORT_NAME 11 +#define FAT_MAX_LONG_FILENAME 0xff + struct FATEBPB{ UBYTE bs_drvnum; UBYTE bs_reserved1; UBYTE bs_bootsig; ULONG bs_volid; - UBYTE bs_vollab[11]; + UBYTE bs_vollab[FAT_MAX_SHORT_NAME]; UBYTE bs_filsystype[8]; } __attribute__ ((__packed__)); @@ -67,7 +70,7 @@ struct FATFSInfo { #define FSI_TRAIL_SIG 0xaa550000 struct FATDirEntry { - UBYTE name[11]; + UBYTE name[FAT_MAX_SHORT_NAME]; UBYTE attr; UBYTE nt_res; UBYTE create_time_tenth; @@ -102,5 +105,3 @@ struct FATLongDirEntry { UWORD first_cluster_lo; UWORD name3[2]; } __attribute__ ((__packed__)); - -#define FAT_MAX_LONG_FILENAME 0xff diff --git a/rom/filesys/fat/packet.c b/rom/filesys/fat/packet.c index 41a1ea7746..200dd5e8e6 100644 --- a/rom/filesys/fat/packet.c +++ b/rom/filesys/fat/packet.c @@ -549,7 +549,8 @@ void ProcessPackets(struct Globals *glob) { glob->sb->volume.name[0] + 2); #endif - SendEvent(IECLASS_DISKINSERTED, glob); + CopyMem(glob->sb->volume.name, glob->sb->info->root_lock.name, + glob->sb->volume.name[0] + 1); res = DOSTRUE; -- 2.11.4.GIT