[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] initializing parted from an application
From: |
Neal H Walfield |
Subject: |
[patch] initializing parted from an application |
Date: |
Tue, 14 Aug 2001 10:43:51 +0200 |
User-agent: |
Mutt/1.3.18i |
When using parted in multiple subsystems, it can be difficult to manage
who is going to initialize the parted subsystem and even worse, who is
going to call ped_done (). This patch makes that behavior recursive.
This problem is prevalent when the main application is not aware that it
is using libparted.
The change log:
2001-08-13 Neal H Walfield <address@hidden>
* libparted/libparted.c (init_count): New, static, variable.
(ped_init): Only initialize libparted if init_count == 0.
(ped_done): Only deinitialize libparted if init_count == 1.
diff --exclude aclocal.m4 --exclude configure --exclude Makefile.in -urNp
parted-1.5.4-pre1.orig/libparted/libparted.c
parted-1.5.4-pre1/libparted/libparted.c
--- parted-1.5.4-pre1.orig/libparted/libparted.c Sun Jul 15 07:38:16 2001
+++ parted-1.5.4-pre1/libparted/libparted.c Mon Aug 13 17:32:20 2001
@@ -119,9 +119,14 @@ done_disk_types ()
ped_disk_sun_done ();
}
+static int init_count;
+
int
ped_init ()
{
+ if (init_count ++ > 0)
+ return 1;
+
if (getlogin())
initgroups (getlogin(), 0);
@@ -164,6 +169,9 @@ done_file_system_types ()
void
ped_done ()
{
+ if (-- init_count > 0)
+ return;
+
ped_device_free_all ();
done_disk_types ();
pgpvZVBuWYubw.pgp
Description: PGP signature
- [patch] initializing parted from an application,
Neal H Walfield <=
- Re: [patch] initializing parted from an application, Andrew Clausen, 2001/08/15
- Re: [patch] initializing parted from an application, Neal H Walfield, 2001/08/15
- Re: [patch] initializing parted from an application, Andrew Clausen, 2001/08/15
- Re: [patch] initializing parted from an application, Neal H Walfield, 2001/08/15
- Re: [patch] initializing parted from an application, Andrew Clausen, 2001/08/16
- Re: [patch] initializing parted from an application, Neal H Walfield, 2001/08/16
- Re: [patch] initializing parted from an application, Neal H Walfield, 2001/08/16
- Re: [patch] initializing parted from an application, Andrew Clausen, 2001/08/17