Difference removing a partitition again: a launch manger.

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

 



Hello,

I was dealing with detecting the difference between the event a
partition is removed when
the whole disk is removed (for example removeable drives) and the
removal of a partition
through a partitionmanager.

Udev does not see any difference.

What I see happen:

generally when a partition is removed when a device is taken out:

- first all the individual partitions are removed
- finally the whole disk is removed (type=disk)

when a partition is removed through a partmanager:

- a partition is removed
- the whole disk is changed (the partitiontable!)

(the same order when a partition is added through partmanager)

Now I've made a construction using the at daemon
to run scripts initiated by udev events. Generally it's good idea to use
such a launch manager which takes care of the launching of all kinds of scripts,
you don't want udev to wait for a script to finish, while waiting not
being able
to continue what it's doing, detection  hardware changes.

An overview:

an hardware event

a rule tells udev to run a script

this script creates a list of commands to be run, if this list already
exist (and is not too old) adds them
to this list.

the launching of the commands on this list takes place after a short
time (a few seconds) This list is sorted and
doubles are removed, and then finally the desired scripts are launched
in a certain preferred order.


I've added some extra scripts to at to make this waiting, sorting and
queuing  them possible.

The reason for me is to introduce the ability for a at job to wait for
some time (a few seconds),
and then queue a list of commands.
Why? When just running scripts launched by udev events, it will get a
mess, cause there are a lot
of events when just removing a partition.

They are all related, but the launch manager (the at daemon) does not
"know" that,
and all the scrips will be launched, which is not what you want.
My construction provides ways to "streamline" the  launching these scripts.
It does so by waiting a short period to gather all the information
coming from udev,
does some sorting and deleting double jobs, and finally launch them in
a preferred order.

Maybe I should publish this construction (on my gitorious page for
example), cause it's good
thing to have a "launch" manager next to udev.

There is being worked on launch mangers like Upstart an system.d,
which you can use for this purpose,
but maybe to have some other solution, only to compare is a good thing.

Through the use of at as launch manager and the ability to "gather"
all the queued jobs
before launching them, it's easy to distinguish the removal of a
partition as part
of the removal of the whole disk, and the removal when using a partitionmanager.

In the first case, there is always a "remove the whole disk" command
(next to the remove the partition),
and in the second case that's not so, there is a "change the whole
disk" instead.

When adding a partition, there is an "add the whole disk" when
inserting the disk (next to the add the partition),
and there is an "change the whole disk" instead when inserting the disk.


A lot of words, I hope you made it to the end.

Stef

PS I've developed this as part of my construction to create
userfriendly access to all kinds of mountable resources,
remote like smb shares, ftp servers AND local like USB devices,
harddisks and cdroms.

See:

http://linux.bononline.nl/linux/mount.md5key.new/

You do not find anything about the launch manager yet. I've worked on
it the last weeks, and not published yet.
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux