[Ocfs2-tools-commits] smushran commits r218 - in trunk: . mounted.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Tue Sep 7 17:15:23 CDT 2004


Author: smushran
Date: 2004-09-07 17:15:21 -0500 (Tue, 07 Sep 2004)
New Revision: 218

Added:
   trunk/mounted.ocfs2/
   trunk/mounted.ocfs2/Cscope.make
   trunk/mounted.ocfs2/Makefile
   trunk/mounted.ocfs2/mounted.c
Log:
added mounted.ocfs2

Added: trunk/mounted.ocfs2/Cscope.make
===================================================================
--- trunk/mounted.ocfs2/Cscope.make	2004-09-07 22:09:41 UTC (rev 217)
+++ trunk/mounted.ocfs2/Cscope.make	2004-09-07 22:15:21 UTC (rev 218)
@@ -0,0 +1,10 @@
+.PHONY: cscope
+cscope:
+	rm -f cscope.*
+	echo "-k" >> cscope.files
+	echo "-I inc" >> cscope.files
+	find . -maxdepth 2 -name '*.c' -print >>cscope.files
+	find . -maxdepth 2 -name '*.h' -print >>cscope.files
+	find ../libocfs2/ -maxdepth 2 -name '*.c' -print >>cscope.files
+	find ../libocfs2/ -maxdepth 2 -name '*.h' -print >>cscope.files
+	cscope -b

Added: trunk/mounted.ocfs2/Makefile
===================================================================
--- trunk/mounted.ocfs2/Makefile	2004-09-07 22:09:41 UTC (rev 217)
+++ trunk/mounted.ocfs2/Makefile	2004-09-07 22:15:21 UTC (rev 218)
@@ -0,0 +1,44 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+           -Wmissing-declarations
+
+ifdef OCFS_DEBUG
+OPTS = -g
+endif
+
+CFLAGS = $(OPTS) -fno-strict-aliasing $(WARNINGS) 
+
+LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
+
+SBIN_PROGRAMS = mounted.ocfs2
+
+INCLUDES = -I$(TOPDIR)/libocfs2/include
+
+OPTIMIZE = -O2
+
+ifeq ($(OCFS_PROCESSOR),x86_64)
+  CFLAGS += -m64
+endif
+ifeq ($(OCFS_PROCESSOR),ia64)
+endif
+ifeq ($(OCFS_PROCESSOR),i686)
+  DEFINES += -D__ILP32__
+endif
+
+CFLAGS += $(OPTIMIZE)
+
+VERSION_FILES = mounted.c
+VERSION_SRC = mounted.c
+VERSION_PREFIX = OCFS2
+
+#MANS = fsck.ocfs2.8
+
+DIST_FILES = $(VERSION_FILES) $(VERSION_SRC) ocfs2_err.et.in
+
+mounted.ocfs2: mounted.o
+	$(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) $(VERMAGIC)
+
+include $(TOPDIR)/Postamble.make

Added: trunk/mounted.ocfs2/mounted.c
===================================================================
--- trunk/mounted.ocfs2/mounted.c	2004-09-07 22:09:41 UTC (rev 217)
+++ trunk/mounted.ocfs2/mounted.c	2004-09-07 22:15:21 UTC (rev 218)
@@ -0,0 +1,130 @@
+/*
+ * mounted.c
+ *
+ * ocfs mount detect utility
+ *
+ * Copyright (C) 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.
+ *
+ * Authors: Sunil Mushran
+ */
+
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE /* Because libc really doesn't want us using O_DIRECT? */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/fd.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#define  OCFS2_FLAT_INCLUDES	1
+#include <ocfs2.h>
+#include <ocfs2_fs.h>
+#include <ocfs2_disk_dlm.h>
+#include <ocfs1_fs_compat.h>
+
+void ocfs2_print_live_nodes(char **node_names, uint16_t num_nodes);
+
+/*
+ * main()
+ *
+ */
+int main(int argc, char **argv)
+{
+	errcode_t ret;
+	int mount_flags = 0;
+	char *node_names[OCFS2_NODE_MAP_MAX_NODES];
+	int i;
+	ocfs2_filesys *fs = NULL;
+	uint8_t vol_label[64];
+	uint8_t vol_uuid[16];
+	uint16_t num_nodes = OCFS2_NODE_MAP_MAX_NODES;
+
+	if (argc < 2) {
+		fprintf(stderr, "Usage: %s device\n", argv[0]);
+		goto bail;
+	}
+
+	initialize_ocfs_error_table();
+
+	memset(node_names, 0, sizeof(node_names));
+	memset(vol_label, 0, sizeof(vol_label));
+	memset(vol_uuid, 0, sizeof(vol_uuid));
+
+	/* open	fs */
+	ret = ocfs2_open(argv[1], O_DIRECT | OCFS2_FLAG_RO, 0, 0, &fs);
+	if (ret) {
+		com_err(argv[0], ret, "while opening \"%s\"", argv[1]);
+		goto bail;
+	}
+
+	num_nodes = OCFS2_RAW_SB(fs->fs_super)->s_max_nodes;
+	memcpy(vol_label, OCFS2_RAW_SB(fs->fs_super)->s_label, sizeof(vol_label));
+	memcpy(vol_uuid, OCFS2_RAW_SB(fs->fs_super)->s_uuid, sizeof(vol_uuid));
+
+	ret = ocfs2_check_heartbeat(argv[1], &mount_flags, node_names);
+	if (ret) {
+		com_err(argv[0], ret, "while detecting heartbeat");
+		goto bail;
+	}
+
+	printf("Label : %s\n", vol_label);
+	printf("Id    : ");
+	for (i = 0; i < 16; i++)
+		printf("%02X", vol_uuid[i]);
+	printf("\n");
+
+	if (mount_flags & (OCFS2_MF_MOUNTED | OCFS2_MF_MOUNTED_CLUSTER)) {
+		printf("Nodes :");
+		ocfs2_print_live_nodes(node_names, num_nodes);
+	} else {
+		printf("Nodes : Not mounted\n");
+		goto bail;
+	}
+
+bail:
+	if (fs)
+		ocfs2_close(fs);
+
+	for (i = 0; i < num_nodes; ++i)
+		if (node_names[i])
+			ocfs2_free (&node_names[i]);
+
+	return 0;
+}
+
+/*
+ * ocfs2_print_live_nodes()
+ *
+ */
+void ocfs2_print_live_nodes(char **node_names, uint16_t num_nodes)
+{
+	int i;
+	char comma = '\0';
+
+	for (i = 0; i < num_nodes; ++i) {
+		if (node_names[i]) {
+			printf("%c %s", comma, node_names[i]);
+			comma = ',';
+		}
+	}
+	printf("\n");
+}



More information about the Ocfs2-tools-commits mailing list