[Ocfs-tools-commits] smushran commits r217 - in trunk: . format format/inc fsck

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Sep 22 15:18:20 CDT 2004


Author: smushran
Date: 2004-09-22 15:18:18 -0500 (Wed, 22 Sep 2004)
New Revision: 217

Modified:
   trunk/configure.in
   trunk/format/format.c
   trunk/format/inc/tune.h
   trunk/format/mounted.c
   trunk/format/tune.c
   trunk/fsck/blked.c
   trunk/fsck/fsck.c
Log:
update volume label option added to tune.c
strncpy lengths reduced by 1
updated version to 1.1.4-BETA3

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/configure.in	2004-09-22 20:18:18 UTC (rev 217)
@@ -8,7 +8,7 @@
 MAJOR_VERSION=1
 MINOR_VERSION=1
 MICRO_VERSION=4
-EXTRA_VERSION=BETA2
+EXTRA_VERSION=BETA3
 
 # Adjust this only to bump the RPM packaging version
 RPM_VERSION=1

Modified: trunk/format/format.c
===================================================================
--- trunk/format/format.c	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/format/format.c	2004-09-22 20:18:18 UTC (rev 217)
@@ -695,7 +695,7 @@
 				++i;
 				if (i < argc && argv[i])
 					strncpy(opts.volume_label, argv[i],
-						MAX_VOL_LABEL_LEN);
+						MAX_VOL_LABEL_LEN-1);
 				else {
 					fprintf(stderr,"Invalid volume label.\n"
 						"Aborting.\n");
@@ -713,7 +713,7 @@
 				++i;
 				if (i < argc && argv[i])
 					strncpy(opts.mount_point, argv[i],
-						FILE_NAME_SIZE);
+						FILE_NAME_SIZE-1);
 				else {
 					fprintf(stderr,"Invalid mount point.\n"
 						"Aborting.\n");
@@ -783,7 +783,7 @@
 			break;
 
 		default:
-			strncpy(opts.device, argv[i], FILE_NAME_SIZE);
+			strncpy(opts.device, argv[i], FILE_NAME_SIZE-1);
 			break;
 		}
 	}

Modified: trunk/format/inc/tune.h
===================================================================
--- trunk/format/inc/tune.h	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/format/inc/tune.h	2004-09-22 20:18:18 UTC (rev 217)
@@ -39,6 +39,8 @@
 int update_volume_header(int file, ocfs_vol_disk_hdr *volhdr,
 			 __u32 sect_size, __u64 vol_size, bool *update);
 
+int update_volume_label(int file, ocfs_vol_label *vollbl, bool *update);
+
 int update_node_cfg(int file, ocfs_vol_disk_hdr *volhdr, __u64 cfg_hdr_off,
 		    __u64 cfg_node_off, __u64 new_cfg_off,
 		    ocfs_node_config_hdr *node_hdr,

Modified: trunk/format/mounted.c
===================================================================
--- trunk/format/mounted.c	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/format/mounted.c	2004-09-22 20:18:18 UTC (rev 217)
@@ -212,7 +212,7 @@
 		goto bail;
 	}
 
-	strncpy(opts.device, argv[1], FILE_NAME_SIZE);
+	strncpy(opts.device, argv[1], sizeof(opts.device)-1);
 	if (strlen(opts.device))
 		ret = 1;
 	else {

Modified: trunk/format/tune.c
===================================================================
--- trunk/format/tune.c	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/format/tune.c	2004-09-22 20:18:18 UTC (rev 217)
@@ -73,6 +73,7 @@
 "	-g Group ID for the root directory\n"
 "	-h Help\n"
 "	-l List all the node config slots\n"
+"	-L Volume Label\n"
 "	-n Query only\n"
 "	-N Node config slot be to be cleared\n"
 "	-p Permissions for the root directory\n"
@@ -89,6 +90,7 @@
 int main(int argc, char **argv)
 {
 	ocfs_vol_disk_hdr *volhdr = NULL;
+	ocfs_vol_label *vollbl = NULL;
 	ocfs_node_config_hdr *node_hdr = NULL;
 	ocfs_disk_node_config_info *node_info = NULL;
 	__u32 sect_size = OCFS_SECTOR_SIZE;
@@ -134,9 +136,10 @@
 
 	/* Allocate mem */
 	volhdr = MemAlloc(OCFS_SECTOR_SIZE);
+	vollbl = MemAlloc(OCFS_SECTOR_SIZE);
 	node_hdr = MemAlloc(OCFS_SECTOR_SIZE);
 	node_info = MemAlloc(OCFS_SECTOR_SIZE);
-	if (!volhdr || !node_hdr || !node_info)
+	if (!volhdr || !vollbl || !node_hdr || !node_info)
 		goto bail;
 
 	/* Is this an existing ocfs volume */
@@ -181,6 +184,10 @@
 	if (!read_sectors(file, 0, 1, sect_size, (void *)volhdr))
 		goto bail;
 
+	/* read volume label */
+	if (!read_sectors(file, 512, 1, sect_size, (void *)vollbl))
+		goto bail;
+
 	/* Update node cfgs */
 	if (IS_VALID_NODE_NUM(opts.slot_num)) {
 		cfg_hdr_off = volhdr->node_cfg_off;
@@ -201,6 +208,12 @@
 			goto bail;
 	}
 
+	/* Update volume label */
+	if (opts.volume_label[0] != '\0') {
+		if (!update_volume_label(file, vollbl, &update))
+			goto bail;
+	}
+
 	if (!update) {
 		printf("No changes made to the volume.\nAborting.\n");
 		goto bail;
@@ -258,10 +271,17 @@
 			goto bail;
 	}
 
+	/* Write volume label */
+	if (opts.volume_label[0] != '\0') {
+		if (!write_sectors(file, 512, 1, sect_size, (void *)vollbl))
+			goto bail;
+	}
+
 	printf("Changes written to disk.\n");
 
 bail:
 	safefree(volhdr);
+	safefree(vollbl);
 	safefree(node_hdr);
 	safefree(node_info);
 
@@ -277,8 +297,8 @@
 /*
  * read_options()
  *
- * "usage: %s [-d ms] [-F] [-g gid] [-h] [-l] [-n] [-N nodenum] [-p permissions] "
- * "[-q] [-S size] [-t ms] [-u uid] [-V] device\n\n"
+ * "usage: %s [-d ms] [-F] [-g gid] [-h] [-l] [-L label] [-n] [-N nodenum] "
+ * "[-p permissions] [-q] [-S size] [-t ms] [-u uid] [-V] device\n\n"
  *
  */
 int read_options(int argc, char **argv)
@@ -297,7 +317,7 @@
 	}
 
 	while(1) {
-		c = getopt(argc, argv, "CFhlnqVd:g:N:p:S:t:u:");
+		c = getopt(argc, argv, "CFhlnqVd:g:N:p:S:t:u:L:");
 		if (c == -1)
 			break;
 
@@ -328,6 +348,11 @@
 			opts.list_nodes = true;
 			break;
 
+		case 'L':	/* volume label */
+			strncpy(opts.volume_label, optarg,
+			       	sizeof(opts.volume_label)-1);
+			break;
+
 		case 'n':	/* query */
 			opts.query_only = true;
 			break;
@@ -375,7 +400,7 @@
 	}
 
 	if (ret && optind < argc && argv[optind])
-			strncpy(opts.device, argv[optind], FILE_NAME_SIZE);
+			strncpy(opts.device, argv[optind], sizeof(opts.device)-1);
 
 bail:
 	return ret;
@@ -512,6 +537,26 @@
 }				/* update_volume_header */
 
 /*
+ * update_volume_label()
+ *
+ */
+int update_volume_label(int file, ocfs_vol_label *vollbl, bool *update)
+{
+	int ret = 1;
+
+	if (opts.volume_label[0] != '\0') {
+		printf("Changing volume label from '%s' to '%s'\n",
+		       vollbl->label, opts.volume_label);
+		strncpy(vollbl->label, opts.volume_label, sizeof(vollbl->label)-1);
+		vollbl->label_len = strlen(vollbl->label);
+		*update = true;
+	}
+
+	return ret;
+}				/* update_volume_label */
+
+
+/*
  * update_node_cfg()
  *
  */
@@ -753,6 +798,7 @@
 	return ret;
 }				/* process_new_volsize */
 
+#if 0
 void init_global_context()
 {
 	char *tmp;
@@ -965,3 +1011,4 @@
 		
 	return(ret);
 }
+#endif

Modified: trunk/fsck/blked.c
===================================================================
--- trunk/fsck/blked.c	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/fsck/blked.c	2004-09-22 20:18:18 UTC (rev 217)
@@ -248,7 +248,7 @@
 
 	version(argv[0]);
 
-	strncpy(ctxt.device, argv[optind], OCFS_MAX_FILENAME_LENGTH);
+	strncpy(ctxt.device, argv[optind], OCFS_MAX_FILENAME_LENGTH-1);
 
 	if (blked_initialize(&buf) == -1) {
 		goto bail;

Modified: trunk/fsck/fsck.c
===================================================================
--- trunk/fsck/fsck.c	2004-09-22 18:24:42 UTC (rev 216)
+++ trunk/fsck/fsck.c	2004-09-22 20:18:18 UTC (rev 217)
@@ -278,7 +278,7 @@
 		if (ctxt.verbose)
 			CLEAR_AND_PRINT("Bound %s to %s", ctxt.device, ctxt.raw_device);
 	} else
-		strncpy(ctxt.raw_device, ctxt.device, sizeof(ctxt.raw_device));
+		strncpy(ctxt.raw_device, ctxt.device, sizeof(ctxt.raw_device)-1);
 
 	if ((fd = myopen(ctxt.raw_device, ctxt.flags)) == -1) {
 		LOG_ERROR("Error opening %s.\n%s.", ctxt.raw_device,
@@ -376,7 +376,7 @@
 
 	version(argv[0]);
 
-	strncpy(ctxt.device, argv[optind], OCFS_MAX_FILENAME_LENGTH);
+	strncpy(ctxt.device, argv[optind], OCFS_MAX_FILENAME_LENGTH-1);
 
 	if (fsck_initialize(&buf) == -1) {
 		goto quiet_bail;



More information about the Ocfs-tools-commits mailing list