* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <errno.h>
#include <dirent.h>
-#include <liblustre.h>
-#include <obd.h>
-#include <lustre_lib.h>
#include <lustre/lustreapi.h>
-#include <obd_lov.h>
-
-#include <lnet/lnetctl.h>
-
#define MAX_LOV_UUID_COUNT 1000
union {
*/
int read_proc_entry(char *proc_path, char *buf, int len)
{
- int rc, fd;
-
- memset(buf, 0, len);
-
- fd = open(proc_path, O_RDONLY);
- if (fd == -1) {
- llapi_error(LLAPI_MSG_ERROR, -errno, "open('%s') failed: %s\n",
- proc_path);
- return -2;
- }
-
- rc = read(fd, buf, len - 1);
- if (rc < 0) {
- llapi_error(LLAPI_MSG_ERROR, -errno,
- "read('%s') failed: %s\n", proc_path);
- rc = -3;
- } else if (rc == 0) {
- llapi_err_noerrno(LLAPI_MSG_ERROR,
- "read('%s') zero bytes\n", proc_path);
- rc = -4;
- } else if (/* rc > 0 && */ buf[rc - 1] == '\n') {
- buf[rc - 1] = '\0'; /* Remove trailing newline */
- }
- close(fd);
-
- return (rc);
+ int rc, fd;
+
+ memset(buf, 0, len);
+
+ fd = open(proc_path, O_RDONLY);
+ if (fd < 0) {
+ llapi_error(LLAPI_MSG_ERROR, -errno, "cannot open '%s'",
+ proc_path);
+ return -2;
+ }
+
+ rc = read(fd, buf, len - 1);
+ if (rc < 0) {
+ llapi_error(LLAPI_MSG_ERROR, -errno,
+ "error reading from '%s'", proc_path);
+ rc = -3;
+ } else if (rc == 0) {
+ llapi_err_noerrno(LLAPI_MSG_ERROR,
+ "read zero bytes from '%s'", proc_path);
+ rc = -4;
+ } else if (buf[rc - 1] == '\n') {
+ buf[rc - 1] = '\0'; /* Remove trailing newline */
+ }
+
+ close(fd);
+
+ return rc;
}
int compare(struct lov_user_md *lum_dir, struct lov_user_md *lum_file1,
int i;
FILE *fp;
- fp = popen("\\ls -d /proc/fs/lustre/lov/*clilov* | head -1", "r");
- if (!fp) {
- llapi_error(LLAPI_MSG_ERROR, -errno,
- "open(lustre/lov/*clilov*) failed: %s\n");
- return 2;
- }
- if (fscanf(fp, "%s", lov_path) < 1) {
- llapi_error(LLAPI_MSG_ERROR, -EINVAL,
- "read(lustre/lov/*clilov*) failed: %s\n");
- pclose(fp);
- return 3;
+ fp = popen("\\ls -d /proc/fs/lustre/lov/*clilov* | head -1", "r");
+ if (fp == NULL) {
+ llapi_error(LLAPI_MSG_ERROR, -errno,
+ "open(lustre/lov/*clilov*) failed");
+ return 2;
}
+
+ if (fscanf(fp, "%s", lov_path) < 1) {
+ llapi_error(LLAPI_MSG_ERROR, -EINVAL,
+ "read(lustre/lov/*clilov*) failed");
+ pclose(fp);
+ return 3;
+ }
+
pclose(fp);
snprintf(tmp_path, sizeof(tmp_path) - 1, "%s/stripecount",
return rc;
}
- lum_size = lov_mds_md_size(MAX_LOV_UUID_COUNT, LOV_MAGIC);
- if ((lum_dir = (struct lov_user_md *)malloc(lum_size)) == NULL) {
- rc = -ENOMEM;
- llapi_error(LLAPI_MSG_ERROR, rc,
- "error: can't allocate %d bytes "
- "for dir EA", lum_size);
- goto cleanup;
- }
+ lum_size = lov_user_md_size(MAX_LOV_UUID_COUNT, LOV_USER_MAGIC);
+ lum_dir = (struct lov_user_md *)malloc(lum_size);
+ if (lum_dir == NULL) {
+ rc = -ENOMEM;
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "error: can't allocate %d bytes "
+ "for dir EA", lum_size);
+ goto cleanup;
+ }
rc = llapi_file_get_stripe(argv[1], lum_dir);
if (rc) {