replacing func() with xfunc() where appropriate

This commit is contained in:
Denis Vlasenko 2006-09-03 12:21:59 +00:00
parent 87d80dcc3e
commit 27af5a0dd3
6 changed files with 12 additions and 21 deletions

View File

@ -454,7 +454,7 @@ DIR *xopendir(const char *path)
/* Die with an error message if we can't daemonize. */ /* Die with an error message if we can't daemonize. */
void xdaemon(int nochdir, int noclose) void xdaemon(int nochdir, int noclose)
{ {
if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon"); if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon");
} }
#endif #endif
#endif #endif

View File

@ -259,7 +259,7 @@ int arping_main(int argc, char **argv)
char *source = NULL; char *source = NULL;
char *target; char *target;
s = socket(PF_PACKET, SOCK_DGRAM, 0); s = xsocket(PF_PACKET, SOCK_DGRAM, 0);
ifindex = errno; ifindex = errno;
// Drop suid root privileges // Drop suid root privileges
@ -346,11 +346,8 @@ int arping_main(int argc, char **argv)
if (!(cfg&dad) || src.s_addr) { if (!(cfg&dad) || src.s_addr) {
struct sockaddr_in saddr; struct sockaddr_in saddr;
int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); /* maybe use bb_xsocket? */ int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0);
if (probe_fd < 0) {
bb_error_msg_and_die("socket");
}
if (device) { if (device) {
if (setsockopt if (setsockopt
(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, (probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device,

View File

@ -135,7 +135,7 @@ static int godaemon(void)
switch (fork()) { switch (fork()) {
case -1: case -1:
bb_perror_msg_and_die("Could not fork"); bb_perror_msg_and_die("fork");
case 0: case 0:
pw = getpwnam(nobodystr); pw = getpwnam(nobodystr);

View File

@ -43,7 +43,7 @@ static int do_ioctl_get_ifindex(char *dev)
int fd; int fd;
strcpy(ifr.ifr_name, dev); strcpy(ifr.ifr_name, dev);
fd = socket(AF_INET, SOCK_DGRAM, 0); fd = xsocket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(fd, SIOCGIFINDEX, &ifr)) { if (ioctl(fd, SIOCGIFINDEX, &ifr)) {
bb_perror_msg("ioctl"); bb_perror_msg("ioctl");
return 0; return 0;
@ -58,7 +58,7 @@ static int do_ioctl_get_iftype(char *dev)
int fd; int fd;
strcpy(ifr.ifr_name, dev); strcpy(ifr.ifr_name, dev);
fd = socket(AF_INET, SOCK_DGRAM, 0); fd = xsocket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(fd, SIOCGIFHWADDR, &ifr)) { if (ioctl(fd, SIOCGIFHWADDR, &ifr)) {
bb_perror_msg("ioctl"); bb_perror_msg("ioctl");
return -1; return -1;
@ -74,7 +74,7 @@ static char *do_ioctl_get_ifname(int idx)
int fd; int fd;
ifr.ifr_ifindex = idx; ifr.ifr_ifindex = idx;
fd = socket(AF_INET, SOCK_DGRAM, 0); fd = xsocket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(fd, SIOCGIFNAME, &ifr)) { if (ioctl(fd, SIOCGIFNAME, &ifr)) {
bb_perror_msg("ioctl"); bb_perror_msg("ioctl");
return NULL; return NULL;
@ -93,7 +93,7 @@ static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p)
strcpy(ifr.ifr_name, basedev); strcpy(ifr.ifr_name, basedev);
ifr.ifr_ifru.ifru_data = (void*)p; ifr.ifr_ifru.ifru_data = (void*)p;
fd = socket(AF_INET, SOCK_DGRAM, 0); fd = xsocket(AF_INET, SOCK_DGRAM, 0);
err = ioctl(fd, SIOCGETTUNNEL, &ifr); err = ioctl(fd, SIOCGETTUNNEL, &ifr);
if (err) { if (err) {
bb_perror_msg("ioctl"); bb_perror_msg("ioctl");
@ -114,7 +114,7 @@ static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p)
strcpy(ifr.ifr_name, basedev); strcpy(ifr.ifr_name, basedev);
} }
ifr.ifr_ifru.ifru_data = (void*)p; ifr.ifr_ifru.ifru_data = (void*)p;
fd = socket(AF_INET, SOCK_DGRAM, 0); fd = xsocket(AF_INET, SOCK_DGRAM, 0);
err = ioctl(fd, cmd, &ifr); err = ioctl(fd, cmd, &ifr);
if (err) { if (err) {
bb_perror_msg("ioctl"); bb_perror_msg("ioctl");
@ -135,7 +135,7 @@ static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p)
strcpy(ifr.ifr_name, basedev); strcpy(ifr.ifr_name, basedev);
} }
ifr.ifr_ifru.ifru_data = (void*)p; ifr.ifr_ifru.ifru_data = (void*)p;
fd = socket(AF_INET, SOCK_DGRAM, 0); fd = xsocket(AF_INET, SOCK_DGRAM, 0);
err = ioctl(fd, SIOCDELTUNNEL, &ifr); err = ioctl(fd, SIOCDELTUNNEL, &ifr);
if (err) { if (err) {
bb_perror_msg("ioctl"); bb_perror_msg("ioctl");

View File

@ -59,10 +59,7 @@ void udhcp_background(const char *pidfile)
/* hold lock during fork. */ /* hold lock during fork. */
pid_fd = pidfile_acquire(pidfile); pid_fd = pidfile_acquire(pidfile);
if (daemon(0, 0) == -1) { /* bb_xdaemon? */ xdaemon(0, 0);
perror("fork");
exit(1);
}
daemonized++; daemonized++;
pidfile_write_release(pid_fd); pidfile_write_release(pid_fd);
#endif /* __uClinux__ */ #endif /* __uClinux__ */

View File

@ -288,10 +288,7 @@ fail:
// daemonize now; don't delay system startup // daemonize now; don't delay system startup
if (!foreground) { if (!foreground) {
if (daemon(0, verbose) < 0) { xdaemon(0, verbose);
why = "daemon";
goto bad;
}
syslog(LOG_INFO, "start, interface %s", intf); syslog(LOG_INFO, "start, interface %s", intf);
} }