[Ocfs2-tools-commits] smushran commits r326 - in trunk/debugfs.ocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Oct 11 16:16:33 CDT 2004


Author: smushran
Date: 2004-10-11 16:16:31 -0500 (Mon, 11 Oct 2004)
New Revision: 326

Removed:
   trunk/debugfs.ocfs2/bindraw.c
   trunk/debugfs.ocfs2/include/bindraw.h
Modified:
   trunk/debugfs.ocfs2/Makefile
   trunk/debugfs.ocfs2/commands.c
   trunk/debugfs.ocfs2/include/main.h
   trunk/debugfs.ocfs2/main.c
Log:
removed code for raw bindings
using O_DIRECT flag in open instead

Modified: trunk/debugfs.ocfs2/Makefile
===================================================================
--- trunk/debugfs.ocfs2/Makefile	2004-10-11 20:17:52 UTC (rev 325)
+++ trunk/debugfs.ocfs2/Makefile	2004-10-11 21:16:31 UTC (rev 326)
@@ -11,7 +11,7 @@
 
 CFLAGS += -Wall -O2
 
-CFILES = main.c commands.c dump.c readfs.c utils.c journal.c bindraw.c
+CFILES = main.c commands.c dump.c readfs.c utils.c journal.c
 HFILES =			\
 	include/main.h		\
 	include/commands.h	\
@@ -19,8 +19,7 @@
 	include/readfs.h	\
 	include/utils.h		\
 	include/jbd.h		\
-	include/journal.h	\
-	include/bindraw.h
+	include/journal.h
 
 OBJS = $(subst .c,.o,$(CFILES))
 

Deleted: trunk/debugfs.ocfs2/bindraw.c
===================================================================
--- trunk/debugfs.ocfs2/bindraw.c	2004-10-11 20:17:52 UTC (rev 325)
+++ trunk/debugfs.ocfs2/bindraw.c	2004-10-11 21:16:31 UTC (rev 326)
@@ -1,157 +0,0 @@
-
-/*
- * bindraw.c
- *
- * Binds device to first available raw device
- *
- * 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
- */
-
-#include <main.h>
-
-/*
- * bind_raw()
- *
- */
-int bind_raw (char *blk_dev, int *raw_minor, char *raw_dev, int rdlen)
-{
-	int fd = 0;
-	int i;
-	struct raw_config_request rcs;
-	struct stat statbuf;
-	int ret = -1;
-
-	memset(&statbuf, 0, sizeof(struct stat));
-	if (stat(blk_dev, &statbuf) == -1)
-		DBGFS_FATAL("%s", strerror(errno));
-
-	if (MAJOR(statbuf.st_rdev) == 0) {
-		printf("Invalid device %s\n", blk_dev);
-		goto bail;
-	}
-
-	if (strstr(blk_dev, "/dev/raw")) {
-		strncpy(raw_dev, blk_dev, rdlen-1);
-		raw_dev[rdlen-1] = '\0';
-	}
-	else {
-		if ((fd = open("/dev/rawctl", O_RDWR)) == -1)
-			DBGFS_FATAL("Error opening /dev/rawctl.\n%s\nMaybe you should use the --no-raw flag.\n", strerror(errno));
-
-		for (i = 1; i < 255; ++i) {
-			memset(&rcs, 0, sizeof(struct raw_config_request));
-			rcs.raw_minor = i;
-			if (ioctl(fd, RAW_GETBIND, &rcs) == -1)
-				continue;
-			if (rcs.block_major == 0)
-				break;
-		}
-
-		if (i >= 255) {
-			printf ("unable to find a free raw device /dev/raw/rawXX\n");
-			goto bail;
-		}
-
-		*raw_minor = i;
-		snprintf(raw_dev, rdlen, "/dev/raw/raw%d", i);
-
-		rcs.raw_minor = i;
-		rcs.block_major = (__u64)MAJOR(statbuf.st_rdev);
-		rcs.block_minor = (__u64)MINOR(statbuf.st_rdev);
-		if (ioctl(fd, RAW_SETBIND, &rcs) == -1) {
-			printf ("Error binding to raw: %s\n", strerror(errno));
-			*raw_minor = 0;
-			raw_dev[0] = '\0';
-			goto bail;
-		}
-	}
-
-	ret = 0;
-bail:
-	if (fd)
-		close(fd);
-
-	return ret;
-}				/* bind_raw */
-
-/*
- * unbind_raw()
- *
- */
-void unbind_raw(int raw_minor)
-{
-	int fd = 0;
-	struct raw_config_request rcs;
-	
-	if (raw_minor == 0)
-		goto bail;
-
-	if ((fd = open("/dev/rawctl", O_RDWR)) == -1)
-		DBGFS_FATAL("%s", strerror(errno));
-
-	rcs.raw_minor = raw_minor;
-	rcs.block_major = 0;
-	rcs.block_minor = 0;
-	if (ioctl(fd, RAW_SETBIND, &rcs) == -1) {
-		printf("Error unbinding from raw: %s\n", strerror(errno));
-		goto bail;
-	}
-
-bail:
-	if (fd)
-		close(fd);
-	return ;
-}				/* unbind_raw */
-
-/*
- * signal_message()
- *
- */
-static void signal_message (int sig)
-{
-#define LINE1 "Abnormal termination!\n"
-#define LINE2 "There may be bound raw devices left lying around, please clean them up\n"
-#define LINE3 "using the raw(8) command.\n"
-
-	write(2, LINE1, sizeof(LINE1) - 1);
-	write(2, LINE2, sizeof(LINE2) - 1);
-	write(2, LINE3, sizeof(LINE3) - 1);
-
-	signal(sig, SIG_DFL);
-
-	raise(sig);
-
-	return ;
-}				/* signal_message */
-
-/*
- * init_raw_cleanup_message()
- *
- */
-void init_raw_cleanup_message(void)
-{
-	signal (SIGHUP, signal_message);
-	signal (SIGQUIT, signal_message);
-	signal (SIGABRT, signal_message);
-	signal (SIGBUS, signal_message);
-	signal (SIGSEGV, signal_message);
-
-	return ;
-}				/* init_raw_cleanup_message */

Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c	2004-10-11 20:17:52 UTC (rev 325)
+++ trunk/debugfs.ocfs2/commands.c	2004-10-11 21:16:31 UTC (rev 326)
@@ -65,7 +65,6 @@
 static void do_header (char **args);
 
 extern gboolean allow_write;
-extern gboolean no_raw_bind;
 
 dbgfs_gbls gbls = {
 	.device = NULL,
@@ -176,8 +175,8 @@
 	ocfs2_super_block *sb;
 	char *buf = NULL;
 	__u32 len;
-	char raw_dev[255];
 	ocfs2_dinode *inode;
+	int flags;
 
 	if (gbls.device)
 		do_close (NULL);
@@ -187,14 +186,8 @@
 		goto bail;
 	}
 
-	if (!no_raw_bind) {
-		if (bind_raw (dev, &gbls.raw_minor, raw_dev, sizeof(raw_dev)))
-			goto bail;
-		printf ("Bound %s to %s\n", dev, raw_dev);
-		dev = raw_dev;
-	}
-
-	gbls.dev_fd = open (dev, allow_write ? O_RDONLY : O_RDWR);
+	flags = O_DIRECT | (allow_write ? O_RDONLY : O_RDWR);
+	gbls.dev_fd = open (dev, flags);
 	if (gbls.dev_fd == -1) {
 		printf ("could not open device %s\n", dev);
 		goto bail;
@@ -267,9 +260,6 @@
 		close (gbls.dev_fd);
 		gbls.dev_fd = -1;
 
-		unbind_raw(gbls.raw_minor);
-		gbls.raw_minor = 0;
-
 		g_free (gbls.curdir);
 		gbls.curdir = NULL;
 

Deleted: trunk/debugfs.ocfs2/include/bindraw.h
===================================================================
--- trunk/debugfs.ocfs2/include/bindraw.h	2004-10-11 20:17:52 UTC (rev 325)
+++ trunk/debugfs.ocfs2/include/bindraw.h	2004-10-11 21:16:31 UTC (rev 326)
@@ -1,34 +0,0 @@
-
-/*
- * bindraw.h
- *
- * Declarations, prototypes, etc.
- *
- * 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
- */
-
-#ifndef _BINDRAW_H_
-#define _BINDRAW_H_
-
-int bind_raw(char *blk_dev, int *raw_minor, char *raw_dev, int rdlen);
-void unbind_raw(int raw_minor);
-void init_raw_cleanup_message(void);
-
-#endif

Modified: trunk/debugfs.ocfs2/include/main.h
===================================================================
--- trunk/debugfs.ocfs2/include/main.h	2004-10-11 20:17:52 UTC (rev 325)
+++ trunk/debugfs.ocfs2/include/main.h	2004-10-11 21:16:31 UTC (rev 326)
@@ -153,6 +153,5 @@
 #include <utils.h>
 #include <journal.h>
 #include <dump.h>
-#include <bindraw.h>
 
 #endif		/* __MAIN_H__ */

Modified: trunk/debugfs.ocfs2/main.c
===================================================================
--- trunk/debugfs.ocfs2/main.c	2004-10-11 20:17:52 UTC (rev 325)
+++ trunk/debugfs.ocfs2/main.c	2004-10-11 21:16:31 UTC (rev 326)
@@ -32,7 +32,6 @@
 static char *get_line      (void);
 
 gboolean allow_write = FALSE;
-gboolean no_raw_bind = FALSE;
 
 /*
  * usage()
@@ -45,7 +44,6 @@
 	g_print ("  -V, --version  g_print version information and exit\n");
 	g_print ("  -?, --help     display this help and exit\n");
 	g_print ("  -w, --write    turn on write support\n");
-	g_print ("  -N, --no-raw   do not bind device to raw\n");
 	exit (0);
 }					/* usage */
 
@@ -97,8 +95,6 @@
 	INSTALL_SIGNAL(SIGTERM);
 	INSTALL_SIGNAL(SIGINT);
 
-	init_raw_cleanup_message();
-
 	for (i = 1; i < argc; i++) {
 		arg = argv[i];
 		if ((strcmp (arg, "--write") == 0) ||
@@ -108,9 +104,6 @@
 			   (strcmp (arg, "-V") == 0)) {
 			print_version ();
 			exit (0);
-		} else if ((strcmp (arg, "--no-raw") == 0) ||
-			   (strcmp (arg, "-N") == 0)) {
-			no_raw_bind = TRUE;
 		} else if ((strcmp (arg, "--help") == 0) ||
 			   (strcmp (arg, "-?") == 0)) {
 			usage (argv[0]);



More information about the Ocfs2-tools-commits mailing list