]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
use get_linux_version() instead ad-hoc uname().release parsing 4493/head
authorIlya Dryomov <idryomov@gmail.com>
Mon, 27 Apr 2015 07:49:26 +0000 (10:49 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 29 Apr 2015 10:45:52 +0000 (13:45 +0300)
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/ceph_fuse.cc
src/os/XfsFileStoreBackend.cc

index 76168503d594c71b8ec4debeae32b18d69e48fc2..814d13fdc4efee05eb2d02b4380fddeeb81a8c41 100644 (file)
@@ -30,6 +30,7 @@ using namespace std;
 
 #include "common/Timer.h"
 #include "common/ceph_argparse.h"
+#include "common/linux_version.h"
 #include "global/global_init.h"
 #include "common/safe_io.h"
        
@@ -121,20 +122,11 @@ int main(int argc, const char **argv, const char *envp[]) {
       }
       virtual ~RemountTest() {}
       virtual void *entry() {
-       struct utsname os_info;
-       int tr = uname(&os_info);
-       assert(tr == 0);
-       assert(memcmp(os_info.sysname, "Linux", 5) == 0);
-       int major, minor;       
-       char *end_num;
-       major = strtol(os_info.release, &end_num, 10);
-       assert(major > 0);
-       ++end_num;
-       minor = strtol(end_num, NULL, 10);
+       int ver = get_linux_version();
+       assert(ver != 0);
        bool can_invalidate_dentries = g_conf->client_try_dentry_invalidate &&
-         (major < 3 ||
-          (major == 3 && minor < 18));
-       tr = client->test_dentry_handling(can_invalidate_dentries);
+                                      ver < KERNEL_VERSION(3, 18, 0);
+       int tr = client->test_dentry_handling(can_invalidate_dentries);
        if (tr != 0) {
          cerr << "ceph-fuse[" << getpid()
               << "]: fuse failed dentry invalidate/remount test with error "
index abff01844ea9d055082c3729f114d045f538aa31..cf8bfe1938867abc9787fe4040419e5cc6614c0f 100644 (file)
@@ -24,6 +24,7 @@
 #include <xfs/xfs.h>
 
 #include "common/errno.h"
+#include "common/linux_version.h"
 #include "include/assert.h"
 #include "include/compat.h"
 
@@ -116,24 +117,15 @@ int XfsFileStoreBackend::detect_features()
     //   aff3a9edb7080f69f07fe76a8bd089b3dfa4cb5d
     // for this set_extsize bug
     //   http://oss.sgi.com/bugzilla/show_bug.cgi?id=874
-    struct utsname u;
-    int r = uname(&u);
-    assert(r == 0);
-    int major = 0, minor = 0, patch = 0;
-    r = sscanf(u.release, "%d.%d.%d", &major, &minor, &patch);
-    if (r != 3) {
-      ret = 0;
-      dout(0) << __func__ << ": failed to parse kernel version "
-             << u.release << " to verify extsize not buggy, disabling extsize"
-             << dendl;
+    int ver = get_linux_version();
+    if (ver == 0) {
+      dout(0) << __func__ << ": couldn't verify extsize not buggy, disabling extsize" << dendl;
       m_has_extsize = false;
-    } else if (major < 3 || (major == 3 && minor < 5)) {
-      dout(0) << __func__ << ": disabling extsize, kernel " << u.release
-             << " is older than 3.5 and has buggy extsize ioctl" << dendl;
+    } else if (ver < KERNEL_VERSION(3, 5, 0)) {
+      dout(0) << __func__ << ": disabling extsize, your kernel < 3.5 and has buggy extsize ioctl" << dendl;
       m_has_extsize = false;
     } else {
-      dout(0) << "detect_feature: extsize is supported and kernel "
-             << u.release << " >= 3.5" << dendl;
+      dout(0) << __func__ << ": extsize is supported and your kernel >= 3.5" << dendl;
       m_has_extsize = true;
     }
   } else {