[Ocfs2-tools-devel] [RESEND][PATCH] Improvement to tunefs.ocfs2 online resize to handle symbolic link
Jiaju Zhang
jjzhang.linux at gmail.com
Tue Mar 23 02:37:36 PDT 2010
On Mon, Mar 22, 2010 at 03:32:53PM -0700, Joel Becker wrote:
> On Fri, Mar 19, 2010 at 05:46:48PM +0800, Jiaju Zhang wrote:
> > On Thu, Mar 18, 2010 at 03:21:44PM -0700, Joel Becker wrote:
> > >
> > > I think you are on track, but you need to be more specific in
> > > your error checking. Each stat call should be checked for error and
> > > fill_error() called. If they both succeed, then you can compare the
> > > rdevs.
> >
> > Many thanks for your comments;-)
> > Here is the improved patch.
> >
> > Thanks,
> > Jiaju
> > ---
> > ocfs2_controld/mount.c | 13 ++++++++++++-
> > 1 files changed, 12 insertions(+), 1 deletions(-)
> >
> > diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
> > index 36459d1..40d7670 100644
> > --- a/ocfs2_controld/mount.c
> > +++ b/ocfs2_controld/mount.c
> > @@ -260,11 +260,22 @@ static void add_service(struct mountgroup *mg, const char *device,
> > const char *service, int ci, int fd)
> > {
> > struct service *ms;
> > + struct stat st1, st2;
> >
> > log_debug("Adding service %s to device %s uuid %s",
> > service, device, mg->mg_uuid);
> >
> > - if (strcmp(mg->mg_device, device)) {
> > + if (stat(mg->mg_device, &st1)) {
> > + fill_error(mg, errno, "Failed to stat on device %s", mg->mg_device);
>
> fill_error(mg, errno, "Failed to stat device \"%s\": %s",
> mg->mg_device, strerror(errno));
Oh yes, thanks a lot for the modification;-)
New patch attached as below.
Thanks,
Jiaju
---
ocfs2_controld/mount.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/ocfs2_controld/mount.c b/ocfs2_controld/mount.c
index 36459d1..b46a04b 100644
--- a/ocfs2_controld/mount.c
+++ b/ocfs2_controld/mount.c
@@ -260,11 +260,24 @@ static void add_service(struct mountgroup *mg, const char *device,
const char *service, int ci, int fd)
{
struct service *ms;
+ struct stat st1, st2;
log_debug("Adding service %s to device %s uuid %s",
service, device, mg->mg_uuid);
- if (strcmp(mg->mg_device, device)) {
+ if (stat(mg->mg_device, &st1)) {
+ fill_error(mg, errno, "Failed to stat device \"%s\": %s",
+ mg->mg_device, strerror(errno));
+ return;
+ }
+
+ if (stat(device, &st2)) {
+ fill_error(mg, errno, "Failed to stat device \"%s\": %s",
+ device, strerror(errno));
+ return;
+ }
+
+ if (st1.st_rdev != st2.st_rdev) {
fill_error(mg, EINVAL,
"Trying to mount fs %s on device %s, but it is already mounted from device %s",
mg->mg_uuid, device, mg->mg_device);
More information about the Ocfs2-tools-devel
mailing list