udev_utils_run.c revision 1aa1e24848903d11780db1ade355be73ad61a937
/*
* udev_utils_run.c - execute programs from udev and read its output
*
* Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include "udev.h"
{
int sock;
struct sockaddr_un saddr;
char buf[2048];
int i;
int retval = 0;
/* only abstract namespace is supported */
bufpos++;
bufpos++;
}
if (count < 0)
retval = -1;
return retval;
}
{
int retval = 0;
int status;
int devnull;
int i;
i = 0;
if (pos[0] == '\'') {
/* don't separate if in apostrophes */
pos++;
pos++;
} else {
}
i++;
}
} else {
}
/* prepare pipes from child to parent */
return -1;
}
}
if (log) {
return -1;
}
}
}
switch(pid) {
case 0:
/* child closes parent ends of pipes */
/* discard child output or connect to pipe */
if (devnull > 0) {
} else
/* we should never reach this */
_exit(1);
case -1:
return -1;
default:
/* read from child if requested */
/* parent closes child ends of pipes */
/* read child output */
int fdcount;
if (fdcount < 0) {
continue;
retval = -1;
break;
}
/* get stdout */
char inbuf[1024];
char *pos;
char *line;
if (count <= 0) {
if (count < 0) {
retval = -1;
}
continue;
}
/* store result for rule processing */
if (result) {
} else {
retval = -1;
}
}
}
/* get stderr */
char errbuf[1024];
char *pos;
char *line;
if (count <= 0) {
if (count < 0)
continue;
}
}
}
/* return the childs stdout string */
if (result) {
if (reslen)
}
}
if (WEXITSTATUS(status) != 0)
retval = -1;
} else {
retval = -1;
}
}
return retval;
}