:: Re: [DNG] issue with procps, any hi…
Top Pagina
Delete this message
Reply to this message
Auteur: aitor
Datum:  
Aan: dng
Onderwerp: Re: [DNG] issue with procps, any hints?
Hi,

On 21/12/22 18:55,dng@??? wrote:

> But
>        using procps is an interesting option.


pstat, did you mean...?

The problem of scanning files like /etc/fstab is that you can find things like this:

/dev/mapper/sysvg-lvroot /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=73ed670d-91d3-4d36-a16e-ab152eba120b /boot           ext4    defaults        0       2
/dev/mapper/sysvg-lvhome /home           ext4    defaults        0       2
/dev/mapper/sysvg-lvswap none            swap    sw              0       0

which is not very illustrative. This is the case of a partitioning done with LVM.

The key of my porposal resides in the fact that pstat will always give you the major:minor
numbers concerning to the root partition of the running system.

Bear in mind that:

8:0 -> represents sda

8:1 -> represents sda1

.....

8:16 -> represents sdb

8:17 -> represents sdb1

.....

8:32 -> represents sdc

8:33 -> represents sdc1

.....

In general:

MAJOR = 7 represents "loop*"
MAJOR = 8 represents "sd*"


My suggestion is:

"if pstat gives you, say for example 8:17, then skip all the partitions from 8:16 to 8:31"

In the case of a logical volume manager partition like above, pstat gave me the device 254:1
involving /dev/mapper/sysvg-lvroot. Then, we should skip the whole the mapping table for the
device from 254:0 to 254:15.

In hopman, the major and minor numbers can be obtained in a very easy way between the lines
41 - 47 of the file:

https://git.devuan.org/kryn/hopman/src/branch/master/hopman-1.1/watch/init_list.c

by the following way:



     #include <sys/sysmacros.h>

      ( .... code  ...  )

      if( (devstat.st_mode & S_IFMT) == S_IFBLK )
    {

          int major = (int)major(devstat.st_dev);
          int minor = (int)minor(devstat.st_dev);


        / **

              PUT THE CONDITIONALS HERE:   skip or not skip?

          **/

         if(hotplug_partition(E->d_name))
        {
           partition_new(E->d_ino, E->d_name);
        }
    }

In order to get the MAJOR:MINOR from pstat, i added a new routine to Jude Nelson's libpstat.
So, a couple of lines together with the header would be enough for hopman. Libpstat compiles
in 1 second without dependencies. And it's also OS agnostic.

IMHO, this is a very simple and reliable choice.

Cheers,

Aitor.