From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 13/29] FAT: Use "struct fat_slot_info" for msdos_find()
Date: Sun, 06 Mar 2005 03:50:56 +0900 [thread overview]
Message-ID: <871xauq63z.fsf_-_@devron.myhome.or.jp> (raw)
In-Reply-To: <876506q653.fsf_-_@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Sun, 06 Mar 2005 03:50:16 +0900")
The msdos_find() provide the "struct fat_slot_info". Then some cleanups.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
fs/msdos/namei.c | 88 ++++++++++++++++++++++---------------------------------
1 files changed, 36 insertions(+), 52 deletions(-)
diff -puN fs/msdos/namei.c~sync06-fat_dir-cleanup6 fs/msdos/namei.c
--- linux-2.6.11/fs/msdos/namei.c~sync06-fat_dir-cleanup6 2005-03-06 02:36:39.000000000 +0900
+++ linux-2.6.11-hirofumi/fs/msdos/namei.c 2005-03-06 02:36:39.000000000 +0900
@@ -137,11 +137,9 @@ static int msdos_format_name(const unsig
/***** Locates a directory entry. Uses unformatted name. */
static int msdos_find(struct inode *dir, const unsigned char *name, int len,
- struct buffer_head **bh, struct msdos_dir_entry **de,
- loff_t *i_pos)
+ struct fat_slot_info *sinfo)
{
struct msdos_sb_info *sbi = MSDOS_SB(dir->i_sb);
- struct fat_slot_info sinfo;
unsigned char msdos_name[MSDOS_NAME];
int err;
@@ -149,22 +147,17 @@ static int msdos_find(struct inode *dir,
if (err)
return -ENOENT;
- err = fat_scan(dir, msdos_name, &sinfo);
+ err = fat_scan(dir, msdos_name, sinfo);
if (!err && sbi->options.dotsOK) {
if (name[0] == '.') {
- if (!(sinfo.de->attr & ATTR_HIDDEN))
+ if (!(sinfo->de->attr & ATTR_HIDDEN))
err = -ENOENT;
} else {
- if (sinfo.de->attr & ATTR_HIDDEN)
+ if (sinfo->de->attr & ATTR_HIDDEN)
err = -ENOENT;
}
if (err)
- brelse(sinfo.bh);
- }
- if (!err) {
- *i_pos = sinfo.i_pos;
- *de = sinfo.de;
- *bh = sinfo.bh;
+ brelse(sinfo->bh);
}
return err;
}
@@ -228,22 +221,20 @@ static struct dentry *msdos_lookup(struc
struct nameidata *nd)
{
struct super_block *sb = dir->i_sb;
+ struct fat_slot_info sinfo;
struct inode *inode = NULL;
- struct msdos_dir_entry *de;
- struct buffer_head *bh = NULL;
- loff_t i_pos;
int res;
dentry->d_op = &msdos_dentry_operations;
lock_kernel();
- res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &bh,
- &de, &i_pos);
+ res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
if (res == -ENOENT)
goto add;
if (res < 0)
goto out;
- inode = fat_build_inode(sb, de, i_pos);
+ inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
+ brelse(sinfo.bh);
if (IS_ERR(inode)) {
res = PTR_ERR(inode);
goto out;
@@ -254,7 +245,6 @@ add:
if (dentry)
dentry->d_op = &msdos_dentry_operations;
out:
- brelse(bh);
unlock_kernel();
if (!res)
return dentry;
@@ -341,39 +331,35 @@ static int msdos_create(struct inode *di
static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
- loff_t i_pos;
- int res;
- struct buffer_head *bh;
- struct msdos_dir_entry *de;
+ struct fat_slot_info sinfo;
+ int err;
- bh = NULL;
lock_kernel();
- res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len,
- &bh, &de, &i_pos);
- if (res < 0)
- goto rmdir_done;
/*
* Check whether the directory is not in use, then check
* whether it is empty.
*/
- res = fat_dir_empty(inode);
- if (res)
- goto rmdir_done;
+ err = fat_dir_empty(inode);
+ if (err)
+ goto out;
+ err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
+ if (err)
+ goto out;
- de->name[0] = DELETED_FLAG;
- mark_buffer_dirty(bh);
+ sinfo.de->name[0] = DELETED_FLAG;
+ mark_buffer_dirty(sinfo.bh);
+ brelse(sinfo.bh);
fat_detach(inode);
inode->i_nlink = 0;
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
- dir->i_nlink--;
mark_inode_dirty(inode);
- mark_inode_dirty(dir);
- res = 0;
-rmdir_done:
- brelse(bh);
+ dir->i_nlink--;
+ mark_inode_dirty(dir);
+out:
unlock_kernel();
- return res;
+
+ return err;
}
/***** Make a directory */
@@ -420,6 +406,7 @@ static int msdos_mkdir(struct inode *dir
if (res)
goto mkdir_error;
brelse(bh);
+
d_instantiate(dentry, inode);
res = 0;
@@ -445,30 +432,27 @@ mkdir_error:
static int msdos_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
- loff_t i_pos;
- int res;
- struct buffer_head *bh;
- struct msdos_dir_entry *de;
+ struct fat_slot_info sinfo;
+ int err;
- bh = NULL;
lock_kernel();
- res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len,
- &bh, &de, &i_pos);
- if (res < 0)
+ err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
+ if (err)
goto unlink_done;
- de->name[0] = DELETED_FLAG;
- mark_buffer_dirty(bh);
+ sinfo.de->name[0] = DELETED_FLAG;
+ mark_buffer_dirty(sinfo.bh);
+ brelse(sinfo.bh);
fat_detach(inode);
- brelse(bh);
inode->i_nlink = 0;
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
+
mark_inode_dirty(dir);
- res = 0;
unlink_done:
unlock_kernel();
- return res;
+
+ return err;
}
static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
_
next prev parent reply other threads:[~2005-03-05 19:55 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87ll92rl6a.fsf@devron.myhome.or.jp>
2005-03-05 18:41 ` [PATCH 1/29] fat: fix writev(), add aio support OGAWA Hirofumi
2005-03-05 18:42 ` [PATCH 2/29] FAT: Updated FAT attributes patch OGAWA Hirofumi
2005-03-05 18:43 ` [PATCH 3/29] FAT: fat_readdirx() with dotOK=yes fix OGAWA Hirofumi
2005-03-05 18:43 ` [PATCH 4/29] let fat handle MS_SYNCHRONOUS flag OGAWA Hirofumi
2005-03-06 22:38 ` Christoph Hellwig
2005-03-07 14:56 ` OGAWA Hirofumi
2005-03-05 18:44 ` [PATCH 5/29] FAT: Rewrite the FAT (File Allocation Table) access stuff OGAWA Hirofumi
2005-03-05 18:45 ` [PATCH 6/29] FAT: add debugging code to fatent.c OGAWA Hirofumi
2005-03-05 18:47 ` [PATCH 7/29] FAT: Use "unsigned int" for ->free_clusters and ->prev_free OGAWA Hirofumi
2005-03-05 18:47 ` [PATCH 8/29] FAT: "struct vfat_slot_info" cleanup OGAWA Hirofumi
2005-03-05 18:48 ` [PATCH 9/29] FAT: Use "struct fat_slot_info" for fat_search_long() OGAWA Hirofumi
2005-03-05 18:49 ` [PATCH 10/29] FAT: Add fat_remove_entries() OGAWA Hirofumi
2005-03-05 18:49 ` [PATCH 11/29] FAT: fat_build_inode() cleanup OGAWA Hirofumi
2005-03-05 18:50 ` [PATCH 12/29] FAT: Use "struct fat_slot_info" for fat_scan() OGAWA Hirofumi
2005-03-05 18:50 ` OGAWA Hirofumi [this message]
2005-03-05 18:51 ` [PATCH 14/29] FAT: vfat_build_slots() cleanup OGAWA Hirofumi
2005-03-05 18:52 ` [PATCH 15/29] FAT: Use a same timestamp on some operations path OGAWA Hirofumi
2005-03-05 18:52 ` [PATCH 16/29] FAT: msdos_rename() cleanup OGAWA Hirofumi
2005-03-05 18:53 ` [PATCH 17/29] FAT: msdos_add_entry() cleanup OGAWA Hirofumi
2005-03-05 18:53 ` [PATCH 18/29] FAT: Allocate the cluster before adding the directory entry OGAWA Hirofumi
2005-03-05 18:54 ` [PATCH 19/29] FAT: Rewrite fat_add_entries() OGAWA Hirofumi
2005-03-05 18:55 ` [PATCH 20/29] FAT: Use fat_remove_entries() for msdos OGAWA Hirofumi
2005-03-05 18:55 ` [PATCH 21/29] FAT: make the fat_get_entry()/fat__get_entry() the static OGAWA Hirofumi
2005-03-05 18:56 ` [PATCH 22/29] FAT: "i_pos" cleanup OGAWA Hirofumi
2005-03-05 18:56 ` [PATCH 23/29] FAT: Remove the multiple MSDOS_SB() call OGAWA Hirofumi
2005-03-05 18:57 ` [PATCH 24/29] FAT: Remove unneed mark_inode_dirty() OGAWA Hirofumi
2005-03-05 18:57 ` [PATCH 25/29] FAT: Fix fat_truncate() OGAWA Hirofumi
2005-03-05 18:58 ` [PATCH 26/29] FAT: Fix fat_write_inode() OGAWA Hirofumi
2005-03-05 18:58 ` [PATCH 27/29] FAT: Use synchronous update for {vfat,msdos}_add_entry() OGAWA Hirofumi
2005-03-05 18:59 ` [PATCH 28/29] FAT: Update ->rename() path OGAWA Hirofumi
2005-03-05 19:00 ` [PATCH 29/29] FAT: Fix typo OGAWA Hirofumi
2005-03-06 22:44 ` [PATCH 23/29] FAT: Remove the multiple MSDOS_SB() call Christoph Hellwig
2005-03-07 22:01 ` Adrian Bunk
2005-03-08 13:48 ` OGAWA Hirofumi
2005-03-06 15:53 ` [PATCH 2/29] FAT: Updated FAT attributes patch Michael Geng
2005-03-06 17:02 ` OGAWA Hirofumi
2005-03-06 22:45 ` Christoph Hellwig
2005-03-06 0:07 ` [PATCH] FAT: Support synchronous updates OGAWA Hirofumi
2005-03-07 1:10 ` [PATCH] FAT: Support synchronous update Andrew Morton
2005-03-07 15:02 ` OGAWA Hirofumi
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=871xauq63z.fsf_-_@devron.myhome.or.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®