Re: [Tux3] [PATCH]tux3_mkdir

Previous thread: [Tux3] The volume table by Daniel Phillips on Wednesday, August 20, 2008 - 3:25 pm. (2 messages)

Next thread: [Tux3] Hello world! by Daniel Phillips on Saturday, August 23, 2008 - 4:53 pm. (4 messages)
From: Pranith Kumar
Date: Saturday, December 6, 2008 - 8:00 am

Hello,

mkdir and create are totally same, except for the flags passed.

It works, atleast in the cases i tested for. :)

--
Pranith.

--- user/kernel/namei.c.orig	2008-12-06 20:10:20.000000000 +0530
+++ user/kernel/namei.c	2008-12-06 19:24:12.000000000 +0530
@@ -43,6 +43,33 @@ error:
 	return err;
 }

+static int tux3_mkdir(struct inode* dir, struct dentry * dentry, int mode)
+{
+	struct inode *inode;
+	int err;
+
+	struct buffer_head *buffer;
+
+	inode = tux_create_inode(dir, S_IFDIR | mode);
+	if (IS_ERR(inode)) {
+		err = PTR_ERR(inode);
+		goto error;
+	}
+
+	if ((err = tux_create_entry(dir, dentry->d_name.name, dentry->d_name.len,
+	    tux_inode(inode)->inum, S_IFDIR | mode)) < 0)
+		goto error;
+
+	d_instantiate(dentry, inode);
+//	tux_make_empty(inode, dir);
+	return 0;
+
+error:
+	inode_dec_link_count(inode);
+	iput(inode);
+	return err;
+}
+
 const struct file_operations tux_dir_fops = {
 	.llseek		= generic_file_llseek,
 	.read		= generic_read_dir,
@@ -55,7 +82,7 @@ const struct inode_operations tux_dir_io
 //	.link		= ext3_link,
 //	.unlink		= ext3_unlink,
 //	.symlink	= ext3_symlink,
-//	.mkdir		= ext3_mkdir,
+	.mkdir		= tux3_mkdir,
 //	.rmdir		= ext3_rmdir,
 //	.mknod		= ext3_mknod,
 //	.rename		= ext3_rename,

_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
From: Daniel Phillips
Date: Saturday, August 23, 2008 - 4:09 am

[Empty message]
From: Daniel Phillips
Date: Saturday, December 6, 2008 - 12:57 pm

They should be similar, however the fact that they are nearly identical
is due to:

  * Hirofumi's somewhat nicer factoring of the code than Ext2, with a
    separate setup_inode function that takes care of setting up the
    operations fields, which are different for directories.

  * Links count we haven't implemented them yet, but directories will
    need two of them.

If tux3_mkdir and tux3_create are very similar then they should be the
same function to avoid cut and paste duplication of code, so you would
have a tux3_mkdir and a tux3_mkreg that both call tux3_create, adding
the IFDIR or IFREG flag as a parameter.  Then you would handle the
extra link count in the wrapper.  But it is best to get it working first
as a cut and paste just as you have done, to be able to compare the

As a  "lindent" convention, * when used as a reference operator has a

Let's resolve the question of whether we really need this (interesting
question).

Congratulations on your first Tux3 hack!

Daniel

_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
From: OGAWA Hirofumi
Date: Saturday, December 6, 2008 - 4:38 pm

FWIW, recently, linux has script to check it.

	linux/scripts/checkpatch.pl /path/to/your/foo.patch
or
	linux/scripts/checkpatch.pl --file /path/to/your/foo.c
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
From: Pranith Kumar
Date: Sunday, December 7, 2008 - 2:34 am

ok. Here is a much simpler patch which avoids duplication.. checked

-- 
Pranith.


--- user/kernel/namei.c.orig	2008-12-06 20:10:20.000000000 +0530
+++ user/kernel/namei.c	2008-12-07 14:57:12.000000000 +0530
@@ -43,6 +43,11 @@ error:
 	return err;
 }

+static int tux3_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+{
+	return tux3_create(dir, dentry, S_IFDIR | mode, NULL);
+}
+
 const struct file_operations tux_dir_fops = {
 	.llseek		= generic_file_llseek,
 	.read		= generic_read_dir,
@@ -55,7 +60,7 @@ const struct inode_operations tux_dir_io
 //	.link		= ext3_link,
 //	.unlink		= ext3_unlink,
 //	.symlink	= ext3_symlink,
-//	.mkdir		= ext3_mkdir,
+	.mkdir		= tux3_mkdir,
 //	.rmdir		= ext3_rmdir,
 //	.mknod		= ext3_mknod,
 //	.rename		= ext3_rename,

_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
From: Daniel Phillips
Date: Sunday, December 7, 2008 - 2:42 am

Beautiful!  Sometimes very short is very sweet.  I will merge your
patch, and when we add link atribute support (very soon) then you can
add the extra link needed for a directory to your wrapper.

Daniel

_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3
Previous thread: [Tux3] The volume table by Daniel Phillips on Wednesday, August 20, 2008 - 3:25 pm. (2 messages)

Next thread: [Tux3] Hello world! by Daniel Phillips on Saturday, August 23, 2008 - 4:53 pm. (4 messages)