[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] initializing parted from an application

From: Neal H Walfield
Subject: Re: [patch] initializing parted from an application
Date: Wed, 15 Aug 2001 22:55:24 +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.
> Can you give an explanation of how this happens?  I'd like to know
> how libparted is being used ;)

I am using libparted in a system library called libstore.  For all
intents and purposes, you can just think of libstore as providing a
slightly more general way to access block devices.  Programs using
libstore may be aware that they are using libstore, however, they should
never need to care what subsystem they are using and how the subsystem
is implemented.

The subsystem that I am adding to libstore is the `partition' subsystem.
Its job is to take a minor number and a source store (e.g. a device,
/dev/hda in Linux speak) and create a new store that contains only the
given partition (i.e. the partition, e.g. /dev/hda1 in Linux speak).  I
am hoping to use parted to help in this job.  As you can imagine, I only
need parted to grok the source and then, I am done with it.

The question remains, however, how do I initialize and deinitialize the
parted subsystem?  Asking the program using libstore to do this is
completely unacceptable.  I came up with three possible solutions: The
parent program explicitly initialized the partition subsystem.  This is
completely unacceptable.  The partition system could initialize
libparted at program creation/destruction time using gcc function
attributes, however, if another library or, even, the main program
itself, uses libparted, this would mean that the initializer and
destructor are called multiple times (and the calls would most likely be
nested).  This is also unreasonable.  Then, there is the option to
initialize the parted subsystem right before use and just after use,
however, this is also unacceptable given the current implementation.

Thus, I see two things that parted can do:  It can either use the gcc
constructor/destructor extension or it can allow nested calls to the
ped_init/ped_done routines.  Personally, I prefer the former.

Attachment: pgpqqoXcTE1jE.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]