Sometimes mdadm prints messages with wrong name "mdmon",
and vice versa.
This patch solves this problem by changing method of determining
process name.
Now "Name" will be set in const at start of a program,
previously was hardcoded as #define.
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
int err;
err = remove_disks_for_takeover(st, sra, array.layout);
if (err) {
int err;
err = remove_disks_for_takeover(st, sra, array.layout);
if (err) {
- dprintf(Name": Array cannot be reshaped\n");
+ dprintf("%s: Array cannot be reshaped\n", Name);
if (cfd > -1)
close(cfd);
rv = 1;
if (cfd > -1)
close(cfd);
rv = 1;
char *ep;
unsigned long long position = strtoull(buf, &ep, 0);
char *ep;
unsigned long long position = strtoull(buf, &ep, 0);
- dprintf(Name": Read sync_max sysfs entry is: %s\n", buf);
+ dprintf("%s: Read sync_max sysfs entry is: %s\n", Name, buf);
if (!(ep == buf || (*ep != 0 && *ep != '\n' && *ep != ' '))) {
position *= get_data_disks(level,
info->new_layout,
if (!(ep == buf || (*ep != 0 && *ep != '\n' && *ep != ' '))) {
position *= get_data_disks(level,
info->new_layout,
return 1;
default: /* parent */
if (!freeze_reshape)
return 1;
default: /* parent */
if (!freeze_reshape)
- printf(Name ": multi-array reshape continues"
- " in background\n");
+ printf("%s: multi-array reshape continues"
+ " in background\n", Name);
return 0;
case 0: /* child */
map_fork();
return 0;
case 0: /* child */
map_fork();
fd = open_dev(mdstat->devnm);
if (fd < 0) {
fd = open_dev(mdstat->devnm);
if (fd < 0) {
- printf(Name ": Device %s cannot be opened for reshape.",
- adev);
+ printf("%s: Device %s cannot be opened for reshape.",
+ Name, adev);
* This is possibly interim until the behaviour of
* reshape_array is resolved().
*/
* This is possibly interim until the behaviour of
* reshape_array is resolved().
*/
- printf(Name ": Multiple reshape execution detected for "
- "device %s.", adev);
+ printf("%s: Multiple reshape execution detected for "
+ "device %s.", Name, adev);
st->ss->free_super(st);
offsets[j] = dinfo.data_offset * 512;
}
st->ss->free_super(st);
offsets[j] = dinfo.data_offset * 512;
}
- printf(Name ": restoring critical section\n");
+ printf("%s: restoring critical section\n", Name);
if (restore_stripes(fdlist, offsets,
info->array.raid_disks,
if (restore_stripes(fdlist, offsets,
info->array.raid_disks,
char buf[32];
if (!id_path)
char buf[32];
if (!id_path)
- dprintf(Name ": incremental removal without --path <id_path> "
+ dprintf("%s: incremental removal without --path <id_path> "
"lacks the possibility to re-add new device in this "
"lacks the possibility to re-add new device in this "
if (strchr(devname, '/')) {
pr_err("incremental removal requires a "
if (strchr(devname, '/')) {
pr_err("incremental removal requires a "
if (info->mailfrom)
fprintf(mp, "From: %s\n", info->mailfrom);
else
if (info->mailfrom)
fprintf(mp, "From: %s\n", info->mailfrom);
else
- fprintf(mp, "From: " Name " monitoring <root>\n");
+ fprintf(mp, "From: %s monitoring <root>\n", Name);
fprintf(mp, "To: %s\n", info->mailaddr);
fprintf(mp, "Subject: %s event on %s:%s\n\n",
event, dev, hname);
fprintf(mp,
"This is an automatically generated"
fprintf(mp, "To: %s\n", info->mailaddr);
fprintf(mp, "Subject: %s event on %s:%s\n\n",
event, dev, hname);
fprintf(mp,
"This is an automatically generated"
- " mail message from " Name "\n");
+ " mail message from %s\n", Name);
fprintf(mp, "running on %s\n\n", hname);
fprintf(mp,
fprintf(mp, "running on %s\n\n", hname);
fprintf(mp,
#ifndef VERS_DATE
#define VERS_DATE "21st August 2014"
#endif
#ifndef VERS_DATE
#define VERS_DATE "21st August 2014"
#endif
-char Version[] = Name " - v" VERSION " - " VERS_DATE "\n";
+char Version[] = "mdadm - v" VERSION " - " VERS_DATE "\n";
struct mddev_ident *ident,
char *dump_directory,
struct supertype *ss, struct context *c);
struct mddev_ident *ident,
char *dump_directory,
struct supertype *ss, struct context *c);
+const char Name[] = "mdadm";
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
if (strcmp(c.update,"?") == 0 ||
strcmp(c.update, "help") == 0) {
outf = stdout;
if (strcmp(c.update,"?") == 0 ||
strcmp(c.update, "help") == 0) {
outf = stdout;
- fprintf(outf, Name ": ");
+ fprintf(outf, "%s: ", Name);
} else {
outf = stderr;
fprintf(outf,
} else {
outf = stderr;
fprintf(outf,
- Name ": '--update=%s' is invalid. ",
- c.update);
+ "%s: '--update=%s' is invalid. ",
+ Name, c.update);
}
fprintf(outf, "Valid --update options are:\n"
" 'sparc2.2', 'super-minor', 'uuid', 'name', 'resync',\n"
}
fprintf(outf, "Valid --update options are:\n"
" 'sparc2.2', 'super-minor', 'uuid', 'name', 'resync',\n"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+extern const char Name[];
+
/* general information that might be extracted from a superblock */
struct mdinfo {
mdu_array_info_t array;
/* general information that might be extracted from a superblock */
struct mdinfo {
mdu_array_info_t array;
struct supertype *supertype;
};
struct supertype *supertype;
};
enum mode {
ASSEMBLE=1,
BUILD,
enum mode {
ASSEMBLE=1,
BUILD,
-#define pr_err(fmt ...) fprintf(stderr, Name ": " fmt)
+#define pr_err(fmt, args...) fprintf(stderr, "%s: "fmt, Name, ##args)
#define cont_err(fmt ...) fprintf(stderr, " " fmt)
void *xmalloc(size_t len);
#define cont_err(fmt ...) fprintf(stderr, " " fmt)
void *xmalloc(size_t len);
#include "mdadm.h"
#include "mdmon.h"
#include "mdadm.h"
#include "mdmon.h"
+char const Name[] = "mdmon";
+
struct active_array *discard_this;
struct active_array *pending_discard;
struct active_array *discard_this;
struct active_array *pending_discard;
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#undef pr_err
-#define pr_err(fmt ...) fprintf(stderr, "mdmon: " fmt)
+extern const char Name[];
enum array_state { clear, inactive, suspended, readonly, read_auto,
clean, active, write_pending, active_idle, bad_word};
enum array_state { clear, inactive, suspended, readonly, read_auto,
clean, active, write_pending, active_idle, bad_word};
- dprintf(Name "(IMSM): Unknown attributes : %x\n", not_supported);
+ dprintf("%s (IMSM): Unknown attributes : %x\n", Name, not_supported);
n = write(fd, val, strlen(val));
close(fd);
if (n != strlen(val)) {
n = write(fd, val, strlen(val));
close(fd);
if (n != strlen(val)) {
- dprintf(Name ": failed to write '%s' to '%s' (%s)\n",
- val, fname, strerror(errno));
+ dprintf("%s: failed to write '%s' to '%s' (%s)\n",
+ Name, val, fname, strerror(errno));
n = write(fd, event, strlen(event));
close(fd);
if (n != (int)strlen(event)) {
n = write(fd, event, strlen(event));
close(fd);
if (n != (int)strlen(event)) {
- dprintf(Name ": failed to write '%s' to '%s' (%s)\n",
- event, fname, strerror(errno));
+ dprintf("%s: failed to write '%s' to '%s' (%s)\n",
+ Name, event, fname, strerror(errno));
char *msg;
if (rv)
return rv;
char *msg;
if (rv)
return rv;
- msg = Name ": memory allocation failure - aborting\n";
+ msg = ": memory allocation failure - aborting\n";
+ write(2, Name, strlen(Name));
exit(4+!!write(2, msg, strlen(msg)));
}
exit(4+!!write(2, msg, strlen(msg)));
}
char *msg;
if (rv)
return rv;
char *msg;
if (rv)
return rv;
- msg = Name ": memory allocation failure - aborting\n";
+ msg = ": memory allocation failure - aborting\n";
+ write(2, Name, strlen(Name));
exit(4+!!write(2, msg, strlen(msg)));
}
exit(4+!!write(2, msg, strlen(msg)));
}
char *msg;
if (rv)
return rv;
char *msg;
if (rv)
return rv;
- msg = Name ": memory allocation failure - aborting\n";
+ msg = ": memory allocation failure - aborting\n";
+ write(2, Name, strlen(Name));
exit(4+!!write(2, msg, strlen(msg)));
}
exit(4+!!write(2, msg, strlen(msg)));
}
char *msg;
if (rv)
return rv;
char *msg;
if (rv)
return rv;
- msg = Name ": memory allocation failure - aborting\n";
+ msg = ": memory allocation failure - aborting\n";
+ write(2, Name, strlen(Name));
exit(4+!!write(2, msg, strlen(msg)));
}
exit(4+!!write(2, msg, strlen(msg)));
}