Whamcloud - gitweb
LU-2995 osd: Delete the ref of remote parent in del ..
[fs/lustre-release.git] / lustre / utils / mount_utils_ldiskfs.c
index c7f551f..b8efddc 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -47,6 +47,7 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#include "mount_utils.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -78,7 +79,6 @@
 #include <lustre_param.h>
 #include <lnet/lnetctl.h>
 #include <lustre_ver.h>
-#include "mount_utils.h"
 
 #define MAX_HW_SECTORS_KB_PATH "queue/max_hw_sectors_kb"
 #define MAX_SECTORS_KB_PATH    "queue/max_sectors_kb"
@@ -219,11 +219,9 @@ int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *mo_ldd)
                if (num_read < 1 && ferror(filep)) {
                        fprintf(stderr, "%s: Unable to read from file %s: %s\n",
                                progname, filepnm, strerror(errno));
-                       goto out_close;
                }
+               fclose(filep);
        }
-out_close:
-       fclose(filep);
 
        snprintf(cmd, cmdsz, "rm -rf %s", tmpdir);
        run_command(cmd, cmdsz);
@@ -289,7 +287,7 @@ static int file_in_dev(char *file_name, char *dev_name)
                pclose(fp);
                return 1;
        }
-       i = fread(debugfs_cmd, 1, sizeof(debugfs_cmd), fp);
+       i = fread(debugfs_cmd, 1, sizeof(debugfs_cmd) - 1, fp);
        if (i) {
                debugfs_cmd[i] = 0;
                fprintf(stderr, "%s", debugfs_cmd);
@@ -348,7 +346,8 @@ static int is_e2fsprogs_feature_supp(const char *feature)
                        fprintf(stderr, "%s: %s\n", progname, strerror(errno));
                        return 0;
                }
-               ret = fread(supp_features, 1, sizeof(supp_features), fp);
+               ret = fread(supp_features, 1, sizeof(supp_features) - 1, fp);
+               supp_features[ret] = '\0';
                fclose(fp);
        }
        if (ret > 0 && strstr(supp_features,
@@ -1106,6 +1105,7 @@ static int is_feature_enabled(const char *feature, const char *devpath)
        char cmd[PATH_MAX];
        FILE *fp;
        char enabled_features[4096] = "";
+       int ret = 1;
 
        snprintf(cmd, sizeof(cmd), "%s -R features %s 2>&1",
                 DEBUGFS, devpath);
@@ -1118,7 +1118,8 @@ static int is_feature_enabled(const char *feature, const char *devpath)
                return 0;
        }
 
-       fread(enabled_features, 1, sizeof(enabled_features), fp);
+       ret = fread(enabled_features, 1, sizeof(enabled_features) - 1, fp);
+       enabled_features[ret] = '\0';
        fclose(fp);
 
        if (strstr(enabled_features, feature))