linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Use MDMON_DIR for pid files created in Monitor.c
@ 2012-02-02 11:45 Jes.Sorensen
  2012-02-22 22:12 ` NeilBrown
  2012-02-23 20:39 ` CoolCold
  0 siblings, 2 replies; 4+ messages in thread
From: Jes.Sorensen @ 2012-02-02 11:45 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Other parts of mdadm/mdmon place .pid/.sock files in MDMON_DIR. This
makes Monitor.c consistent with the rest.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 Monitor.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index 77f22aa..7ed5282 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -294,8 +294,10 @@ static int check_one_sharer(int scan)
 	int pid, rv;
 	FILE *fp;
 	char dir[20];
+	char path[100];
 	struct stat buf;
-	fp = fopen("/var/run/mdadm/autorebuild.pid", "r");
+	sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
+	fp = fopen(path, "r");
 	if (fp) {
 		if (fscanf(fp, "%d", &pid) != 1)
 			pid = -1;
@@ -317,12 +319,12 @@ static int check_one_sharer(int scan)
 		fclose(fp);
 	}
 	if (scan) {
-		if (mkdir("/var/run/mdadm", S_IRWXU) < 0 &&
+		if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
 		    errno != EEXIST) {
 			fprintf(stderr, Name ": Can't create "
 				"autorebuild.pid file\n");
 		} else {
-			fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
+			fp = fopen(path, "w");
 			if (!fp)
 				fprintf(stderr, Name ": Cannot create"
 					" autorebuild.pid"
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use MDMON_DIR for pid files created in Monitor.c
  2012-02-02 11:45 [PATCH] Use MDMON_DIR for pid files created in Monitor.c Jes.Sorensen
@ 2012-02-22 22:12 ` NeilBrown
  2012-02-23 20:39 ` CoolCold
  1 sibling, 0 replies; 4+ messages in thread
From: NeilBrown @ 2012-02-22 22:12 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]

On Thu,  2 Feb 2012 12:45:02 +0100 Jes.Sorensen@redhat.com wrote:

> From: Jes Sorensen <Jes.Sorensen@redhat.com>
> 
> Other parts of mdadm/mdmon place .pid/.sock files in MDMON_DIR. This
> makes Monitor.c consistent with the rest.
> 
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---
>  Monitor.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/Monitor.c b/Monitor.c
> index 77f22aa..7ed5282 100644
> --- a/Monitor.c
> +++ b/Monitor.c
> @@ -294,8 +294,10 @@ static int check_one_sharer(int scan)
>  	int pid, rv;
>  	FILE *fp;
>  	char dir[20];
> +	char path[100];
>  	struct stat buf;
> -	fp = fopen("/var/run/mdadm/autorebuild.pid", "r");
> +	sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
> +	fp = fopen(path, "r");
>  	if (fp) {
>  		if (fscanf(fp, "%d", &pid) != 1)
>  			pid = -1;
> @@ -317,12 +319,12 @@ static int check_one_sharer(int scan)
>  		fclose(fp);
>  	}
>  	if (scan) {
> -		if (mkdir("/var/run/mdadm", S_IRWXU) < 0 &&
> +		if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
>  		    errno != EEXIST) {
>  			fprintf(stderr, Name ": Can't create "
>  				"autorebuild.pid file\n");
>  		} else {
> -			fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
> +			fp = fopen(path, "w");
>  			if (!fp)
>  				fprintf(stderr, Name ": Cannot create"
>  					" autorebuild.pid"


Applied (at last).
Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use MDMON_DIR for pid files created in Monitor.c
  2012-02-02 11:45 [PATCH] Use MDMON_DIR for pid files created in Monitor.c Jes.Sorensen
  2012-02-22 22:12 ` NeilBrown
@ 2012-02-23 20:39 ` CoolCold
  2012-02-23 20:47   ` Jes Sorensen
  1 sibling, 1 reply; 4+ messages in thread
From: CoolCold @ 2012-02-23 20:39 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: neilb, linux-raid

On Thu, Feb 2, 2012 at 3:45 PM,  <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> Other parts of mdadm/mdmon place .pid/.sock files in MDMON_DIR. This
> makes Monitor.c consistent with the rest.
>
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---
>  Monitor.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/Monitor.c b/Monitor.c
> index 77f22aa..7ed5282 100644
> --- a/Monitor.c
> +++ b/Monitor.c
> @@ -294,8 +294,10 @@ static int check_one_sharer(int scan)
>        int pid, rv;
>        FILE *fp;
>        char dir[20];
> +       char path[100];
Just wondering why not something like PATH_MAX or similar constant? I
guess there should be one, though 100 should be enough
>        struct stat buf;
> -       fp = fopen("/var/run/mdadm/autorebuild.pid", "r");
> +       sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
> +       fp = fopen(path, "r");
>        if (fp) {
>                if (fscanf(fp, "%d", &pid) != 1)
>                        pid = -1;
> @@ -317,12 +319,12 @@ static int check_one_sharer(int scan)
>                fclose(fp);
>        }
>        if (scan) {
> -               if (mkdir("/var/run/mdadm", S_IRWXU) < 0 &&
> +               if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
>                    errno != EEXIST) {
>                        fprintf(stderr, Name ": Can't create "
>                                "autorebuild.pid file\n");
>                } else {
> -                       fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
> +                       fp = fopen(path, "w");
>                        if (!fp)
>                                fprintf(stderr, Name ": Cannot create"
>                                        " autorebuild.pid"
> --
> 1.7.4.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

This is 2nd copy, first was sent from phone and discarded as contained HTML.

--
Best regards,
[COOLCOLD-RIPN]
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use MDMON_DIR for pid files created in Monitor.c
  2012-02-23 20:39 ` CoolCold
@ 2012-02-23 20:47   ` Jes Sorensen
  0 siblings, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2012-02-23 20:47 UTC (permalink / raw)
  To: CoolCold; +Cc: neilb, linux-raid

On 02/23/12 21:39, CoolCold wrote:
> On Thu, Feb 2, 2012 at 3:45 PM,  <Jes.Sorensen@redhat.com> wrote:
>> > From: Jes Sorensen <Jes.Sorensen@redhat.com>
>> >
>> > Other parts of mdadm/mdmon place .pid/.sock files in MDMON_DIR. This
>> > makes Monitor.c consistent with the rest.
>> >
>> > Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
>> > ---
>> >  Monitor.c |    8 +++++---
>> >  1 files changed, 5 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/Monitor.c b/Monitor.c
>> > index 77f22aa..7ed5282 100644
>> > --- a/Monitor.c
>> > +++ b/Monitor.c
>> > @@ -294,8 +294,10 @@ static int check_one_sharer(int scan)
>> >        int pid, rv;
>> >        FILE *fp;
>> >        char dir[20];
>> > +       char path[100];
> Just wondering why not something like PATH_MAX or similar constant? I
> guess there should be one, though 100 should be enough

I used 100 here because it was consistent with how it is handled
elsewhere in the code. Having a constant would be fine with me, as long
as it is applied consistently.

Jes

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-23 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-02 11:45 [PATCH] Use MDMON_DIR for pid files created in Monitor.c Jes.Sorensen
2012-02-22 22:12 ` NeilBrown
2012-02-23 20:39 ` CoolCold
2012-02-23 20:47   ` Jes Sorensen

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).