:: Re: [DNG] I have a question about l…
Pàgina inicial
Delete this message
Reply to this message
Autor: Didier Kryn
Data:  
A: dng
Assumpte: Re: [DNG] I have a question about libsystemd0 in devuan ascii,
Le 29/06/2017 à 15:15, Didier Kryn a écrit :
>>>       Please find it in attachment. The archive contains four files:

>>>
>>> README
>>> etc/init.d/mdev  -- The start/stop script for Sysvinit
>>> etc/mdev.conf    -- The necessary configuration file for mdev
>>> sbin/mdev-disk   -- An experimental script to manage /dev/disk/by-label
>>>                    -- and /dev/disk/by-uuid

>>>
>>>       I might restart experimenting with it some day...
>> Hmm, something similar could be used to create thoose /dev/disk/by-*,
>> for a static /dev:

>>
>> find /dev -type b | xargs blkid | sort |
>> some_script_to_populate_by_xxx
>>
>> But if that is only a transformed /sys/class/block, wouldn't it be
>> easier if there was a /sys/class/uuid or similar ?
>>
>> Also man blkid says:
>>
>> # man blkid | grep -A6 ' -L label$'
>>         -L label
>>                Look up the device that uses this label (equal to: -l 
>> -o  device
>>                -t  LABEL=<label>).   This lookup method is able to 
>> reliably use
>>                /dev/disk/by-label udev symlinks  (dependent  on a  
>> setting  in
>>                /etc/blkid.conf).   Avoid using the symlinks directly; 
>> it is not
>>                reliable to use  the  symlinks  without 
>> verification.   The  -L
>>                option works on systems with and without udev.

>>
>> so if /dev/disk/by-* isn't reliable, why do we have them ?
>>
>> Regards,
>> /Karl Hammar
>>
>
>    Everybody is using blkid to build thiese links, my script as well 
> as Udev and Vdev. You probably noticed that blkid has a special option 
> for Udev because Udev people are too lazzy to parse the response. In 
> Vdev, Jude made the parsing job to be compatible with Busybox's blkid 
> which hasn't this special format.

>
>    So blkid authors on one hand provide a special format for Udev to 
> create the symlinks, and on the other hand claim that they aren't 
> reliable!


     For people wanting to give a look at what's going through the 
uevent netlink, here is a small C program to dump it:


/* Print uevents from netlink -- Author: Didier Kryn <kryn@???> */
/* With command-line argument "-noudev", skip events from libudev */
#include <asm/types.h>
#include <sys/socket.h>
#include <linux/netlink.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

#define BUFSIZE 4096
int main( int argc, char **argv )
{
char b[BUFSIZE];
struct sockaddr_nl nladdr;
int ns, len, i, noudev;
char *c, *max;

   /*-------------- check option to skip libudev events --------------*/
   noudev = 0;
   if(argc>1)
     {
       if(!strcmp(argv[1], "-noudev")) noudev =1;
       else fprintf(stderr, "nluevent: ignore unknown argument %s\n", 
argv[1]);
     }


   /*---------------- create and open netlink socket -----------------*/
   ns = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
   if( ns == -1 ) goto error;
   len = sizeof(b);
   /* set socket receive buffer size to the size of our own buffer */
   if(geteuid()) i = setsockopt(ns, SOL_SOCKET, SO_RCVBUF, &len, 
sizeof(len));
   else i = setsockopt(ns, SOL_SOCKET, SO_RCVBUFFORCE, &len, sizeof(len));
   if( i< 0) goto error;
   /* set socket address */
   memset(&nladdr, 0, sizeof(struct sockaddr_nl));
   nladdr.nl_family = AF_NETLINK;
   nladdr.nl_pid = getpid();
   nladdr.nl_groups = -1;
   /* bind */
   if ( bind(ns, (void *)&nladdr, sizeof(struct sockaddr_nl)) )
     goto error;


   /*------------------ receive and print forever ------------------*/
   while(1)
     {
       len = recv ( ns, &b, sizeof(b), MSG_TRUNC );
       if(len == -1) break;
       else if(len > sizeof(b))
     {
       fprintf(stderr, "Netlink message exceeded buffer size by %d chars. "
           "Message truncated.\n", len - sizeof(b) );
       len = sizeof(b);
     }


       if(noudev && !strncmp("libudev", b,7)) continue; /* skip libudev 
event */


       max=b+len;
       /* uevent datagrams contain several strings separated by nulls */
       for( c=b; c<max; c++ ) { if(!*c) *c='\n'; } /* replace \0 with \n */
       fputs(b, stdout);


     }


   /*------------------------- exceptions --------------------------*/
     error:
   perror("nluevent");
   return 1;
}