[Libburn] Proposal about .location, burn_drive_scan et al.

scdbackup at gmx.net scdbackup at gmx.net
Fri Feb 10 11:19:06 PST 2006


Hi,

hereby asking for comments about this combined proposal for
the clarification of burn_drive_info.location , 
a persistent drive identifier and a method to keep
drive scan from running into unnessesary trouble :


For the drive identifier i propose a tree address structure 
like with a simple filesystem. 
Currently libburn will only use 
  /dev/sg*
  /dev/hd*
"/dev" will be reserved for classical file system access.
Future HAL devices for example could be mapped into something
like
  /hal/further/path/to/be/defined/in/future
This will be very extensible and causes nearly no effort now
because Linus et al. already donated a first set of identifiers.

This addressing scheme will not be backed by a real database
but will be only a consistent unambigous encoding for the
identity of drive objects.
It will make use of the persistent management handles of the
hardware access layer. Whatever such layer is used, it will
have some persistent device names or properties ... i hope.


burn_drive_info.location should be declared a bit more abstract
because else it would lose its meaning as soon as non filesystem
based device access systems are used.


The function to perform a single-drive scan will then refer to
the drive identifier rather than to the location.

It will be implemented by help of a whitelist which has to be
queried by the drive enumeration functions before the drives
get opened for in depth examination. Nothing that can stall or 
cause other trouble may be performed before that whitelist test.
Future hardware access facilities will have to query the
whitelist too, before they access the drive itself.


It will be very easy to implement a subset scan rather than a
single drive scan. It will also be easy to extend this by a
blacklist facility or regular expressions or other queries.


This would roughly cause the following changes:
------------------------------------------------------------------------
In libburn.h :

struct burn_drive_info
{
        /** Unique drive identifier which is as persistent as possible */
        char drive_id[81];
...
        /** Location of the drive in the filesystem or other address
            related to system administration of the drive. 
            (Not guaranteed to be unique, depends on hardware access facility)
        */
        char location[17];
...
};

...

/** Does the same as burn_drive_scan() but will at most return
    the drive with the given drive identifier. Different from
    burn_drive_scan() this function returns a final decision about
    the availability of the desired drive and does not need to be
    called in a loop.
    @param drive returns a single element array with the eventually found drive
    @param id has to match exactly with the found *drives[0].drive_id
    @return 1 if a drive was found , 0 else
*/
int burn_drive_scan_single(struct burn_drive_info *drives[], const char *id);


---------------------------------------------------------------------
In drive.c:

static int drive_getcaps(struct burn_drive *d, struct burn_drive_info *out)
{
...
        strncpy(out->drive_id, d->devname, 80);
        out->location[80] = '\0';
...
}

...

static char *enumeration_whitelist[BURN_DRIVE_WHITELIST_LEN];
static int enumeration_whitelist_top = -1;

/** Add a device to the list of permissible drives. As soon as some entry is in
    the whitelist all non-listed drives are banned from enumeration.
    @return 1 success, <=0 failure
*/
static int burn_drive_add_whitelist(char *drive_id)
{ ... }

/** Remove all drives from whitelist. This enables all possible drives. */
static void burn_drive_clear_whitelist(void)
{ ... }

/** To be called by the enumeration functions of libburn */
int burn_drive_is_banned(char *drive_id)
{ ... }

int burn_drive_scan_single(struct burn_drive_info *drives[], const char *id)
{
        burn_drive_clear_whitelist();
        if(burn_drive_add_whitelist(id) <= 0)
                 return 0;
        /* ... loop around   burn_drive_scan()  ... */
}


---------------------------------------------------------------------
In sg.c:

int burn_drive_is_banned(char *drive_id);

...

void ata_enumerate(void)
{
        ...
        for (i = 0; i < 26; i++) {
               sprintf(fname, "/dev/hd%c", 'a' + i);
               /* This is not HAL:
                  In this function "/dev/hdX" is really the drive id */
               if (burn_drive_is_banned(fname))
                       continue;
        ...
}

void sg_enumerate(void)
{
        ...
        for (i = 0; i < 32; i++) {
               sprintf(fname, "/dev/sg%d", i);
               /* This is not HAL:
                  In this function "/dev/sgN" is really the drive id */
               if (burn_drive_is_banned(fname))
                       continue;
        ...
}

---------------------------------------------------------------------

Derek and Dana:
I hope to have addressed all your concerns.
If i missed some, give me a little kick.

If you can agree with this plan then i would implement it
into the fresh CVS snapshot when the fd-patch is installed.
Afterwards i could give up my own temporary libburn-0.2 fork.


Have a nice day :)

Thomas



More information about the libburn mailing list