public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Nikos Skalkotos <skalkoto@grnet.gr>
Cc: util-linux@vger.kernel.org, synnefo-devel@googlegroups.com
Subject: Re: Support for the new OpenBSD disklabel format
Date: Fri, 13 Dec 2013 12:45:55 +0100	[thread overview]
Message-ID: <20131213114555.GA16096@x2.net.home> (raw)
In-Reply-To: <52AAE5FF.90403@grnet.gr>

On Fri, Dec 13, 2013 at 12:48:31PM +0200, Nikos Skalkotos wrote:
> > Now the library is good enough for dialogs driven interfaces (like
> > fdisk), but it's necessary to improve it for programs like cfdisk and
> > sfdisk. Now I'm working on new cfdisk.
> 
> Actually I wanted to ask you about this. I've seen the fdisk_ask struct
> and how the client can registers an ask_callback function, but it's not
> clear to me how you are planning to allow programs to use the
> library in an unattended way. Are you going to provide new methods

See libfdisk branch on github. There is a new 'struct fdisk_partition'
and some functions to modify this struct (well, it's not complete
yet). The idea is to use the struct as template for operations like
add partition. So the primary source for information will be the
template otherwise label drivers will ask by fdisk_ask API.

> If you rewrite sfdisk to use the library, I'll get all the answers I 
> need. :-)

Probably something like:

  struct fdisk_partition *pa = fdisk_new_partition();

  fdisk_partition_enable_default_start(pa);
  fdisk_partition_set_size(pa, 1024 * 1024 * 1024);

  fdisk_add_partition(cxt, pa);

to create 1GiB partition at the begin of the free space.

I can also imagine something like --interactive for sfdisk, so it will
possible to use incomplete input and then it will ask for the missing
things.

I guess it will be usable in python binding, because "*pa" could be an
object, so you can do things like:

 cxt = FdiskContext("/dev/sda")
 pa = FdiskPartition()
 pa[SIZE] = 1024 * 1024 * 1024
 pa[START] = FDISK_DEFAULT

 cxt.add(pa);

or so....

> or are you going to document the data each method will ask
> for to allow the user to provide the answers in advance?

I thought about it, for example add names for the ask API questions to
make it possible for the ask_callback function to detect what exactly is
wanted. But it seems to complex and callbacks driven libraries suck :-)  
(except UI events libs, etc.)

It would be probably better to keep the current ask API restricted to
things like err/warn messages, tables outputs and simple dialogs for
programs like fdisk.


Anyway, I believe that dialog driven fdisk is the best possible way
for advanced users because you can *talk* directly with label specific
code about label specific stuff. It's better than use extra
abstraction layers to describe labels and devices.  Unfortunately, for
programs like sfdisk we need something else (but I still believe that
we can make things in more lightweight way compare to libparted ;-)

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

      reply	other threads:[~2013-12-13 11:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-02 17:21 Support for the new OpenBSD disklabel format Nikos Skalkotos
2013-12-10 10:32 ` Karel Zak
2013-12-13 10:48   ` Nikos Skalkotos
2013-12-13 11:45     ` Karel Zak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131213114555.GA16096@x2.net.home \
    --to=kzak@redhat.com \
    --cc=skalkoto@grnet.gr \
    --cc=synnefo-devel@googlegroups.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox