[DRBD-cvs] svn commit by lars - r2333 - trunk/user - * fix some
bogus "error" messages for dump when protoco
drbd-cvs at lists.linbit.com
drbd-cvs at lists.linbit.com
Thu Aug 3 18:18:55 CEST 2006
Author: lars
Date: 2006-08-03 18:18:52 +0200 (Thu, 03 Aug 2006)
New Revision: 2333
Modified:
trunk/user/drbdadm.h
trunk/user/drbdadm_main.c
trunk/user/drbdadm_usage_cnt.c
trunk/user/drbdsetup.c
Log:
* fix some bogus "error" messages for dump
when protocol is defined in common section only
* make "drbdadm -d dump" expand the common section
* fix usage count dialog to do nothing when called
from init, or stdin/stdout is not a tty, and
make additional output go to stderr in any case,
to not confuse "X=`drbdadm sh-resources`" and the like.
Modified: trunk/user/drbdadm.h
===================================================================
--- trunk/user/drbdadm.h 2006-08-03 10:17:00 UTC (rev 2332)
+++ trunk/user/drbdadm.h 2006-08-03 16:18:52 UTC (rev 2333)
@@ -127,6 +127,7 @@
extern struct d_globals global_options;
extern int line, fline, c_resource_start;
+extern int no_tty;
extern int dry_run;
extern char* drbdsetup;
extern char ss_buffer[255];
Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c 2006-08-03 10:17:00 UTC (rev 2332)
+++ trunk/user/drbdadm_main.c 2006-08-03 16:18:52 UTC (rev 2333)
@@ -120,6 +120,7 @@
int nr_resources;
int highest_minor;
int config_valid=1;
+int no_tty;
int dry_run;
int do_verify_ips;
char* drbdsetup;
@@ -320,6 +321,7 @@
{
printI("resource %s {\n",esc(res->name)); ++indent;
if(res->protocol) printA("protocol",res->protocol);
+ // else if (common && common->protocol) printA("# common protocol", common->protocol);
dump_host_info(res->me);
dump_host_info(res->peer);
dump_options("net",res->net_options);
@@ -1016,7 +1018,7 @@
saved_stdin = -1;
saved_stdout = -1;
- if( isatty(fileno(stdin)) == 0 || isatty(fileno(stdout)) == 0 ) {
+ if (no_tty) {
fprintf(stderr,"WARN: stdin/stdout is not a TTY; using /dev/console");
fprintf(stdout,"WARN: stdin/stdout is not a TTY; using /dev/console");
saved_stdin = dup(fileno(stdin));
@@ -1337,10 +1339,13 @@
struct d_option* opt;
if (!res->protocol) {
- fprintf(stderr,
- "%s:%d: in resource %s:\n\tprotocol definition missing.\n",
- config_file, c_resource_start, res->name);
- config_valid = 0;
+ if (!common || !common->protocol) {
+ fprintf(stderr,
+ "%s:%d: in resource %s:\n\tprotocol definition missing.\n",
+ config_file, c_resource_start, res->name);
+ config_valid = 0;
+ } /* else:
+ * may not have been expanded yet for "dump" subcommand */
} else {
res->protocol[0] = toupper(res->protocol[0]);
}
@@ -1408,6 +1413,7 @@
dry_run=0;
yyin=NULL;
uname(&nodeinfo); /* FIXME maybe fold to lower case ? */
+ no_tty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));
env_drbd_nodename = getenv("__DRBD_NODE__");
if (env_drbd_nodename && *env_drbd_nodename) {
@@ -1612,9 +1618,9 @@
if (optind + 1 > argc && !is_dump)
print_usage_and_exit("missing arguments"); // arguments missing.
- if(!is_dump) {
- expand_common();
- global_validate();
+ if (!is_dump || dry_run) expand_common();
+ global_validate();
+ if (!is_dump) {
if(!config_valid) exit(E_config_invalid);
for_each_resource(res,tmp,config) {
Modified: trunk/user/drbdadm_usage_cnt.c
===================================================================
--- trunk/user/drbdadm_usage_cnt.c 2006-08-03 10:17:00 UTC (rev 2332)
+++ trunk/user/drbdadm_usage_cnt.c 2006-08-03 16:18:52 UTC (rev 2333)
@@ -268,7 +268,7 @@
if (buffer[0] == '\r' || buffer[0] == '\n')
writeit = 1;
} else {
- printf("%s", buffer);
+ fprintf(stderr,"%s", buffer);
}
}
fclose(sockfd);
@@ -316,6 +316,14 @@
if( type == UC_NO ) return;
if( getuid() != 0 ) return;
+ /* not when running directly from init,
+ * or if stdout is no tty.
+ * you do not want to have the "user information message"
+ * as output from `drbdadm sh-resources all`
+ */
+ if (getenv("INIT_VERSION")) return;
+ if (no_tty) return;
+
current = current_svn_revision();
if( ! read_node_id(&ni) ) {
@@ -335,7 +343,7 @@
n_comment[0]=0;
if (type == UC_ASK ) {
- printf(
+ fprintf(stderr,
"\n"
"\t\t--== This is %s of DRBD ==--\n"
"Please take part in the global DRBD usage count at http://"HTTP_HOST".\n\n"
@@ -370,12 +378,12 @@
if (send) {
write_node_id(&ni);
- printf(
+ fprintf(stderr,
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
" --== Thank you for participating in the global usage survey ==--\n"
"The server's response is:\n\n");
make_get_request(req_buf);
- printf(
+ fprintf(stderr,
"\n"
"In the future drbdadm will only contact "HTTP_HOST" when you update\n"
"DRBD or when you use 'drbdadm create-md'. Of course it will continue\n"
@@ -458,7 +466,7 @@
if( global_options.usage_count == UC_YES ) send = 1;
if( global_options.usage_count == UC_ASK ) {
- printf(
+ fprintf(stderr,
"\n"
"\t\t--== Creating metadata ==--\n"
"As with nodes we count the total number of devices mirrored by DRBD at\n"
Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c 2006-08-03 10:17:00 UTC (rev 2332)
+++ trunk/user/drbdsetup.c 2006-08-03 16:18:52 UTC (rev 2333)
@@ -943,10 +943,10 @@
int cmd_syncer(int drbd_fd,char** argv,int argc,struct option *options)
{
struct ioctl_syncer_config cn;
- struct ioctl_get_config current_cn;
int err;
/*
+ struct ioctl_get_config current_cn;
err=ioctl(drbd_fd,DRBD_IOCTL_GET_CONFIG,¤t_cn);
if(err)
{
More information about the drbd-cvs
mailing list