[Ocfs2-tools-commits] mfasheh commits r848 - in trunk: fsck.ocfs2 libo2cb libo2cb/include mkfs.ocfs2 mount.ocfs2 mounted.ocfs2 o2cb_ctl ocfs2_hb_ctl tunefs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Apr 26 20:58:44 CDT 2005


Author: mfasheh
Signed-off-by: jlbec
Date: 2005-04-26 20:58:42 -0500 (Tue, 26 Apr 2005)
New Revision: 848

Added:
   trunk/libo2cb/include/ocfs2_nodemanager.h
Modified:
   trunk/fsck.ocfs2/fsck.c
   trunk/libo2cb/include/o2cb.h
   trunk/libo2cb/o2cb_abi.c
   trunk/libo2cb/o2cb_err.et
   trunk/mkfs.ocfs2/check.c
   trunk/mount.ocfs2/mount.ocfs2.c
   trunk/mounted.ocfs2/mounted.c
   trunk/o2cb_ctl/o2cb_ctl.c
   trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c
   trunk/tunefs.ocfs2/tunefs.c
Log:
* Update the toolchain to check against the version published by our
  module.

Signed-off-by: jlbec



Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/fsck.ocfs2/fsck.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -498,6 +498,12 @@
 		}
 	}
 
+	ret = o2cb_init();
+	if (ret) {
+		com_err(whoami, ret, "Cannot initialize cluster\n");
+		fsck_mask |= FSCK_ERROR;
+		goto out;
+	}
 
 	if (blksize % OCFS2_MIN_BLOCKSIZE) {
 		fprintf(stderr, "Invalid blocksize: %"PRId64"\n", blksize);

Modified: trunk/libo2cb/include/o2cb.h
===================================================================
--- trunk/libo2cb/include/o2cb.h	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/libo2cb/include/o2cb.h	2005-04-27 01:58:42 UTC (rev 848)
@@ -47,6 +47,8 @@
 #include <o2cb/o2cb_err.h>
 #endif
 
+errcode_t o2cb_init(void);
+
 errcode_t o2cb_create_cluster(const char *cluster_name);
 errcode_t o2cb_remove_cluster(const char *cluster_name);
 

Added: trunk/libo2cb/include/ocfs2_nodemanager.h
===================================================================
--- trunk/libo2cb/include/ocfs2_nodemanager.h	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/libo2cb/include/ocfs2_nodemanager.h	2005-04-27 01:58:42 UTC (rev 848)
@@ -0,0 +1,39 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * ocfs2_nodemanager.h
+ *
+ * Header describing the interface between userspace and the kernel
+ * for the ocfs2_nodemanager module.
+ *
+ * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ *
+ */
+
+#ifndef _OCFS2_NODEMANAGER_H
+#define _OCFS2_NODEMANAGER_H
+
+#define NM_API_VERSION		1
+
+#define NM_MAX_NODES		255
+#define NM_INVALID_SLOT_NUM	255
+
+/* host name, group name, cluster name all 64 bytes */
+#define NM_MAX_NAME_LEN          64    // __NEW_UTS_LEN
+
+#endif /* _OCFS2_NODEMANAGER_H */

Modified: trunk/libo2cb/o2cb_abi.c
===================================================================
--- trunk/libo2cb/o2cb_abi.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/libo2cb/o2cb_abi.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -47,6 +47,8 @@
 
 #include "o2cb_crc32.h"
 
+#include "ocfs2_nodemanager.h"
+
 errcode_t o2cb_create_cluster(const char *cluster_name)
 {
 	char path[PATH_MAX];
@@ -407,6 +409,58 @@
 	return err;
 }
 
+#define O2CB_NM_REVISION_PATH	"/proc/fs/ocfs2_nodemanager/interface_revision"
+errcode_t o2cb_init(void)
+{
+	int ret, fd;
+	unsigned int module_version;
+	errcode_t err;
+	char revision_string[16];
+
+	fd = open(O2CB_NM_REVISION_PATH, O_RDONLY);
+	if (fd == -1) {
+		switch (errno) {
+			default:
+				err = O2CB_ET_INTERNAL_FAILURE;
+				break;
+
+			case ENOTDIR:
+			case ENOENT:
+			case EISDIR:
+				err = O2CB_ET_SERVICE_UNAVAILABLE;
+				break;
+
+			case EACCES:
+			case EPERM:
+			case EROFS:
+				err = O2CB_ET_PERMISSION_DENIED;
+				break;
+		}
+		return err;
+	}
+
+	ret = do_read(fd, revision_string, sizeof(revision_string) - 1);
+	close(fd);
+
+	if (ret < 0) {
+		err = O2CB_ET_INTERNAL_FAILURE;
+		if (ret == -EIO)
+			err = O2CB_ET_IO;
+		return err;
+	}
+
+	revision_string[ret] = '\0';
+
+	ret = sscanf(revision_string, "%u\n", &module_version);
+	if (ret < 0)
+		return O2CB_ET_INTERNAL_FAILURE;
+
+	if (NM_API_VERSION < module_version)
+		return O2CB_ET_BAD_VERSION;
+
+	return 0;
+}
+
 static errcode_t o2cb_set_region_attribute(const char *cluster_name,
 					   const char *region_name,
 					   const char *attr_name,

Modified: trunk/libo2cb/o2cb_err.et
===================================================================
--- trunk/libo2cb/o2cb_err.et	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/libo2cb/o2cb_err.et	2005-04-27 01:58:42 UTC (rev 848)
@@ -75,4 +75,7 @@
 ec	O2CB_ET_NO_SEM,
 	"Region semaphore set destroyed"
 
+ec	O2CB_ET_BAD_VERSION,
+	"Revision of OCFS2-Tools is out of date."
+
 	end

Modified: trunk/mkfs.ocfs2/check.c
===================================================================
--- trunk/mkfs.ocfs2/check.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/mkfs.ocfs2/check.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -39,6 +39,12 @@
 	initialize_o2dl_error_table();
 	initialize_o2cb_error_table();
 
+	ret = o2cb_init();
+	if (ret) {
+		com_err(s->progname, ret, "Cannot initialize cluster\n");
+		return -1;
+	}
+
 	ret = ocfs2_open(s->device_name, OCFS2_FLAG_RW, 0, 0, &fs);
 	if (ret) {
 		if (ret == OCFS2_ET_OCFS_REV)

Modified: trunk/mount.ocfs2/mount.ocfs2.c
===================================================================
--- trunk/mount.ocfs2/mount.ocfs2.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/mount.ocfs2/mount.ocfs2.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -300,6 +300,12 @@
 	if (ret)
 		goto bail;
 
+	ret = o2cb_init();
+	if (ret) {
+		com_err(progname, ret, "Cannot initialize cluster\n");
+		goto bail;
+	}
+
 	if (verbose)
 		printf("device=%s\n", mo.dev);
 

Modified: trunk/mounted.ocfs2/mounted.c
===================================================================
--- trunk/mounted.ocfs2/mounted.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/mounted.ocfs2/mounted.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -292,6 +292,12 @@
 	if (ret)
 		goto bail;
 
+	ret = o2cb_init();
+	if (ret) {
+		com_err(progname, ret, "Cannot initialize cluster\n");
+		goto bail;
+	}
+
 	ret = ocfs2_detect(device, quick_detect);
 
 bail:

Modified: trunk/o2cb_ctl/o2cb_ctl.c
===================================================================
--- trunk/o2cb_ctl/o2cb_ctl.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/o2cb_ctl/o2cb_ctl.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -1359,16 +1359,25 @@
 gint main(gint argc, gchar *argv[])
 {
     int rc;
+    errcode_t ret;
     O2CBContext ctxt = {0, };
 
     setbuf(stdout, NULL);
     setbuf(stderr, NULL);
 
     initialize_o2cb_error_table();
+
     rc = parse_options(argc, argv, &ctxt);
     if (rc)
         print_usage(rc);
 
+    ret = o2cb_init();
+    if (ret) {
+	com_err(PROGNAME, ret, "Cannot initialize cluster\n");
+	rc = -EINVAL;
+	goto out_error;
+    }
+
     switch (ctxt.oc_op)
     {
         case O2CB_OP_NONE:
@@ -1406,5 +1415,6 @@
         o2cb_config_free(ctxt.oc_config);
     clear_attrs(&ctxt);
 
+out_error:
     return rc;
 }  /* main() */

Modified: trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c
===================================================================
--- trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/ocfs2_hb_ctl/ocfs2_hb_ctl.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -231,6 +231,13 @@
 		goto bail;
 	}
 
+	err = o2cb_init();
+	if (err) {
+		com_err(progname, err, "Cannot initialize cluster\n");
+		ret = -EINVAL;
+		goto bail;
+	}
+
 	if (!hbo.uuid_str) {
 		err = get_uuid(hbo.dev_str, hbuuid);
 		if (err) {

Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c	2005-04-27 01:52:26 UTC (rev 847)
+++ trunk/tunefs.ocfs2/tunefs.c	2005-04-27 01:58:42 UTC (rev 848)
@@ -566,6 +566,12 @@
 
 	get_options(argc, argv);
 
+	ret = o2cb_init();
+	if (ret) {
+		com_err(opts.progname, ret, "Cannot initialize cluster\n");
+		exit(1);
+	}
+
 	ret = ocfs2_open(opts.device, OCFS2_FLAG_RW, 0, 0, &fs);
 	if (ret) {
 		com_err(opts.progname, ret, " ");



More information about the Ocfs2-tools-commits mailing list