[Ocfs-tools-commits] smushran commits r49 - trunk/debugocfs

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Jun 10 14:29:57 CDT 2004


Author: smushran
Date: 2004-06-10 13:29:54 -0500 (Thu, 10 Jun 2004)
New Revision: 49

Modified:
   trunk/debugocfs/debugocfs.h
   trunk/debugocfs/main.c
Log:
-H option is for explicitly updating the volume header

Modified: trunk/debugocfs/debugocfs.h
===================================================================
--- trunk/debugocfs/debugocfs.h	2004-06-09 23:13:58 UTC (rev 48)
+++ trunk/debugocfs/debugocfs.h	2004-06-10 18:29:54 UTC (rev 49)
@@ -64,6 +64,7 @@
 {
     int nodenum;
     int showHeader;
+    int updHeader;
     int showBitmap;
     int showPublish;
     int showVote;

Modified: trunk/debugocfs/main.c
===================================================================
--- trunk/debugocfs/main.c	2004-06-09 23:13:58 UTC (rev 48)
+++ trunk/debugocfs/main.c	2004-06-10 18:29:54 UTC (rev 49)
@@ -315,7 +315,7 @@
     while (1)
     {
 	int off = 0;
-	int c = getopt(argc, argv, "Nhgl2v:p:d:D:f:F:a:A:b:B:b:r:c:L:M:s:n:X");
+	int c = getopt(argc, argv, "NhHgl2v:p:d:D:f:F:a:A:b:B:b:r:c:L:M:s:n:X");
 
 	if (c == -1)
 	    break;
@@ -324,6 +324,9 @@
 	    case 'h':		/* header */
 		args.showHeader = true;
 		break;
+	    case 'H':		/* update header */
+		args.updHeader = true;
+		break;
 	    case 'g':		/* global bitmap */
 		args.showBitmap = true;
 		break;
@@ -429,21 +432,27 @@
     if (!(args.showHeader || args.showPublish || args.showVote ||
 	  args.showListing || args.showDirent || args.showFileent ||
 	  args.showFileext || args.showSystemFiles || args.showBitmap ||
-	  args.showDirentAll))
+	  args.showDirentAll || args.updHeader))
     {
 	usage();
 	exit(1);
     }
 
-    if (!args.no_rawbind) {
+    if (args.updHeader) {
     	if (get_device_size(argv[optind], &device_size) == -1)
 		    goto bail;
+    }
+
+    if (!args.no_rawbind) {
 	    if (bind_raw(argv[optind], &rawminor, rawdev, sizeof(rawdev)) == -1)
 		    goto bail;
     } else
 	    strncpy(rawdev, argv[optind], sizeof(rawdev));
 
-    flags = O_RDWR | O_LARGEFILE;
+    if (args.updHeader)
+    	flags = O_RDWR | O_LARGEFILE;
+    else
+    	flags = O_RDONLY | O_LARGEFILE;
     fd = open(rawdev, flags);
     if (fd == -1)
     {
@@ -451,24 +460,36 @@
 	goto bail;
     }
 
-    read_vol_disk_header(fd, diskHeader);
-    if (strncmp(diskHeader->signature, OCFS_VOLUME_SIGNATURE, MAX_VOL_SIGNATURE_LEN)) {
-	    printf("ERROR: volume header appears to be corrupted.\nContinuing with standard values.\n");
-	    if (get_default_vol_hdr(fd, diskHeader, device_size) == -1)
-		    goto bail;
-	    while (1) {
+    if (args.updHeader) {
+	if (get_default_vol_hdr(fd, diskHeader, device_size) == -1)
+		goto bail;
+	printf("diskheader:\n");
+	print_vol_disk_header(diskHeader);
+	while (1) {
 		printf("Do you want to write the new volume header to disk (y/N)? ");
 		fgets(input, sizeof(input), stdin);
 		if (toupper(*input) == 'Y') {
-	    		if (write_vol_disk_header(fd, diskHeader) != OCFS_SECTOR_SIZE)
-		    		goto bail;
+			if (write_vol_disk_header(fd, diskHeader) != OCFS_SECTOR_SIZE) {
+				printf("ERROR updating volume header.\n");
+				goto bail;
+			}
 			printf("Volume header successfully updated.\n");
 			break;
-		} else
+		} else {
+			printf("Volume header not updated.\n");
 			break;
-	    }
+		}
+	}
+	goto bail;
     }
 
+    read_vol_disk_header(fd, diskHeader);
+    if (strncmp(diskHeader->signature, OCFS_VOLUME_SIGNATURE, MAX_VOL_SIGNATURE_LEN)) {
+	    printf("ERROR: Volume header appears to be corrupted.\nRerun with -H.\n");
+	    if (!args.showHeader)
+		    goto bail;
+    }
+
     read_vol_label(fd, volLabel);
 
     vcb = get_fake_vcb(fd, diskHeader, args.nodenum);



More information about the Ocfs-tools-commits mailing list