[parted-devel] [PATCH 25/28] fs/r/fat: Remove disabled code

Brian C. Lane bcl at redhat.com
Fri Nov 20 22:22:40 GMT 2020


---
 libparted/fs/r/fat/count.c  |  83 -----------------
 libparted/fs/r/fat/fat.c    | 175 ------------------------------------
 libparted/fs/r/fat/resize.c |  17 ----
 3 files changed, 275 deletions(-)

diff --git a/libparted/fs/r/fat/count.c b/libparted/fs/r/fat/count.c
index 2b65e72..51e1aa2 100644
--- a/libparted/fs/r/fat/count.c
+++ b/libparted/fs/r/fat/count.c
@@ -27,66 +27,6 @@
 
 #ifndef DISCOVER_ONLY
 
-#if 0
-/* extremely ugly hack: stick everything that obviously isn't an unmovable file
- * in here.  Note: DAT is a bit dubious.  Unfortunately, it's used by the
- * registry, so it'll be all over the place :-(
- */
-static char*	movable_extensions[] = {
-	"",
-	"1ST",
-	"AVI",
-	"BAK", "BAT", "BMP",
-	"CFG", "COM", "CSS",
-	"DAT", "DLL", "DOC", "DRV",
-	"EXE",
-	"FAQ", "FLT", "FON",
-	"GID", "GIF",
-	"HLP", "HTT", "HTM",
-	"ICO", "INI",
-	"JPG",
-	"LNK", "LOG",
-	"KBD",
-	"ME", "MID", "MSG",
-	"OCX", "OLD",
-	"PIF", "PNG", "PRV",
-	"RTF",
-	"SCR", "SYS",
-	"TMP", "TTF", "TXT",
-	"URL",
-	"WAV",
-	"VBX", "VOC", "VXD",
-	NULL
-};
-
-static char*
-get_extension (char* file_name)
-{
-	char*		ext;
-
-	ext = strrchr (file_name, '.');
-	if (!ext)
-		return "";
-	if (strchr (ext, '\\'))
-		return "";
-	return ext + 1;
-}
-
-static int
-is_movable_system_file (char* file_name)
-{
-	char*		ext = get_extension (file_name);
-	int		i;
-
-	for (i = 0; movable_extensions [i]; i++) {
-		if (strcasecmp (ext, movable_extensions [i]) == 0)
-			return 1;
-	}
-
-	return 0;
-}
-#endif /* 0 */
-
 /*
     prints out the sequence of clusters for a given file chain, beginning
     at start_cluster.
@@ -248,29 +188,6 @@ flag_traverse_dir (FatTraverseInfo* trav_info) {
 		print_chain (fs, first_cluster);
 #endif
 
-#if 0
-		if (fat_dir_entry_is_system_file (this_entry)
-		    && !is_movable_system_file (file_name)) {
-                        PedExceptionOption ex_status;
-			ex_status = ped_exception_throw (
-				PED_EXCEPTION_WARNING,
-				PED_EXCEPTION_IGNORE_CANCEL,
-				_("The file %s is marked as a system file.  "
-				"This means moving it could cause some "
-				"programs to stop working."),
-				file_name);
-
-			switch (ex_status) {
-				case PED_EXCEPTION_CANCEL:
-					return 0;
-
-				case PED_EXCEPTION_UNHANDLED:
-					ped_exception_catch ();
-				case PED_EXCEPTION_IGNORE:
-			}
-		}
-#endif /* 0 */
-
 		if (fat_dir_entry_is_directory (this_entry)) {
 			if (!flag_traverse_fat (fs, file_name, first_cluster,
 						FAT_FLAG_DIRECTORY, size))
diff --git a/libparted/fs/r/fat/fat.c b/libparted/fs/r/fat/fat.c
index ad57d36..0b2fee9 100644
--- a/libparted/fs/r/fat/fat.c
+++ b/libparted/fs/r/fat/fat.c
@@ -613,68 +613,6 @@ fat_get_resize_constraint (const PedFileSystem* fs)
 	return fat_get_copy_constraint (fs, fs->geom->dev);
 }
 
-/* FIXME: fat_calc_sizes() needs to say "too big" or "too small", or
- * something.  This is a really difficult (maths) problem to do
- * nicely...
- * 	So, this algorithm works if dev->length / 2 is a valid fat_type
- * size.  (Which is how I got the magic numbers below)
- */
-#if 0
-/* returns: -1 too small, 0 ok, 1 too big */
-static int
-_test_create_size (PedSector length, FatType fat_type,
-		   PedSector cluster_sectors, PedSector cluster_count)
-{
-	PedSector	rootdir_sectors;
-	PedSector	_cluster_sectors;
-	FatCluster	_cluster_count;
-	PedSector	_fat_size;
-
-	rootdir_sectors = (fat_type == FAT_TYPE_FAT16) ? 16 : 0;
-
-	if (!fat_calc_sizes (length, 0, fat_type, rootdir_sectors,
-			     &_cluster_sectors, &_cluster_count, &_fat_size))
-		return -1; // XXX: doesn't work... can't see a better way!
-
-	if (_cluster_sectors < cluster_sectors)
-		return -1;
-	if (_cluster_sectors > cluster_sectors)
-		return 1;
-
-	if (_cluster_count < cluster_count)
-		return -1;
-	if (_cluster_count > cluster_count)
-		return 1;
-
-	return 0;
-}
-
-static PedSector
-_get_create_size (PedSector upper_bound, FatType fat_type,
-		  PedSector cluster_sectors, FatCluster cluster_count)
-{
-	PedSector	min_length = 0;
-	PedSector	max_length = upper_bound;
-	PedSector	length;
-
-	while (1) {
-		length = (min_length + max_length) / 2;
-		switch (_test_create_size (length, fat_type, cluster_sectors,
-					   cluster_count)) {
-			case -1: min_length = length; break;
-			case 0: return length;
-			case 1: max_length = length; break;
-		}
-		/* hack... won't always be able to get max cluster count
-		 * with max cluster size, etc. */
-		if (max_length - min_length == 1)
-			return min_length;
-	}
-
-	return 0;	/* shut gcc up */
-}
-#endif
-
 PedConstraint*
 fat_get_create_constraint_fat16 (const PedDevice* dev)
 {
@@ -685,19 +623,8 @@ fat_get_create_constraint_fat16 (const PedDevice* dev)
 	if (!ped_geometry_init (&full_dev, dev, 0, dev->length - 1))
 		return NULL;
 
-#if 0
-	min_size = _get_create_size (dev->length, FAT_TYPE_FAT16,
-		       		     fat_min_cluster_size (FAT_TYPE_FAT16),
-				     fat_min_cluster_count (FAT_TYPE_FAT16));
-	max_size = _get_create_size (dev->length, FAT_TYPE_FAT16,
-				     fat_max_cluster_size (FAT_TYPE_FAT16),
-				     fat_max_cluster_count (FAT_TYPE_FAT16));
-	if (!min_size)
-		return NULL;
-#else
 	min_size = 65794;
 	max_size = 2097153;
-#endif
 
 	return ped_constraint_new (
 			ped_alignment_any, ped_alignment_any,
@@ -714,15 +641,7 @@ fat_get_create_constraint_fat32 (const PedDevice* dev)
 	if (!ped_geometry_init (&full_dev, dev, 0, dev->length - 1))
 		return NULL;
 
-#if 0
-	min_size = _get_create_size (dev->length, FAT_TYPE_FAT32,
-		       		     fat_min_cluster_size (FAT_TYPE_FAT32),
-				     fat_min_cluster_count (FAT_TYPE_FAT32));
-	if (!min_size)
-		return NULL;
-#else
 	min_size = 525224;
-#endif
 
 	return ped_constraint_new (
 			ped_alignment_any, ped_alignment_any,
@@ -730,97 +649,3 @@ fat_get_create_constraint_fat32 (const PedDevice* dev)
 			min_size, dev->length);
 }
 #endif /* !DISCOVER_ONLY */
-
-#if 0
-
-static PedFileSystemOps fat16_ops = {
-	probe:		fat_probe_fat16,
-#ifndef DISCOVER_ONLY
-	clobber:	fat_clobber,
-	open:		fat_open,
-	create:		fat_create_fat16,
-	close:		fat_close,
-	check:		fat_check,
-	resize:		fat_resize,
-	copy:		fat_copy,
-	get_create_constraint:	fat_get_create_constraint_fat16,
-	get_resize_constraint:	fat_get_resize_constraint,
-	get_copy_constraint:	fat_get_copy_constraint,
-#else /* !DISCOVER_ONLY */
-	clobber:	NULL,
-	open:		NULL,
-	create:		NULL,
-	close:		NULL,
-	check:		NULL,
-	resize:		NULL,
-	copy:		NULL,
-	get_create_constraint:	NULL,
-	get_resize_constraint:	NULL,
-	get_copy_constraint:	NULL,
-#endif /* !DISCOVER_ONLY */
-};
-
-static PedFileSystemOps fat32_ops = {
-	probe:		fat_probe_fat32,
-#ifndef DISCOVER_ONLY
-	clobber:	fat_clobber,
-	open:		fat_open,
-	create:		fat_create_fat32,
-	close:		fat_close,
-	check:		fat_check,
-	resize:		fat_resize,
-	copy:		fat_copy,
-	get_create_constraint:	fat_get_create_constraint_fat32,
-	get_resize_constraint:	fat_get_resize_constraint,
-	get_copy_constraint:	fat_get_copy_constraint,
-#else /* !DISCOVER_ONLY */
-	clobber:	NULL,
-	open:		NULL,
-	create:		NULL,
-	close:		NULL,
-	check:		NULL,
-	resize:		NULL,
-	copy:		NULL,
-	get_create_constraint:	NULL,
-	get_resize_constraint:	NULL,
-	get_copy_constraint:	NULL,
-#endif /* !DISCOVER_ONLY */
-};
-
-#define FAT_BLOCK_SIZES ((int[2]){512, 0})
-
-PedFileSystemType fat16_type = {
-	next:	        NULL,
-	ops:	        &fat16_ops,
-	name:	        "fat16",
-        block_sizes:    FAT_BLOCK_SIZES
-};
-
-PedFileSystemType fat32_type = {
-	next:	        NULL,
-	ops:	        &fat32_ops,
-	name:	        "fat32",
-        block_sizes:    FAT_BLOCK_SIZES
-};
-
-void
-ped_file_system_fat_init ()
-{
-	if (sizeof (FatBootSector) != 512) {
-		ped_exception_throw (PED_EXCEPTION_BUG, PED_EXCEPTION_CANCEL,
-			_("GNU Parted was miscompiled: the FAT boot sector "
-			"should be 512 bytes.  FAT support will be disabled."));
-	} else {
-		ped_file_system_type_register (&fat16_type);
-		ped_file_system_type_register (&fat32_type);
-	}
-}
-
-void
-ped_file_system_fat_done ()
-{
-	ped_file_system_type_unregister (&fat16_type);
-	ped_file_system_type_unregister (&fat32_type);
-}
-
-#endif
diff --git a/libparted/fs/r/fat/resize.c b/libparted/fs/r/fat/resize.c
index 71113d4..2a0955d 100644
--- a/libparted/fs/r/fat/resize.c
+++ b/libparted/fs/r/fat/resize.c
@@ -446,23 +446,6 @@ fat_construct_new_fat (FatOpContext* ctx)
 		fat_table_set (new_fs_info->fat, new_cluster, new_next_cluster);
 	}
 
-#if 0
-#ifdef PED_VERBOSE
-	for (old_cluster=2; old_cluster < old_fs_info->cluster_count+2;
-	     old_cluster++) {
-		if (fat_table_is_available (old_fs_info->fat, old_cluster))
-			continue;
-
-		printf ("%d->%d\t(next: %d->%d)\n",
-			old_cluster,
-			ctx->remap [old_cluster],
-			fat_table_get (old_fs_info->fat, old_cluster),
-			fat_table_get (new_fs_info->fat,
-				       ctx->remap [old_cluster]));
-	}
-#endif /* PED_VERBOSE */
-#endif
-
 	if (old_fs_info->fat_type == FAT_TYPE_FAT32
 	    && new_fs_info->fat_type == FAT_TYPE_FAT32) {
 		new_fs_info->root_cluster
-- 
2.26.2




More information about the parted-devel mailing list