:: Re: [DNG] issue with procps, any hi…
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Hendrik Boom
Ημερομηνία:  
Προς: dng
Αντικείμενο: Re: [DNG] issue with procps, any hints?
On Wed, Dec 21, 2022 at 09:43:10PM +0100, aitor wrote:
...
...
>
> 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
>
> .....


I thought a GPT disk could have far more than 16 partitions.
What happens past 16?

-- hendrik

>
> 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.
>