From: Shen Feng <shen@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Btrfs-progs: add error processing for btrfs_register_one_device
Date: Wed, 07 Jan 2009 14:51:54 +0800 [thread overview]
Message-ID: <4964510A.9020601@cn.fujitsu.com> (raw)
Now btrfsctl -a will do nothing and no error is output
if btrfs.ko is not inserted.
Since no caller do error processing for btrfs_register_one_device,
make its return void and do error processing inside.
Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
---
utils.c | 15 +++++++++++----
utils.h | 2 +-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/utils.c b/utils.c
index 1f99ea3..694a92f 100644
--- a/utils.c
+++ b/utils.c
@@ -645,19 +645,26 @@ struct pending_dir {
char name[256];
};
-int btrfs_register_one_device(char *fname)
+void btrfs_register_one_device(char *fname)
{
struct btrfs_ioctl_vol_args args;
int fd;
int ret;
fd = open("/dev/btrfs-control", O_RDONLY);
- if (fd < 0)
- return -EINVAL;
+ if (fd < 0) {
+ fprintf(stderr, "failed to open"
+ "/dev/btrfs-control\n");
+ exit(1);
+ }
strcpy(args.name, fname);
ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args);
close(fd);
- return ret;
+ if (ret < 0) {
+ fprintf(stderr, "failed to register device %s\n",
+ fname);
+ exit(1);
+ }
}
int btrfs_scan_one_dir(char *dirname, int run_ioctl)
diff --git a/utils.h b/utils.h
index 55eb079..7ff542b 100644
--- a/utils.h
+++ b/utils.h
@@ -34,7 +34,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
u32 sectorsize);
int btrfs_scan_for_fsid(struct btrfs_fs_devices *fs_devices, u64 total_devs,
int run_ioctls);
-int btrfs_register_one_device(char *fname);
+void btrfs_register_one_device(char *fname);
int btrfs_scan_one_dir(char *dirname, int run_ioctl);
int check_mounted(char *devicename);
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
--
1.6.0.6
reply other threads:[~2009-01-07 6:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4964510A.9020601@cn.fujitsu.com \
--to=shen@cn.fujitsu.com \
--cc=linux-btrfs@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