From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 11/29] FAT: fat_build_inode() cleanup
Date: Sun, 06 Mar 2005 03:49:38 +0900 [thread overview]
Message-ID: <87acpiq665.fsf_-_@devron.myhome.or.jp> (raw)
In-Reply-To: <87ekeuq672.fsf_-_@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Sun, 06 Mar 2005 03:49:05 +0900")
Just use ERR_PTR() instead of getting the error code by additional
argument.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
fs/fat/inode.c | 62 ++++++++++++++++++++++-------------------------
fs/msdos/namei.c | 17 +++++++-----
fs/vfat/namei.c | 19 ++++++++------
include/linux/msdos_fs.h | 2 -
4 files changed, 52 insertions(+), 48 deletions(-)
diff -puN fs/fat/inode.c~sync06-fat_dir-cleanup4 fs/fat/inode.c
--- linux-2.6.11/fs/fat/inode.c~sync06-fat_dir-cleanup4 2005-03-06 02:36:32.000000000 +0900
+++ linux-2.6.11-hirofumi/fs/fat/inode.c 2005-03-06 02:36:32.000000000 +0900
@@ -304,23 +304,25 @@ static int fat_fill_inode(struct inode *
}
struct inode *fat_build_inode(struct super_block *sb,
- struct msdos_dir_entry *de, loff_t i_pos, int *res)
+ struct msdos_dir_entry *de, loff_t i_pos)
{
struct inode *inode;
- *res = 0;
+ int err;
+
inode = fat_iget(sb, i_pos);
if (inode)
goto out;
inode = new_inode(sb);
- *res = -ENOMEM;
- if (!inode)
+ if (!inode) {
+ inode = ERR_PTR(-ENOMEM);
goto out;
+ }
inode->i_ino = iunique(sb, MSDOS_ROOT_INO);
inode->i_version = 1;
- *res = fat_fill_inode(inode, de);
- if (*res < 0) {
+ err = fat_fill_inode(inode, de);
+ if (err) {
iput(inode);
- inode = NULL;
+ inode = ERR_PTR(err);
goto out;
}
fat_attach(inode, i_pos);
@@ -643,39 +645,35 @@ fat_encode_fh(struct dentry *de, __u32 *
static struct dentry *fat_get_parent(struct dentry *child)
{
- struct buffer_head *bh=NULL;
- struct msdos_dir_entry *de = NULL;
- struct dentry *parent = NULL;
- int res;
- loff_t i_pos = 0;
+ struct buffer_head *bh;
+ struct msdos_dir_entry *de;
+ loff_t i_pos;
+ struct dentry *parent;
struct inode *inode;
+ int err;
lock_kernel();
- res = fat_scan(child->d_inode, MSDOS_DOTDOT, &bh, &de, &i_pos);
- if (res < 0)
+ err = fat_scan(child->d_inode, MSDOS_DOTDOT, &bh, &de, &i_pos);
+ if (err) {
+ parent = ERR_PTR(err);
goto out;
- inode = fat_build_inode(child->d_sb, de, i_pos, &res);
- if (res)
+ }
+ inode = fat_build_inode(child->d_sb, de, i_pos);
+ brelse(bh);
+ if (IS_ERR(inode)) {
+ parent = ERR_PTR(PTR_ERR(inode));
goto out;
- if (!inode)
- res = -EACCES;
- else {
- parent = d_alloc_anon(inode);
- if (!parent) {
- iput(inode);
- res = -ENOMEM;
- }
}
-
- out:
- if(bh)
- brelse(bh);
+ parent = d_alloc_anon(inode);
+ if (!parent) {
+ iput(inode);
+ parent = ERR_PTR(-ENOMEM);
+ }
+out:
unlock_kernel();
- if (res)
- return ERR_PTR(res);
- else
- return parent;
+
+ return parent;
}
static struct export_operations fat_export_ops = {
diff -puN fs/msdos/namei.c~sync06-fat_dir-cleanup4 fs/msdos/namei.c
--- linux-2.6.11/fs/msdos/namei.c~sync06-fat_dir-cleanup4 2005-03-06 02:36:32.000000000 +0900
+++ linux-2.6.11-hirofumi/fs/msdos/namei.c 2005-03-06 02:36:32.000000000 +0900
@@ -236,9 +236,11 @@ static struct dentry *msdos_lookup(struc
goto add;
if (res < 0)
goto out;
- inode = fat_build_inode(sb, de, i_pos, &res);
- if (res)
+ inode = fat_build_inode(sb, de, i_pos);
+ if (IS_ERR(inode)) {
+ res = PTR_ERR(inode);
goto out;
+ }
add:
res = 0;
dentry = d_splice_alias(inode, dentry);
@@ -314,11 +316,11 @@ static int msdos_create(struct inode *di
unlock_kernel();
return res;
}
- inode = fat_build_inode(dir->i_sb, de, i_pos, &res);
+ inode = fat_build_inode(dir->i_sb, de, i_pos);
brelse(bh);
- if (!inode) {
+ if (IS_ERR(inode)) {
unlock_kernel();
- return res;
+ return PTR_ERR(inode);
}
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
@@ -392,9 +394,10 @@ static int msdos_mkdir(struct inode *dir
res = msdos_add_entry(dir, msdos_name, &bh, &de, &i_pos, 1, is_hid);
if (res)
goto out_unlock;
- inode = fat_build_inode(dir->i_sb, de, i_pos, &res);
- if (!inode) {
+ inode = fat_build_inode(dir->i_sb, de, i_pos);
+ if (IS_ERR(inode)) {
brelse(bh);
+ res = PTR_ERR(inode);
goto out_unlock;
}
res = 0;
diff -puN fs/vfat/namei.c~sync06-fat_dir-cleanup4 fs/vfat/namei.c
--- linux-2.6.11/fs/vfat/namei.c~sync06-fat_dir-cleanup4 2005-03-06 02:36:32.000000000 +0900
+++ linux-2.6.11-hirofumi/fs/vfat/namei.c 2005-03-06 02:36:32.000000000 +0900
@@ -757,11 +757,11 @@ static struct dentry *vfat_lookup(struct
table++;
goto error;
}
- inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos, &err);
+ inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
brelse(sinfo.bh);
- if (err) {
+ if (IS_ERR(inode)) {
unlock_kernel();
- return ERR_PTR(err);
+ return ERR_PTR(PTR_ERR(inode));
}
alias = d_find_alias(inode);
if (alias) {
@@ -798,10 +798,12 @@ static int vfat_create(struct inode *dir
res = vfat_add_entry(dir, &dentry->d_name, 0, &sinfo);
if (res < 0)
goto out;
- inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos, &res);
+ inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
brelse(sinfo.bh);
- if (!inode)
+ if (IS_ERR(inode)) {
+ res = PTR_ERR(inode);
goto out;
+ }
res = 0;
inode->i_version++;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
@@ -883,9 +885,11 @@ static int vfat_mkdir(struct inode *dir,
res = vfat_add_entry(dir, &dentry->d_name, 1, &sinfo);
if (res < 0)
goto out;
- inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos, &res);
- if (!inode)
+ inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
+ if (IS_ERR(inode)) {
+ res = PTR_ERR(inode);
goto out_brelse;
+ }
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
inode->i_version++;
@@ -967,7 +971,6 @@ static int vfat_rename(struct inode *old
}
new_dir->i_version++;
- /* releases old_bh */
err = fat_remove_entries(old_dir, &old_sinfo); /* and releases bh */
old_sinfo.bh = NULL;
if (err)
diff -puN include/linux/msdos_fs.h~sync06-fat_dir-cleanup4 include/linux/msdos_fs.h
--- linux-2.6.11/include/linux/msdos_fs.h~sync06-fat_dir-cleanup4 2005-03-06 02:36:32.000000000 +0900
+++ linux-2.6.11-hirofumi/include/linux/msdos_fs.h 2005-03-06 02:36:32.000000000 +0900
@@ -394,7 +394,7 @@ extern void fat_attach(struct inode *ino
extern void fat_detach(struct inode *inode);
extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos);
extern struct inode *fat_build_inode(struct super_block *sb,
- struct msdos_dir_entry *de, loff_t i_pos, int *res);
+ struct msdos_dir_entry *de, loff_t i_pos);
extern int fat_sync_inode(struct inode *inode);
extern int fat_fill_super(struct super_block *sb, void *data, int silent,
struct inode_operations *fs_dir_inode_ops, int isvfat);
_
next prev parent reply other threads:[~2005-03-05 19:53 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 ` OGAWA Hirofumi [this message]
2005-03-05 18:50 ` [PATCH 12/29] FAT: Use "struct fat_slot_info" for fat_scan() OGAWA Hirofumi
2005-03-05 18:50 ` [PATCH 13/29] FAT: Use "struct fat_slot_info" for msdos_find() OGAWA Hirofumi
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=87acpiq665.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