]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/rbd_nbd: use POSIX basename()
authorKefu Chai <kchai@redhat.com>
Wed, 3 Jul 2019 04:52:15 +0000 (12:52 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Jul 2019 07:13:17 +0000 (15:13 +0800)
* glibc offers two variants of basename(). one modifies the content of
  `path`, the other does not. to be standard compliant, and to fix
  the FTBFS with musl-libc, we need to use the POSIX variant.
* #include <libgen.h> for basename(3), the POSIX compliant one.

see
http://pubs.opengroup.org/onlinepubs/009695399/functions/basename.html

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/tools/rbd_nbd/rbd-nbd.cc

index bf4195caee51cab0e686c30cb8d275d200745666..6d2f1b113ae141fb53d048320361b8022a3c1048 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "include/int_types.h"
 
+#include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -562,7 +563,7 @@ private:
     ifs >> cmdline;
 
     for (unsigned i = 0; i < cmdline.size(); i++) {
-      const char *arg = &cmdline[i];
+      char *arg = &cmdline[i];
       if (i == 0) {
         if (strcmp(basename(arg) , "rbd-nbd") != 0) {
           return -EINVAL;