[Ocfs2-commits] mfasheh commits r1657 - branches/dlm-glue/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Nov 19 20:06:24 CST 2004


Author: mfasheh
Date: 2004-11-19 20:06:22 -0600 (Fri, 19 Nov 2004)
New Revision: 1657

Modified:
   branches/dlm-glue/src/super.c
Log:
* accept the 'group' argument.



Modified: branches/dlm-glue/src/super.c
===================================================================
--- branches/dlm-glue/src/super.c	2004-11-20 02:06:09 UTC (rev 1656)
+++ branches/dlm-glue/src/super.c	2004-11-20 02:06:22 UTC (rev 1657)
@@ -135,11 +135,11 @@
 #endif /* Linux 2.4 stuff */
 
 
-static int ocfs_parse_options (char *options, __u32 * uid, __u32 * gid, int * reclaim_id);
+static int ocfs_parse_options (char *options, __u32 * uid, __u32 * gid, int * reclaim_id, char **group_name);
 static int __init ocfs_driver_entry (void);
 static void __exit ocfs_driver_exit (void);
 static void ocfs_put_super (struct super_block *sb);
-static int ocfs_mount_volume (struct super_block *sb, int reclaim_id, struct inode *root);
+static int ocfs_mount_volume (struct super_block *sb, int reclaim_id, char *group_name, struct inode *root);
 static void ocfs_dismount_volume(struct super_block *sb);
 static int ocfs_initialize_mem_lists (void);
 static void ocfs_free_mem_lists (void);
@@ -156,7 +156,7 @@
 static int ocfs_init_global_system_inodes(ocfs_super *osb);
 static int ocfs_init_local_system_inodes(ocfs_super *osb);
 static int ocfs_release_system_inodes(ocfs_super *osb);
-static int ocfs2_fill_node_info(ocfs_super *osb);
+static int ocfs2_fill_node_info(ocfs_super *osb, const char *group_name);
 static int ocfs2_complete_mount_recovery(ocfs_super *osb);
 static int ocfs_check_volume(ocfs_super * osb);
 static int ocfs_verify_volume(ocfs2_dinode *di, struct buffer_head *bh,
@@ -321,11 +321,12 @@
 	__u32 uid = current->fsuid;
 	__u32 gid = current->fsgid;
 	int reclaim_id;
+	char *group_name = NULL;
 	ocfs_super *osb = NULL;
 
 	LOG_ENTRY_ARGS ("%p, %p, %i", sb, data, silent);
 
-	if (ocfs_parse_options (data, &uid, &gid, &reclaim_id) != 0) {
+	if (ocfs_parse_options (data, &uid, &gid, &reclaim_id, &group_name) != 0) {
 		status = -EINVAL;
 		LOG_ERROR_STR ("ocfs_read_super: bad mount option");
 		goto read_super_error;
@@ -338,7 +339,7 @@
 	/* this is needed to support O_LARGE_FILE */
 	sb->s_maxbytes = OCFS_LINUX_MAX_FILE_SIZE;
 
-	status = ocfs_mount_volume (sb, reclaim_id, NULL);
+	status = ocfs_mount_volume (sb, reclaim_id, group_name, NULL);
 	if (status < 0)
 		goto read_super_error;
 
@@ -380,6 +381,9 @@
 			LOG_EXIT_STATUS(status);
 	}
 
+	if (group_name)
+		kfree(group_name);
+
 	LOG_EXIT_STATUS(status);
 	return status;		
 
@@ -392,6 +396,9 @@
 	if (inode)
 		iput (inode);
 
+	if (group_name)
+		kfree(group_name);
+
 	LOG_EXIT_STATUS(status);
 	return status;
 }
@@ -428,11 +435,12 @@
  *
  * e.g., gid=9999,uid=9999,[no]cache,reclaimid
  */
-static int ocfs_parse_options (char *options, __u32 * uid, __u32 * gid, int * reclaim_id)
+static int ocfs_parse_options (char *options, __u32 * uid, __u32 * gid, int * reclaim_id, char **group_name)
 {
 	char *c;
 	char *value;
 	int ret = 1;
+	int size;
 
 	LOG_ENTRY ();
 	
@@ -473,6 +481,22 @@
 			}
 		} else if (!strcmp (c, "reclaimid")) {
 			*reclaim_id = 1;
+		} else if (!strcmp(c, "group")) {
+			if (!value || !*value) {
+				LOG_ERROR_STR
+					("group option requires an argument");
+				goto bail;
+			}
+			LOG_TRACE_ARGS("group name passed = %s\n", value);
+
+			size = strlen(value);
+			*group_name = kmalloc(size, GFP_KERNEL);
+			if (!(*group_name)) {
+				LOG_ERROR_STATUS(-ENOMEM);
+				goto bail;
+			}
+
+			strcpy(*group_name, value);
 		} else {
 			LOG_ERROR_ARGS ("Invalid mount option: %s", c);
 			goto bail;
@@ -832,13 +856,11 @@
 	return 0;
 }
 
-static int ocfs2_fill_node_info(ocfs_super *osb)
+static int ocfs2_fill_node_info(ocfs_super *osb, const char *group_name)
 {
 	int status;
 	struct inode *group = NULL;
 
-#warning "TODO: group name is always passed in as a parameter"
-	/* hard coded right now. */
 	osb->group_name = kmalloc(NM_MAX_NAME_LEN, GFP_KERNEL);
 	if (!osb->group_name) {
 		status = -ENOMEM;
@@ -846,8 +868,12 @@
 		goto bail;
 	}
 	memset(osb->group_name, 0, NM_MAX_NAME_LEN);
-	sprintf(osb->group_name, "%s", "ocfs2cluster");
 
+	if (group_name)
+		strncpy(osb->group_name, group_name, NM_MAX_NAME_LEN);
+	else
+		memcpy(osb->group_name, osb->uuid, MAX_VOL_ID_LENGTH);
+
 	group = nm_get_group_by_name(osb->group_name);
 	if (!group) {
 		printk("ocfs2: could not join group \"%s\"\n",
@@ -872,7 +898,7 @@
  * ocfs_mount_volume()
  *
  */
-static int ocfs_mount_volume (struct super_block *sb, int reclaim_id, struct inode *root)
+static int ocfs_mount_volume (struct super_block *sb, int reclaim_id, char *group_name, struct inode *root)
 {
 	int status, sector_size;
 	int unlock_super = 0;
@@ -912,7 +938,7 @@
 		goto leave;
 	}
 
-	status = ocfs2_fill_node_info(osb);
+	status = ocfs2_fill_node_info(osb, group_name);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto leave;



More information about the Ocfs2-commits mailing list