[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Otavio Salvador otavio at alioth.debian.org
Mon Nov 5 03:40:37 UTC 2007


 include/parted/beos.h    |    2 --
 include/parted/device.h  |    6 +++---
 include/parted/filesys.h |    3 ---
 include/parted/geom.h    |    6 +++---
 include/parted/gnu.h     |    2 --
 include/parted/linux.h   |    2 --
 include/parted/parted.h  |   14 --------------
 libparted/Makefile.am    |    1 +
 libparted/arch/beos.c    |    2 ++
 libparted/arch/gnu.c     |    2 ++
 libparted/arch/linux.c   |    1 +
 libparted/architecture.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 libparted/architecture.h |   38 ++++++++++++++++++++++++++++++++++++++
 libparted/device.c       |    2 ++
 libparted/disk.c         |    2 ++
 libparted/libparted.c    |   30 ++----------------------------
 16 files changed, 98 insertions(+), 57 deletions(-)

New commits:
commit 5b1ae8fe9eec59340b479e8e3ac74a3268123e33
Author: Otavio Salvador <otavio at ossystems.com.br>
Date:   Fri Nov 2 14:33:05 2007 -0200

    Move PedArchitecture and ped_set_architecture to private
    
    Code that works with libparted isn't suppose to need to change the
    architecture where it's running and then doesn't make sense to export
    it.
    
    Two new files has been create (libparted/architecture.[hc]) that has
    the PedArchitecture structure and the ped_set_architecture
    implementation.  All changes that were need to get it suported on all
    currently available architectures has been done too.

diff --git a/include/parted/beos.h b/include/parted/beos.h
index cb329aa..b4d692c 100644
--- a/include/parted/beos.h
+++ b/include/parted/beos.h
@@ -30,7 +30,5 @@ struct _BEOSSpecific {
 	int	fd;
 };
 
-extern PedArchitecture ped_beos_arch;
-
 #endif /* PED_LINUX_H_INCLUDED */
 
diff --git a/include/parted/gnu.h b/include/parted/gnu.h
index e809fb7..a47b026 100644
--- a/include/parted/gnu.h
+++ b/include/parted/gnu.h
@@ -32,8 +32,6 @@ struct _GNUSpecific {
 	int consume;
 };
 
-extern PedArchitecture ped_gnu_arch;
-
 /* Initialize a PedDevice using SOURCE.  The SOURCE will NOT be destroyed;
    the caller created it, it is the caller's responsilbility to free it
    after it calls ped_device_destory.  SOURCE is not registered in Parted's
diff --git a/include/parted/linux.h b/include/parted/linux.h
index 52d28be..9eb7490 100644
--- a/include/parted/linux.h
+++ b/include/parted/linux.h
@@ -39,7 +39,5 @@ struct _LinuxSpecific {
 #endif
 };
 
-extern PedArchitecture ped_linux_arch;
-
 #endif /* PED_LINUX_H_INCLUDED */
 
diff --git a/include/parted/parted.h b/include/parted/parted.h
index 1302d8f..31ed6ec 100644
--- a/include/parted/parted.h
+++ b/include/parted/parted.h
@@ -23,8 +23,6 @@
 extern "C" {
 #endif
 
-typedef struct _PedArchitecture PedArchitecture;
-
 #include <parted/constraint.h>
 #include <parted/device.h>
 #include <parted/disk.h>
@@ -37,18 +35,6 @@ typedef struct _PedArchitecture PedArchitecture;
 #include <stdlib.h>
 #include <string.h>
 
-struct _PedArchitecture {
-	PedDiskArchOps*		disk_ops;
-	PedDeviceArchOps*	dev_ops;
-};
-
-extern const PedArchitecture*	ped_architecture;
-
-/* the architecture can't be changed if there are any PedDevice's.
- * i.e. you should only be doing this if it's the FIRST thing you do...
- */
-extern int ped_set_architecture (const PedArchitecture* arch);
-
 extern const char* ped_get_version ();
 
 extern void* ped_malloc (size_t size);
diff --git a/libparted/Makefile.am b/libparted/Makefile.am
index 0b013cc..8e20a7d 100644
--- a/libparted/Makefile.am
+++ b/libparted/Makefile.am
@@ -17,6 +17,7 @@ lib_LTLIBRARIES	      =	libparted.la
 libparted_la_LDFLAGS  = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
 						-release $(LT_RELEASE)
 libparted_la_SOURCES  = debug.c			\
+			architecture.c	\
 			device.c		\
 			exception.c		\
 			filesys.c		\
diff --git a/libparted/arch/beos.c b/libparted/arch/beos.c
index 6100e15..ee2e5b3 100644
--- a/libparted/arch/beos.c
+++ b/libparted/arch/beos.c
@@ -45,6 +45,8 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
+#include "../architecture.h"
+
 static void
 _scan_for_disks(const char* path)
 {
diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c
index a3af905..c2ef370 100644
--- a/libparted/arch/gnu.c
+++ b/libparted/arch/gnu.c
@@ -37,6 +37,8 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
+#include "../architecture.h"
+
 static int
 _device_get_sector_size (PedDevice* dev)
 {
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 648bd2b..9854f51 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -42,6 +42,7 @@
 #endif
 
 #include "blkpg.h"
+#include "../architecture.h"
 
 #if ENABLE_NLS
 #  include <libintl.h>
diff --git a/libparted/architecture.c b/libparted/architecture.c
new file mode 100644
index 0000000..c102563
--- /dev/null
+++ b/libparted/architecture.c
@@ -0,0 +1,42 @@
+ /*
+    libparted - a library for manipulating disk partitions
+    Copyright (C) 2007 Free Software Foundation, Inc.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "architecture.h"
+
+const PedArchitecture* ped_architecture;
+
+void
+ped_set_architecture ()
+{
+	/* Set just once */
+	if (ped_architecture)
+		return;
+
+#ifdef linux
+	extern PedArchitecture ped_linux_arch;
+	const PedArchitecture* arch = &ped_linux_arch;
+#elif defined(__BEOS__)
+	extern PedArchitecture ped_beos_arch;
+	const PedArchitecture* arch = &ped_beos_arch;
+#else
+	extern PedArchitecture ped_gnu_arch;
+	const PedArchitecture* arch = &ped_gnu_arch;
+#endif
+
+	ped_architecture = arch;
+}
diff --git a/libparted/architecture.h b/libparted/architecture.h
new file mode 100644
index 0000000..012af4c
--- /dev/null
+++ b/libparted/architecture.h
@@ -0,0 +1,38 @@
+ /*
+    libparted - a library for manipulating disk partitions
+    Copyright (C) 2007 Free Software Foundation, Inc.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * WARNING: This shouldn't be exported to the API
+ */
+
+#ifndef _LIBPARTED_ARCH_H_INCLUDED
+#define _LIBPARTED_ARCH_H_INCLUDED
+
+#include <parted/disk.h>
+
+struct _PedArchitecture {
+	PedDiskArchOps*		disk_ops;
+	PedDeviceArchOps*	dev_ops;
+};
+typedef struct _PedArchitecture PedArchitecture;
+
+extern const PedArchitecture*	ped_architecture;
+
+extern void ped_set_architecture ();
+
+#endif /* _LIBPARTED_ARCH_H_INCLUDED */
diff --git a/libparted/device.c b/libparted/device.c
index cbf5a38..e4bbb02 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -44,6 +44,8 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include "architecture.h"
+
 static PedDevice*	devices; /* legal advice says: initialized to NULL,
 				    under section 6.7.8 part 10
 				    of ISO/EIC 9899:1999 */
diff --git a/libparted/disk.c b/libparted/disk.c
index aae2ccf..087fbbf 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -37,6 +37,8 @@
 #include <parted/parted.h>
 #include <parted/debug.h>
 
+#include "architecture.h"
+
 #if ENABLE_NLS
 #  include <libintl.h>
 #  define _(String) dgettext (PACKAGE, String)
diff --git a/libparted/libparted.c b/libparted/libparted.c
index a8c7f0a..9759174 100644
--- a/libparted/libparted.c
+++ b/libparted/libparted.c
@@ -22,13 +22,7 @@
 #include <parted/parted.h>
 #include <parted/debug.h>
 
-#ifdef linux
-#  include <parted/linux.h>
-#elif defined(__BEOS__)
-#  include <parted/beos.h>
-#else
-#  include <parted/gnu.h>
-#endif
+#include "architecture.h"
 
 #if ENABLE_NLS
 #  include <locale.h>
@@ -38,8 +32,6 @@
 #  define _(String) (String)
 #endif /* ENABLE_NLS */
 
-const PedArchitecture* ped_architecture;
-
 /* ped_malloc() debugging.  Stick the address and size of memory blocks that
  * weren't ped_free()d in here, and an exception will be thrown when it is
  * allocated.  That way, you can find out what, exactly, the allocated thing
@@ -72,15 +64,6 @@ static pointer_size_type dodgy_malloc_list[] = {
 static int	dodgy_memory_active[100];
 #endif /* DEBUG */
 
-int
-ped_set_architecture (const PedArchitecture* arch)
-{
-	PED_ASSERT (ped_device_get_next (NULL) == NULL, return 0);
-
-	ped_architecture = arch;
-	return 1;
-}
-
 extern void ped_disk_aix_init ();
 extern void ped_disk_bsd_init ();
 extern void ped_disk_dvh_init ();
@@ -189,16 +172,7 @@ _init()
 #ifdef ENABLE_FS
 	init_file_system_types ();
 #endif
-
-	/* FIXME: a better way of doing this? */
-#ifdef linux
-	ped_set_architecture (&ped_linux_arch);
-#elif defined(__BEOS__)
-	ped_set_architecture (&ped_beos_arch);
-#else
-	ped_set_architecture (&ped_gnu_arch);
-#endif
-
+	ped_set_architecture ();
 #ifdef DEBUG
 	memset (dodgy_memory_active, 0, sizeof (dodgy_memory_active));
 #endif

commit dc8582efb6077fe129ccfa9f7ed1827adaed5abd
Author: Otavio Salvador <otavio at ossystems.com.br>
Date:   Fri Nov 2 18:42:52 2007 -0200

    parted/geom.h: move includes to after type definition to avoids dependency

diff --git a/include/parted/geom.h b/include/parted/geom.h
index 58fd900..0982c8e 100644
--- a/include/parted/geom.h
+++ b/include/parted/geom.h
@@ -26,9 +26,6 @@
 #ifndef PED_GEOM_H_INCLUDED
 #define PED_GEOM_H_INCLUDED
 
-#include <parted/device.h>
-#include <parted/timer.h>
-
 typedef struct _PedGeometry	PedGeometry;
 
 /**
@@ -41,6 +38,9 @@ struct _PedGeometry {
 	PedSector		end;
 };
 
+#include <parted/device.h>
+#include <parted/timer.h>
+
 extern int ped_geometry_init (PedGeometry* geom, const PedDevice* dev,
 			      PedSector start, PedSector length);
 extern PedGeometry* ped_geometry_new (const PedDevice* dev, PedSector start,

commit c6512c3665a665fda583f3e68be497ed0800befb
Author: Otavio Salvador <otavio at ossystems.com.br>
Date:   Fri Nov 2 18:42:48 2007 -0200

    parted/device.h: move includes to after type definition to avoids dependency

diff --git a/include/parted/device.h b/include/parted/device.h
index ee92de9..fed39be 100644
--- a/include/parted/device.h
+++ b/include/parted/device.h
@@ -26,9 +26,6 @@
 #ifndef PED_DEVICE_H_INCLUDED
 #define PED_DEVICE_H_INCLUDED
 
-#include <parted/constraint.h>
-#include <parted/timer.h>
-
 /** We can address 2^63 sectors */
 typedef long long PedSector;
 
@@ -117,6 +114,9 @@ struct _PedDeviceArchOps {
         void (*probe_all) ();
 };
 
+#include <parted/constraint.h>
+#include <parted/timer.h>
+
 extern void ped_device_probe_all ();
 extern void ped_device_free_all ();
 

commit 31337a2c8dc72283ae76d0a795785d8800985cd9
Author: Otavio Salvador <otavio at ossystems.com.br>
Date:   Fri Nov 2 14:57:32 2007 -0200

    parted/filesys.h doesn't use stdio.h, parted/disk.h and parted/exception.h

diff --git a/include/parted/filesys.h b/include/parted/filesys.h
index eacfa72..9d8025c 100644
--- a/include/parted/filesys.h
+++ b/include/parted/filesys.h
@@ -31,11 +31,8 @@ typedef struct _PedFileSystemType	PedFileSystemType;
 typedef const struct _PedFileSystemOps	PedFileSystemOps;
 
 #include <parted/geom.h>
-#include <parted/disk.h>
-#include <parted/exception.h>
 #include <parted/constraint.h>
 #include <parted/timer.h>
-#include <stdio.h>
 
 struct _PedFileSystemOps {
 	PedGeometry* (*probe) (PedGeometry* geom);



More information about the Parted-commits mailing list