s!/etc/slackware-release!/etc/slackware-version! (reported by bubulak)
[util-vserver.git] / util-vserver / src / save_ctxinfo.c
index 2dd49f0..2f84d3f 100644 (file)
@@ -22,6 +22,7 @@
 #  include <config.h>
 #endif
 
+#include "pathconfig.h"
 #include "vserver.h"
 #include "internal.h"
 #include "util.h"
@@ -52,7 +53,7 @@ checkParams(int argc, char UNUSED * argv[])
 
 int main(int argc, char *argv[])
 {
-  char         runfile[(checkParams(argc,argv),strlen(argv[1])) + sizeof("/run.rev/99999")];
+  char         runfile[(checkParams(argc,argv),strlen(argv[1])) + sizeof(DEFAULT_PKGSTATEREVDIR "/99999")];
   char         dstfile[PATH_MAX];
   int          fd;
   char         buf[sizeof(int)*3+2];
@@ -75,10 +76,11 @@ int main(int argc, char *argv[])
     return 255;
   }
 
-  Ereadlink(runfile, dstfile, sizeof(dstfile));
-  len  = utilvserver_fmt_uint(buf, ctx);
+  len          = EreadlinkD(runfile, dstfile, sizeof(dstfile)-1);
+  dstfile[len] = '\0';
+  len          = utilvserver_fmt_uint(buf, ctx);
 
-  fd = Eopen(dstfile, O_EXCL|O_CREAT|O_WRONLY, 0644);
+  fd = EopenD(dstfile, O_EXCL|O_CREAT|O_WRONLY, 0644);
   if (write(fd, buf,     len) !=len  ||
       write(fd, "\n",    1)   !=1) {
     perror("save_ctxinfo: write()");
@@ -86,10 +88,10 @@ int main(int argc, char *argv[])
   }
   Eclose(fd);
 
-  strcat(runfile, ".rev/");
-  strcat(runfile, buf);
+  strcpy(runfile, DEFAULT_PKGSTATEREVDIR "/");
+  strncat(runfile, buf, len);
   unlink(runfile);
-  Esymlink(argv[1], runfile);
+  EsymlinkD(argv[1], runfile);
 
   Eexecv(argv[2], argv+2);
 }