Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-parted: Commit

external/parted


Commit MetaInfo

Révisionf5308e408980443b20cb35696b09e1f6e6e60966 (tree)
l'heure2012-02-11 04:05:49
AuteurJim Meyering <meyering@redh...>
CommiterJim Meyering

Message de Log

lib-fs-resize: rewrite ped_file_system_clobber

Before, it would probe for an existing file system type and then,
according to what it found, call the corresponding <FS_TYPE>_clobber
function. Now that we have restored only HFS and FAT FS-writing
support, only those few types have a corresponding _clobber function.
We would obviously fail to clear common types of file systems, and even
if we were to restore all previous _clobber functions, none of those
were able to handle sector sizes larger than 512. Not worth it.
* libparted/fs/r/filesys.c: Include pt-tools.h.
(MIN): Define.
(ped_file_system_clobber): Rewrite not to use hfs*_clobber or
fat_clobber. Instead, simply clear the first three and last two
sectors of the specified "device".
* libparted/fs/Makefile.am (INCLUDES): Add
-I$(top_srcdir)/libparted/labels for new use of a ptt_* function.

Change Summary

Modification

--- a/libparted/fs/Makefile.am
+++ b/libparted/fs/Makefile.am
@@ -102,4 +102,7 @@ libparted_fs_resize_la_SOURCES = \
102102 r/hfs/reloc_plus.c \
103103 r/hfs/reloc_plus.h
104104
105-INCLUDES = $(partedincludedir) $(INTLINCS)
105+INCLUDES = \
106+ -I$(top_srcdir)/libparted/labels \
107+ $(partedincludedir) \
108+ $(INTLINCS)
--- a/libparted/fs/r/filesys.c
+++ b/libparted/fs/r/filesys.c
@@ -29,6 +29,7 @@
2929
3030 #include <parted/parted.h>
3131 #include <parted/debug.h>
32+#include "pt-tools.h"
3233
3334 #if ENABLE_NLS
3435 # include <libintl.h>
@@ -39,6 +40,10 @@
3940
4041 #define STREQ(a, b) (strcmp (a, b) == 0)
4142
43+#ifndef MIN
44+# define MIN(a,b) (((a) < (b)) ? (a) : (b))
45+#endif
46+
4247 typedef PedFileSystem * (*open_fn_t) (PedGeometry *);
4348 extern PedFileSystem *hfsplus_open (PedGeometry *);
4449 extern PedFileSystem *hfs_open (PedGeometry *);
@@ -215,40 +220,22 @@ error_close_dev:
215220 static int
216221 ped_file_system_clobber (PedGeometry* geom)
217222 {
218- PedFileSystemType* fs_type = NULL;
219-
220- PED_ASSERT (geom != NULL);
221-
222- if (!ped_device_open (geom->dev))
223- goto error;
223+ PED_ASSERT (geom != NULL);
224224
225- ped_exception_fetch_all ();
226- while ((fs_type = ped_file_system_type_get_next (fs_type))) {
227- PedGeometry* probed;
225+ if (!ped_device_open (geom->dev))
226+ return 0;
228227
229- if (!fs_type->ops->clobber)
230- continue;
228+ /* Clear the first three and the last two sectors, albeit fewer
229+ when GEOM is too small. */
230+ PedSector len = MIN (geom->length, geom->dev->length);
231231
232- probed = ped_file_system_probe_specific (fs_type, geom);
233- if (!probed) {
234- ped_exception_catch ();
235- continue;
236- }
237- ped_geometry_destroy (probed);
232+ int ok = (len <= 5
233+ ? ptt_geom_clear_sectors (geom, 0, len)
234+ : (ptt_geom_clear_sectors (geom, 0, 3)
235+ && ptt_geom_clear_sectors (geom, geom->dev->length - 2, 2)));
238236
239- if (fs_type->ops->clobber && !fs_type->ops->clobber (geom)) {
240- ped_exception_leave_all ();
241- goto error_close_dev;
242- }
243- }
244- ped_device_close (geom->dev);
245- ped_exception_leave_all ();
246- return 1;
247-
248-error_close_dev:
249- ped_device_close (geom->dev);
250-error:
251- return 0;
237+ ped_device_close (geom->dev);
238+ return !!ok;
252239 }
253240
254241 /* This function erases all signatures that indicate the presence of
Afficher sur ancien navigateur de dépôt.