From: Valerie Aurora <valerie.aurora@gmail.com>
To: linux-fsdevel@vger.kernel.org, linux@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, Valerie Aurora <vaurora@redhat.com>,
Valerie Aurora <valerie.aurora@gmail.com>
Subject: [PATCH 10/74] ext2: Add ext2_dirent_in_use()
Date: Tue, 22 Mar 2011 18:58:46 -0700 [thread overview]
Message-ID: <1300845590-14184-11-git-send-email-valerie.aurora@gmail.com> (raw)
In-Reply-To: <1300845590-14184-1-git-send-email-valerie.aurora@gmail.com>
From: Valerie Aurora <vaurora@redhat.com>
Currently ext2 checks if a directory entry is in-use by checking if
the inode is non-zero. Fallthrus and whiteouts will have zero inode
but be in-use. Add a function to abstract out the directory entry
in-use test.
Signed-off-by: Valerie Aurora <valerie.aurora@gmail.com>
---
fs/ext2/dir.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 7641098..79987ab 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -209,6 +209,11 @@ fail:
return ERR_PTR(-EIO);
}
+static inline int ext2_dirent_in_use(struct ext2_dir_entry_2 *de)
+{
+ return (de->inode);
+}
+
/*
* NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure.
*
@@ -219,7 +224,7 @@ static inline int ext2_match (int len, const char * const name,
{
if (len != de->name_len)
return 0;
- if (!de->inode)
+ if (!ext2_dirent_in_use(de))
return 0;
return !memcmp(name, de->name, len);
}
@@ -518,6 +523,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
rec_len = chunk_size;
de->rec_len = ext2_rec_len_to_disk(chunk_size);
de->inode = 0;
+ de->file_type = 0;
goto got_it;
}
if (de->rec_len == 0) {
@@ -531,7 +537,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
goto out_unlock;
name_len = EXT2_DIR_REC_LEN(de->name_len);
rec_len = ext2_rec_len_from_disk(de->rec_len);
- if (!de->inode && rec_len >= reclen)
+ if (!ext2_dirent_in_use(de) && rec_len >= reclen)
goto got_it;
if (rec_len >= name_len + reclen)
goto got_it;
@@ -549,7 +555,7 @@ got_it:
err = ext2_prepare_chunk(page, pos, rec_len);
if (err)
goto out_unlock;
- if (de->inode) {
+ if (ext2_dirent_in_use(de)) {
ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len);
de1->rec_len = ext2_rec_len_to_disk(rec_len - name_len);
de->rec_len = ext2_rec_len_to_disk(name_len);
--
1.7.0.4
next prev parent reply other threads:[~2011-03-23 2:00 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 1:58 [PATCH 00/74] Union mounts version something or other Valerie Aurora
2011-03-23 1:58 ` [PATCH 01/74] VFS: Comment follow_mount() and friends Valerie Aurora
2011-03-23 1:58 ` [PATCH 02/74] VFS: Make lookup_hash() return a struct path Valerie Aurora
2011-03-23 1:58 ` [PATCH 03/74] autofs4: Save autofs trigger's vfsmount in super block info Valerie Aurora
2011-03-23 1:58 ` [PATCH 04/74] Documentation: Fix trivial typo in filesystems/sharedsubtree.txt Valerie Aurora
2011-03-23 1:58 ` [PATCH 05/74] whiteout/NFSD: Don't return information about whiteouts to userspace Valerie Aurora
2011-03-23 1:58 ` [PATCH 06/74] whiteout: Define opaque inode flags and operations Valerie Aurora
2011-03-23 1:58 ` [PATCH 07/74] whiteout: Add vfs_whiteout() and whiteout inode operation Valerie Aurora
2011-03-23 1:58 ` [PATCH 08/74] whiteout: Allow removal of a directory with whiteouts Valerie Aurora
2011-03-23 1:58 ` [PATCH 09/74] whiteout: tmpfs whiteout support Valerie Aurora
2011-03-23 1:58 ` Valerie Aurora [this message]
2011-03-23 1:58 ` [PATCH 11/74] ext2: Split ext2_add_entry() from ext2_add_link() Valerie Aurora
2011-03-23 1:58 ` [PATCH 12/74] whiteout: ext2 whiteout support Valerie Aurora
2011-03-23 1:58 ` [PATCH 13/74] whiteout: jffs2 " Valerie Aurora
2011-03-23 1:58 ` [PATCH 14/74] fallthru: Basic fallthru definitions Valerie Aurora
2011-03-23 1:58 ` [PATCH 15/74] fallthru: ext2 fallthru support Valerie Aurora
2011-03-23 1:58 ` [PATCH 16/74] fallthru: tmpfs " Valerie Aurora
2011-03-23 1:58 ` [PATCH 17/74] fallthru: jffs2 " Valerie Aurora
2011-03-23 1:58 ` [PATCH 18/74] VFS: Add hard read-only users count to superblock Valerie Aurora
2011-03-23 1:58 ` [PATCH 19/74] VFS: Make clone_mnt()/copy_tree()/collect_mounts() return errors Valerie Aurora
2011-03-23 1:58 ` [PATCH 20/74] VFS: Add CL_NO_SHARED flag to clone_mnt()/copy_tree() Valerie Aurora
2011-03-23 1:58 ` [PATCH 21/74] VFS: Add CL_NO_SLAVE " Valerie Aurora
2011-03-23 1:58 ` [PATCH 22/74] VFS: Add CL_MAKE_HARD_READONLY " Valerie Aurora
2011-03-23 1:58 ` [PATCH 23/74] union-mount: Union mounts documentation Valerie Aurora
2011-03-23 1:59 ` [PATCH 24/74] union-mount: Introduce MNT_UNION and MS_UNION flags Valerie Aurora
2011-03-23 1:59 ` [PATCH 25/74] union-mount: Add CONFIG_UNION_MOUNT option Valerie Aurora
2011-03-23 1:59 ` [PATCH 26/74] union-mount: Create union_stack structure Valerie Aurora
2011-03-23 1:59 ` [PATCH 27/74] union-mount: Add two superblock fields for union mounts Valerie Aurora
2011-03-23 1:59 ` [PATCH 28/74] union-mount: Add union_alloc() Valerie Aurora
2011-03-23 1:59 ` [PATCH 29/74] union-mount: Add union_find_dir() Valerie Aurora
2011-03-23 1:59 ` [PATCH 30/74] union-mount: Create d_free_unions() Valerie Aurora
2011-03-23 1:59 ` [PATCH 31/74] union-mount: Free union stack on removal of topmost dentry from dcache Valerie Aurora
2011-03-23 1:59 ` [PATCH 32/74] union-mount: Create union_add_dir() Valerie Aurora
2011-03-23 1:59 ` [PATCH 33/74] union-mount: Add union_create_topmost_dir() Valerie Aurora
2011-03-23 1:59 ` [PATCH 34/74] union-mount: Create IS_MNT_UNION() Valerie Aurora
2011-03-23 1:59 ` [PATCH 35/74] union-mount: Create needs_lookup_union() Valerie Aurora
2011-03-23 1:59 ` [PATCH 36/74] union-mount: Create check_topmost_union_mnt() Valerie Aurora
2011-03-23 1:59 ` [PATCH 37/74] union-mount: Add clone_union_tree() and put_union_sb() Valerie Aurora
2011-03-23 1:59 ` [PATCH 38/74] union-mount: Create build_root_union() Valerie Aurora
2011-03-23 1:59 ` [PATCH 39/74] union-mount: Create prepare_mnt_union() and cleanup_mnt_union() Valerie Aurora
2011-03-23 1:59 ` [PATCH 40/74] union-mount: Prevent improper union-related remounts Valerie Aurora
2011-03-23 1:59 ` [PATCH 41/74] union-mount: Prevent topmost file system from being mounted elsewhere Valerie Aurora
2011-03-23 1:59 ` [PATCH 42/74] union-mount: Prevent bind mounts of union mounts Valerie Aurora
2011-03-23 1:59 ` [PATCH 43/74] union-mount: Implement union mount Valerie Aurora
2011-03-23 1:59 ` [PATCH 44/74] union-mount: Temporarily disable some syscalls Valerie Aurora
2011-03-23 2:12 ` [PATCH 00/74] Union mounts version something or other Valerie Aurora
2011-03-24 13:43 ` Union mounts comparison with overlay file system prototype? Ric Wheeler
2011-03-25 11:38 ` Szeredi Miklos
2011-03-25 12:12 ` Ric Wheeler
2011-03-23 8:38 ` [PATCH 00/74] Union mounts version something or other Sedat Dilek
2011-03-24 22:40 ` Ben Hutchings
2011-03-25 2:32 ` Sedat Dilek
2011-03-30 14:30 ` David Howells
2011-04-01 16:48 ` Valerie Aurora
2011-04-21 13:09 ` David Howells
2011-04-24 21:48 ` Valerie Aurora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300845590-14184-11-git-send-email-valerie.aurora@gmail.com \
--to=valerie.aurora@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux@vger.kernel.org \
--cc=vaurora@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).