On Wednesday 21 February 2007 21:19, Jeroen van der Ham wrote:
> Blaisorblade wrote:
> > Using > /dev/null 2>&1 is not suitable?
>
> Well yes, that might also help.
> However, when you supply a daemon mode, I think it is also a good idea to
> add a silent feature, so that it is more easily and cleanly scriptable.

Hmm. It's a possibility, implemented and attached (1st uml_switch-* then 
use-sil_-funcs), but I don't like it. Unless we don't use syslog(3), or at 
least errors early at boot are reported.

> > In fact, docs do not talk about '-daemon' - I was the first to document
> > it when happening to see it in sources. The web page says:

> Well, Matt Zimmerman of the Debian team also found it and even wrote a
> whole nice man page for uml_switch (and other tools) that comes with
> "apt-get install uml-utilities" :)

Nice to know. I've received the man pages from Debian maintainers and I'll 
integrate them.

> I'm sorry, but I don't really know how to get more information besides
> that...

No problem, what you say is already enough for me to conclude that things are 
ok with the patch.
-- 
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Index: tools/uml_switch/switch.h
===================================================================
--- tools.orig/uml_switch/switch.h
+++ tools/uml_switch/switch.h
@@ -6,5 +6,24 @@
 #define __SWITCH_H__
 
 #define ETH_ALEN 6
+extern int quiet;
+
+#define sil_printf(args...)		\
+	do {				\
+	    if (!quiet) 		\
+    		printf(args);		\
+	} while (0)
+
+#define sil_fprintf(args...)		\
+	do {				\
+	    if (!quiet) 		\
+    		fprintf(args);		\
+	} while (0)
+
+#define sil_perror(str)			\
+	do {				\
+	    if (!quiet) 		\
+    		perror(str);		\
+	} while (0)
 
 #endif
Index: tools/uml_switch/tuntap.c
===================================================================
--- tools.orig/uml_switch/tuntap.c
+++ tools/uml_switch/tuntap.c
@@ -7,6 +7,7 @@
 #include <net/if.h>
 #include <linux/if_tun.h>
 #include "port.h"
+#include "switch.h"
 
 static void send_tap(int fd, void *packet, int len, void *unused)
 {
Index: tools/uml_switch/uml_switch.c
===================================================================
--- tools.orig/uml_switch/uml_switch.c
+++ tools/uml_switch/uml_switch.c
@@ -26,6 +26,7 @@
 
 static int hub = 0;
 static int compat_v0 = 0;
+int quiet = 0;
 
 enum request_type { REQ_NEW_CONTROL };
 
@@ -403,6 +404,8 @@ void bind_sockets(int ctl_fd, const char
 					In this case, -unix is used as:\n\
    -unix control-socket	data-socket	Specify a different path for the\n\
 					control- and data- socket\n\
+   -quiet				To be used with -daemon, omit any\n\
+					message from stdout/stderr\n\
 "
 
 static void Usage(void)
@@ -413,8 +416,8 @@ static void Usage(void)
   tap_str = "[ -tap tap-device ]";
 #endif
 
-  fprintf(stderr, "Usage : %s [ -unix control-socket ] [ -daemon ] [ -hub ] %s\n"
-	  "or : %s -compat-v0 [ -unix control-socket data-socket ] [ -daemon ] "
+  fprintf(stderr, "Usage : %s [ -quiet ] [ -unix control-socket ] [ -daemon ] [ -hub ] %s\n"
+	  "or : %s -compat-v0 [ -quiet ] [ -unix control-socket data-socket ] [ -daemon ] "
 	  "[ -hub ] %s\n", prog, tap_str, prog, tap_str);
   fprintf(stderr, HELP_TEXT);
 
@@ -477,6 +480,11 @@ int main(int argc, char **argv)
       argc--;
       argv++;
     }
+    else if(!strcmp(argv[0], "-quiet")){
+      quiet = 1;
+      argc--;
+      argv++;
+    }
     else Usage();
   }
 
Index: tools/uml_switch/tuntap.c
===================================================================
--- tools.orig/uml_switch/tuntap.c
+++ tools/uml_switch/tuntap.c
@@ -15,7 +15,7 @@ static void send_tap(int fd, void *packe
 
   n = write(fd, packet, len);
   if(n != len){
-    if(errno != EAGAIN) perror("send_tap");
+    if(errno != EAGAIN) sil_perror("send_tap");
   }
 }
 
@@ -25,14 +25,14 @@ int open_tap(char *dev)
   int fd, err;
 
   if((fd = open("/dev/net/tun", O_RDWR)) < 0){
-    perror("Failed to open /dev/net/tun");
+    sil_perror("Failed to open /dev/net/tun");
     return(-1);
   }
   memset(&ifr, 0, sizeof(ifr));
   ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
   strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
   if(ioctl(fd, TUNSETIFF, (void *) &ifr) < 0){
-    perror("TUNSETIFF failed");
+    sil_perror("TUNSETIFF failed");
     close(fd);
     return(-1);
   }
Index: tools/uml_switch/uml_switch.c
===================================================================
--- tools.orig/uml_switch/uml_switch.c
+++ tools/uml_switch/uml_switch.c
@@ -87,12 +87,12 @@ static struct sockaddr_un data_sun;
 static void cleanup(void)
 {
   if(unlink(ctl_socket) < 0){
-    printf("Couldn't remove control socket '%s' : ", ctl_socket);
-    perror("");
+    sil_printf("Couldn't remove control socket '%s' : ", ctl_socket);
+    sil_perror("");
   }
   if((data_socket != NULL) && (unlink(data_socket) < 0)){
-    printf("Couldn't remove data socket '%s' : ", data_socket);
-    perror("");
+    sil_printf("Couldn't remove data socket '%s' : ", data_socket);
+    sil_perror("");
   }
 }
 
@@ -107,7 +107,7 @@ static void add_fd(int fd)
   if(nfds == maxfds){
     maxfds = maxfds ? 2 * maxfds : 4;
     if((fds = realloc(fds, maxfds * sizeof(struct pollfd))) == NULL){
-      perror("realloc");
+      sil_perror("realloc");
       cleanup();
       exit(1);
     }
@@ -125,7 +125,7 @@ static void remove_fd(int fd)
     if(fds[i].fd == fd) break;
   }
   if(i == nfds){
-    fprintf(stderr, "remove_fd : Couldn't find descriptor %d\n", fd);
+    sil_fprintf(stderr, "remove_fd : Couldn't find descriptor %d\n", fd);
   }
   memmove(&fds[i], &fds[i + 1], (maxfds - i - 1) * sizeof(struct pollfd));
   nfds--;
@@ -133,7 +133,7 @@ static void remove_fd(int fd)
 
 static void sig_handler(int sig)
 {
-  printf("Caught signal %d, cleaning up and exiting\n", sig);
+  sil_printf("Caught signal %d, cleaning up and exiting\n", sig);
   cleanup();
   signal(sig, SIG_DFL);
   kill(getpid(), sig);
@@ -153,7 +153,7 @@ static void new_port_v0(int fd, struct r
     setup_sock_port(fd, &req->u.new_control.name, data_fd);
     break;
   default:
-    printf("Bad request type : %d\n", req->type);
+    sil_printf("Bad request type : %d\n", req->type);
     close_descriptor(fd);
   }
 }
@@ -169,19 +169,19 @@ static void new_port_v1_v3(int fd, enum 
     if(err) return;
     n = write(fd, &data_sun, sizeof(data_sun));
     if(n != sizeof(data_sun)){
-      perror("Sending data socket name");
+      sil_perror("Sending data socket name");
       close_descriptor(fd);
     }
     break;
   default:
-    printf("Bad request type : %d\n", type);
+    sil_printf("Bad request type : %d\n", type);
     close_descriptor(fd);
   }
 }
 
 static void new_port_v2(int fd)
 {
-  fprintf(stderr, "Version 2 is not supported\n");
+  sil_fprintf(stderr, "Version 2 is not supported\n");
   close_descriptor(fd);
 }
 
@@ -193,13 +193,13 @@ static void new_port(int fd, int data_fd
   len = read(fd, &req, sizeof(req));
   if(len < 0){
     if(errno != EAGAIN){
-      perror("Reading request");
+      sil_perror("Reading request");
       close_descriptor(fd);
     }
     return;
   }
   else if(len == 0){
-    printf("EOF from new port\n");
+    sil_printf("EOF from new port\n");
     close_descriptor(fd);
     return;
   }
@@ -208,7 +208,7 @@ static void new_port(int fd, int data_fd
     if(req.v3.version == 3) 
       new_port_v1_v3(fd, req.v3.type, &req.v3.sock, data_fd);
     else if(req.v2.version > 2) 
-      fprintf(stderr, "Request for a version %d port, which this "
+      sil_fprintf(stderr, "Request for a version %d port, which this "
 	      "uml_switch doesn't support\n", req.v2.version);
     else new_port_v1_v3(fd, req.v1.type, &req.v1.u.new_control.name, data_fd);
   }
@@ -224,11 +224,11 @@ void accept_connection(int fd)
   len = sizeof(addr);
   new = accept(fd, &addr, &len);
   if(new < 0){
-    perror("accept");
+    sil_perror("accept");
     return;
   }
   if(fcntl(new, F_SETFL, O_NONBLOCK) < 0){
-    perror("fcntl - setting O_NONBLOCK");
+    sil_perror("fcntl - setting O_NONBLOCK");
     close(new);
     return;
   }
@@ -240,19 +240,19 @@ int still_used(struct sockaddr_un *sun)
   int test_fd, ret = 1;
 
   if((test_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0){
-    perror("socket");
+    sil_perror("socket");
     exit(1);
   }
   if(connect(test_fd, (struct sockaddr *) sun, sizeof(*sun)) < 0){
     if(errno == ECONNREFUSED){
       if(unlink(sun->sun_path) < 0){
-	fprintf(stderr, "Failed to removed unused socket '%s': ", 
+	sil_fprintf(stderr, "Failed to removed unused socket '%s': ",
 		sun->sun_path);
-	perror("");
+	sil_perror("");
       }
       ret = 0;
     }
-    else perror("connect");
+    else sil_perror("connect");
   }
   close(test_fd);
   return(ret);
@@ -268,7 +268,7 @@ int bind_socket(int fd, const char *name
   if(bind(fd, (struct sockaddr *) &sun, sizeof(sun)) < 0){
     if((errno == EADDRINUSE) && still_used(&sun)) return(EADDRINUSE);
     else if(bind(fd, (struct sockaddr *) &sun, sizeof(sun)) < 0){
-      perror("bind");
+      sil_perror("bind");
       return(EPERM);
     }
   }
@@ -300,40 +300,40 @@ void bind_sockets_v0(int ctl_fd, const c
   try_remove_ctl = ctl_present;
   try_remove_data = data_present;
   if(ctl_present && ctl_used){
-    fprintf(stderr, "The control socket '%s' has another server "
+    sil_fprintf(stderr, "The control socket '%s' has another server "
 	    "attached to it\n", ctl_name);
     try_remove_ctl = 0;
   }
   else if(ctl_present && !ctl_used)
-    fprintf(stderr, "The control socket '%s' exists, isn't used, but couldn't "
+    sil_fprintf(stderr, "The control socket '%s' exists, isn't used, but couldn't "
 	    "be removed\n", ctl_name);
   if(data_present && data_used){
-    fprintf(stderr, "The data socket '%s' has another server "
+    sil_fprintf(stderr, "The data socket '%s' has another server "
 	    "attached to it\n", data_name);
     try_remove_data = 0;
   }
   else if(data_present && !data_used)
-    fprintf(stderr, "The data socket '%s' exists, isn't used, but couldn't "
+    sil_fprintf(stderr, "The data socket '%s' exists, isn't used, but couldn't "
 	    "be removed\n", data_name);
   if(try_remove_ctl || try_remove_data){
-    fprintf(stderr, "You can either\n");
+    sil_fprintf(stderr, "You can either\n");
     if(try_remove_ctl && !try_remove_data) 
-      fprintf(stderr, "\tremove '%s'\n", ctl_socket);
+      sil_fprintf(stderr, "\tremove '%s'\n", ctl_socket);
     else if(!try_remove_ctl && try_remove_data) 
-      fprintf(stderr, "\tremove '%s'\n", data_socket);
-    else fprintf(stderr, "\tremove '%s' and '%s'\n", ctl_socket, data_socket);
-    fprintf(stderr, "\tor rerun with different, unused filenames for "
+      sil_fprintf(stderr, "\tremove '%s'\n", data_socket);
+    else sil_fprintf(stderr, "\tremove '%s' and '%s'\n", ctl_socket, data_socket);
+    sil_fprintf(stderr, "\tor rerun with different, unused filenames for "
 	    "sockets:\n");
-    fprintf(stderr, "\t\t%s -unix <control> <data>\n", prog);
-    fprintf(stderr, "\t\tand run the UMLs with "
+    sil_fprintf(stderr, "\t\t%s -unix <control> <data>\n", prog);
+    sil_fprintf(stderr, "\t\tand run the UMLs with "
 	    "'eth0=daemon,,unix,<control>,<data>\n");
     exit(1);
   }
   else {
-    fprintf(stderr, "You should rerun with different, unused filenames for "
+    sil_fprintf(stderr, "You should rerun with different, unused filenames for "
 	    "sockets:\n");
-    fprintf(stderr, "\t%s -unix <control> <data>\n", prog);
-    fprintf(stderr, "\tand run the UMLs with "
+    sil_fprintf(stderr, "\t%s -unix <control> <data>\n", prog);
+    sil_fprintf(stderr, "\tand run the UMLs with "
 	    "'eth0=daemon,,unix,<control>,<data>'\n");
     exit(1);
   }
@@ -355,7 +355,7 @@ void bind_data_socket(int fd, struct soc
   sun->sun_family = AF_UNIX;
   memcpy(sun->sun_path, &name, sizeof(name));
   if(bind(fd, (struct sockaddr *) sun, sizeof(*sun)) < 0){
-    perror("Binding to data socket");
+    sil_perror("Binding to data socket");
     exit(1);
   }
 }
@@ -372,15 +372,15 @@ void bind_sockets(int ctl_fd, const char
   else if(err == EADDRINUSE) used = 1;
   
   if(used){
-    fprintf(stderr, "The control socket '%s' has another server "
+    sil_fprintf(stderr, "The control socket '%s' has another server "
 	    "attached to it\n", ctl_name);
-    fprintf(stderr, "You can either\n");
-    fprintf(stderr, "\tremove '%s'\n", ctl_name);
-    fprintf(stderr, "\tor rerun with a different, unused filename for a "
+    sil_fprintf(stderr, "You can either\n");
+    sil_fprintf(stderr, "\tremove '%s'\n", ctl_name);
+    sil_fprintf(stderr, "\tor rerun with a different, unused filename for a "
 	    "socket\n");
   }
   else
-    fprintf(stderr, "The control socket '%s' exists, isn't used, but couldn't "
+    sil_fprintf(stderr, "The control socket '%s' exists, isn't used, but couldn't "
 	    "be removed\n", ctl_name);
   exit(1);
 }
@@ -416,10 +416,10 @@ static void Usage(void)
   tap_str = "[ -tap tap-device ]";
 #endif
 
-  fprintf(stderr, "Usage : %s [ -quiet ] [ -unix control-socket ] [ -daemon ] [ -hub ] %s\n"
+  sil_fprintf(stderr, "Usage : %s [ -quiet ] [ -unix control-socket ] [ -daemon ] [ -hub ] %s\n"
 	  "or : %s -compat-v0 [ -quiet ] [ -unix control-socket data-socket ] [ -daemon ] "
 	  "[ -hub ] %s\n", prog, tap_str, prog, tap_str);
-  fprintf(stderr, HELP_TEXT);
+  sil_fprintf(stderr, HELP_TEXT);
 
   exit(1);
 }
@@ -458,18 +458,18 @@ int main(int argc, char **argv)
       argv += 2;
       argc -= 2;
 #else
-      fprintf(stderr, "-tap isn't supported since TUNTAP isn't enabled\n");
+      sil_fprintf(stderr, "-tap isn't supported since TUNTAP isn't enabled\n");
       Usage();
 #endif      
     }
     else if(!strcmp(argv[0], "-hub")){
-      printf("%s will be a hub instead of a switch\n", prog);
+      sil_printf("%s will be a hub instead of a switch\n", prog);
       hub = 1;
       argc--;
       argv++;
     }
     else if(!strcmp(argv[0], "-compat-v0")){
-      printf("Control protocol 0 compatibility\n");
+      sil_printf("Control protocol 0 compatibility\n");
       compat_v0 = 1;
       data_socket = "/tmp/uml.data";
       argc--;
@@ -489,24 +489,24 @@ int main(int argc, char **argv)
   }
 
   if((connect_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0){
-    perror("socket");
+    sil_perror("socket");
     exit(1);
   }
   if(setsockopt(connect_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, 
 		sizeof(one)) < 0){
-    perror("setsockopt");
+    sil_perror("setsockopt");
     exit(1);
   }
   if(fcntl(connect_fd, F_SETFL, O_NONBLOCK) < 0){
-    perror("Setting O_NONBLOCK on connection fd");
+    sil_perror("Setting O_NONBLOCK on connection fd");
     exit(1);
   }
   if((data_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0){
-    perror("socket");
+    sil_perror("socket");
     exit(1);
   }
   if(fcntl(data_fd, F_SETFL, O_NONBLOCK) < 0){
-    perror("Setting O_NONBLOCK on data fd");
+    sil_perror("Setting O_NONBLOCK on data fd");
     exit(1);
   }
 
@@ -514,24 +514,24 @@ int main(int argc, char **argv)
   else bind_sockets(connect_fd, ctl_socket, data_fd);
 
   if(listen(connect_fd, 15) < 0){
-    perror("listen");
+    sil_perror("listen");
     exit(1);
   }
 
   if(signal(SIGINT, sig_handler) == SIG_ERR)
-    perror("Setting handler for SIGINT");
+    sil_perror("Setting handler for SIGINT");
   hash_init();
 
   if(compat_v0) 
-    printf("%s attached to unix sockets '%s' and '%s'", prog, ctl_socket,
+    sil_printf("%s attached to unix sockets '%s' and '%s'", prog, ctl_socket,
 	   data_socket);
-  else printf("%s attached to unix socket '%s'", prog, ctl_socket);
+  else sil_printf("%s attached to unix socket '%s'", prog, ctl_socket);
 
 #ifdef TUNTAP
   if(tap_dev != NULL)
-    printf(" tap device '%s'", tap_dev);
+    sil_printf(" tap device '%s'", tap_dev);
 #endif
-  printf("\n");
+  sil_printf("\n");
 
   if(isatty(0) && !daemonize)
     add_fd(0);
@@ -546,12 +546,12 @@ int main(int argc, char **argv)
   if (daemonize) {
     int nullfd;
     if (daemon(0, 1)) {
-      perror("daemon");
+      sil_perror("daemon");
       exit(1);
     }
     nullfd = open("/dev/null", O_RDONLY);
     if (dup2(nullfd, 0))
-      perror("dup2 /dev/null to 0");
+      sil_perror("dup2 /dev/null to 0");
     close(nullfd);
   }
 
@@ -561,30 +561,30 @@ int main(int argc, char **argv)
     n = poll(fds, nfds, -1);
     if(n < 0){
       if(errno == EINTR) continue;
-      perror("poll");
+      sil_perror("poll");
       break;
     }
     for(i = 0; i < nfds; i++){
       if(fds[i].revents == 0) continue;
       if(fds[i].fd == 0){
 	if(fds[i].revents & POLLHUP){
-	  printf("EOF on stdin, cleaning up and exiting\n");
+	  sil_printf("EOF on stdin, cleaning up and exiting\n");
 	  goto out;
 	}
 
 	n = read(0, buf, sizeof(buf));
 	if(n < 0){
-	  perror("Reading from stdin");
+	  sil_perror("Reading from stdin");
 	  break;
 	}
 	else if(n == 0){
-	  printf("EOF on stdin, cleaning up and exiting\n");
+	  sil_printf("EOF on stdin, cleaning up and exiting\n");
 	  goto out;
 	}
       }
       else if(fds[i].fd == connect_fd){
 	if(fds[i].revents & POLLHUP){
-	  printf("Error on connection fd\n");
+	  sil_printf("Error on connection fd\n");
 	  continue;
 	}
 	accept_connection(connect_fd);
Index: tools/uml_switch/hash.c
===================================================================
--- tools.orig/uml_switch/hash.c
+++ tools/uml_switch/hash.c
@@ -61,7 +61,7 @@ void insert_into_hash(unsigned char *src
 
   new = malloc(sizeof(*new));
   if(new == NULL){
-    perror("Failed to malloc hash entry");
+    sil_perror("Failed to malloc hash entry");
     return;
   }
 
@@ -123,7 +123,7 @@ static void print_hash_entry(struct hash
 {
   struct printer *p = arg;
 
-  printf("Hash: %d Addr: %02x:%02x:%02x:%02x:%02x:%02x to port: %s  " 
+  sil_printf("Hash: %d Addr: %02x:%02x:%02x:%02x:%02x:%02x to port: %s  "
 	 "age %ld secs\n", calc_hash(e->dst),
 	 e->dst[0], e->dst[1], e->dst[2], e->dst[3], e->dst[4], e->dst[5],
 	 (*p->port_id)(e->port), (int) p->now - e->last_seen);
@@ -168,7 +168,7 @@ void hash_init(void)
   sa.sa_handler = sig_alarm;
   sa.sa_flags = SA_RESTART;
   if(sigaction(SIGALRM, &sa, NULL) < 0){
-    perror("Setting handler for SIGALRM");
+    sil_perror("Setting handler for SIGALRM");
     return;
   }
   kill(getpid(), SIGALRM);
Index: tools/uml_switch/port.c
===================================================================
--- tools.orig/uml_switch/port.c
+++ tools/uml_switch/port.c
@@ -47,7 +47,7 @@ void close_port(int fd)
     if(port->control == fd) break;
   }
   if(port == NULL){
-    fprintf(stderr, "No port associated with descriptor %d\n", fd);
+    sil_fprintf(stderr, "No port associated with descriptor %d\n", fd);
     return;
   }
   delete_hash(port->src);
@@ -66,16 +66,16 @@ static void update_src(struct port *port
   if(port != last){
     /* old value differs from actual input port */
 
-    printf(" Addr: %02x:%02x:%02x:%02x:%02x:%02x New port %d",
+    sil_printf(" Addr: %02x:%02x:%02x:%02x:%02x:%02x New port %d",
 	   p->header.src[0], p->header.src[1], p->header.src[2],
 	   p->header.src[3], p->header.src[4], p->header.src[5],
 	   port->control);
 
     if(last != NULL){
-      printf(" old port %d", last->control);
+      sil_printf(" old port %d", last->control);
       delete_hash(p->header.src);
     }
-    printf("\n");
+    sil_printf("\n");
 
     memcpy(port->src, p->header.src, sizeof(port->src));
     insert_into_hash(p->header.src, port);
@@ -91,12 +91,12 @@ static void send_dst(struct port *port, 
   target = find_in_hash(packet->header.dest);
   if((target == NULL) || IS_BROADCAST(packet->header.dest) || hub){
     if((target == NULL) && !IS_BROADCAST(packet->header.dest)){
-      printf("unknown Addr: %02x:%02x:%02x:%02x:%02x:%02x from port ",
+      sil_printf("unknown Addr: %02x:%02x:%02x:%02x:%02x:%02x from port ",
 	     packet->header.src[0], packet->header.src[1], 
 	     packet->header.src[2], packet->header.src[3], 
 	     packet->header.src[4], packet->header.src[5]);
-      if(port == NULL) printf("UNKNOWN\n");
-      else printf("%d\n", port->control);
+      if(port == NULL) sil_printf("UNKNOWN\n");
+      else sil_printf("%d\n", port->control);
     } 
 
     /* no cache or broadcast/multicast == all ports */
@@ -124,7 +124,7 @@ static void handle_data(int fd, int hub,
   
   /* if we have an incoming port (we should) */
   if(p != NULL) update_src(p, packet);
-  else printf("Unknown connection for packet, shouldn't happen.\n");
+  else sil_printf("Unknown connection for packet, shouldn't happen.\n");
 
   send_dst(p, packet, len, hub);  
 }
@@ -142,7 +142,7 @@ void handle_tap_data(int fd, int hub)
 
   len = read(fd, &packet, sizeof(packet));
   if(len < 0){
-    if(errno != EAGAIN) perror("Reading tap data");
+    if(errno != EAGAIN) sil_perror("Reading tap data");
     return;
   }
   handle_data(fd, hub, &packet, len, NULL, match_tap);
@@ -155,7 +155,7 @@ int setup_port(int fd, void (*sender)(in
 
   port = malloc(sizeof(struct port));
   if(port == NULL){
-    perror("malloc");
+    sil_perror("malloc");
     return(-1);
   }
   port->next = head;
@@ -166,7 +166,7 @@ int setup_port(int fd, void (*sender)(in
   port->data_len = data_len;
   port->sender = sender;
   head = port;
-  printf("New connection\n");
+  sil_printf("New connection\n");
   return(0);
 }
 
@@ -185,9 +185,9 @@ static void send_sock(int fd, void *pack
   if(err != len) {
     int saved_errno = errno;
     if (saved_errno != EAGAIN) {
-      fprintf(stderr, "send_sock sending to fd %d ", mine->fd);
+      sil_fprintf(stderr, "send_sock sending to fd %d ", mine->fd);
       errno = saved_errno;
-      perror("");
+      sil_perror("");
     }
   }
 }
@@ -212,7 +212,7 @@ void handle_sock_data(int fd, int hub)
   len = recvfrom(fd, &packet, sizeof(packet), 0, 
 		 (struct sockaddr *) &data.sock, &socklen);
   if(len < 0){
-    if(errno != EAGAIN) perror("handle_sock_data");
+    if(errno != EAGAIN) sil_perror("handle_sock_data");
     return;
   }
   data.fd = fd;
@@ -226,7 +226,7 @@ int setup_sock_port(int fd, struct socka
 
   data = malloc(sizeof(*data));
   if(data == NULL){
-    perror("setup_sock_port");
+    sil_perror("setup_sock_port");
     return(-1);
   }
   *data = ((struct sock_data) { fd : 	data_fd,
@@ -240,9 +240,9 @@ static void service_port(struct port *po
   char c;
 
   n = read(port->control, &c, sizeof(c));
-  if(n < 0) perror("Reading request");
-  else if(n == 0) printf("Disconnect\n");
-  else printf("Bad request\n");  
+  if(n < 0) sil_perror("Reading request");
+  else if(n == 0) sil_printf("Disconnect\n");
+  else sil_printf("Bad request\n");
 }
 
 int handle_port(int fd)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to