about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-04-09 02:45:39 +0000
committerLaurent Bercot <ska@appnovation.com>2022-04-09 02:45:39 +0000
commitc2e67273c1b05bd67eafcda22f88880c015c34dc (patch)
tree44debc48cb282f1cc16015fc52d5888b0d65e60e
parentc1d105e3618c30a5b212786c9bb948d73e825eff (diff)
downloadmdevd-c2e67273c1b05bd67eafcda22f88880c015c34dc.tar.gz
mdevd-c2e67273c1b05bd67eafcda22f88880c015c34dc.tar.xz
mdevd-c2e67273c1b05bd67eafcda22f88880c015c34dc.zip
Adapt to skalibs-2.12.0.0
Need to investigate what pulls vfprintf...

Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/mdevd/mdevd.c48
1 files changed, 4 insertions, 44 deletions
diff --git a/src/mdevd/mdevd.c b/src/mdevd/mdevd.c
index 6bcdf98..f360ac7 100644
--- a/src/mdevd/mdevd.c
+++ b/src/mdevd/mdevd.c
@@ -37,8 +37,7 @@
 #include <skalibs/iopause.h>
 #include <skalibs/socket.h>
 #include <skalibs/skamisc.h>
-#include <skalibs/surf.h>
-#include <skalibs/random.h>
+#include <skalibs/unix-transactional.h>
 
 #include <mdevd/config.h>
 
@@ -60,7 +59,6 @@ static pid_t pid = 0 ;
 static unsigned int verbosity = 1 ;
 static char const *slashsys = "/sys" ;
 static char const *fwbase = "/lib/firmware" ;
-static SURFSchedule surf_ctx = SURFSCHEDULE_ZERO ;
 static unsigned int root_maj, root_min ;
 
 struct envmatch_s
@@ -147,20 +145,6 @@ static inline void script_free (scriptelem *script, unsigned short scriptlen, st
   for (i = 0 ; i < envmatchlen ; i++) regfree(&envmatch[i].re) ;
 }
 
-static inline void mdevd_random_init (void)
-{
-  char seed[160] ;
-  random_makeseed(seed) ;
-  surf_init(&surf_ctx, seed) ;
-}
-
-static inline void surfname (char *s, size_t n)
-{
-  static char const oklist[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ;
-  surf(&surf_ctx, s, n) ;
-  while (n--) s[n] = oklist[s[n] & 63] ;
-}
-
 static inline int mkdirp (char *s)
 {
   size_t n = strlen(s) ;
@@ -793,33 +777,10 @@ static inline int run_scriptelem (struct uevent_s *event, scriptelem const *elem
     {
       if (!makesubdirs(devname)) return -1 ;
       if (dryrun) strerr_warni4x("dry run: symlink ", node, " to ", devname) ;
-      else if (symlink(node, devname) < 0)
+      else if (atomic_symlink(node, devname, "mdevd") < 0)
       {
-        if (errno != EEXIST)
-        {
-          if (verbosity)
-            strerr_warnwu4sys("symlink ", node, " to ", devname) ;
-          return -1 ;
-        }
-        else
-        {
-          char tmppath[devnamelen + 20] ;
-          memcpy(tmppath, devname, devnamelen) ;
-          memcpy(tmppath + devnamelen, ":mdevd-", 7) ;
-          surfname(tmppath + devnamelen + 7, 12) ;
-          tmppath[devnamelen + 19] = 0 ;
-          if (symlink(node, tmppath) < 0)
-          {
-            if (verbosity)
-              strerr_warnwu4sys("symlink ", node, " to ", tmppath) ;
-          }
-          else if (rename(tmppath, devname) < 0)
-          {
-            if (verbosity)
-              strerr_warnwu4sys("rename ", tmppath, " to ", devname) ;
-            unlink_void(tmppath) ;
-          }
-        }
+        if (verbosity) strerr_warnwu4sys("symlink ", node, " to ", devname) ;
+        return -1 ;
       }
     }
   }
@@ -1117,7 +1078,6 @@ int main (int argc, char const *const *argv)
   }
 
   tain_now_set_stopwatch_g() ;
-  mdevd_random_init() ;
   umask(0) ;
 
   while (cont)