libudev-util-private.c revision 6133f3432fe86bc140cc9ba74794826f75c915fa
/*
* libudev - interface to udev device information
*
* Copyright (C) 2004-2009 Kay Sievers <kay.sievers@vrfy.org>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <pwd.h>
#include <grp.h>
#include "libudev.h"
#include "libudev-private.h"
{
char p[UTIL_PATH_SIZE];
char *pos;
int ret;
util_strscpy(p, sizeof(p), path);
return 0;
pos--;
pos[0] = '\0';
return 0;
if (util_create_path(udev, p) != 0)
return -1;
if (ret == 0)
return 0;
return 0;
return -1;
}
{
char p[UTIL_PATH_SIZE];
char *pos;
int retval;
return 0;
while (1) {
*pos = '\0';
/* don't remove the last one */
break;
/* remove if empty */
retval = 0;
if (retval) {
return 0;
break;
}
}
return 0;
}
/* Reset permissions on the device node, before unlinking it to make sure,
* that permisions of possible hard links will be removed too.
*/
{
int retval;
if (retval)
if (retval)
retval = 0;
if (retval)
return retval;
}
{
char *endptr;
return 0;
if (endptr[0] == '\0')
return uid;
errno = 0;
else
return 0;
}
{
char *endptr;
return 0;
if (endptr[0] == '\0')
return gid;
errno = 0;
else
return 0;
}
/* handle "[<SUBSYSTEM>/<KERNEL>]<attribute>" format */
{
char temp[UTIL_PATH_SIZE];
char *subsys;
char *sysname;
struct udev_device *dev;
char *attr;
if (string[0] != '[')
return -1;
return -1;
sysname[0] = '\0';
return -1;
attr[0] = '\0';
if (attr[0] == '/')
if (attr[0] == '\0')
return -1;
return -1;
if (read_value) {
const char *val;
else
result[0] = '\0';
} else {
size_t l;
char *s;
s = result;
}
return 0;
}
{
int status;
char arg[UTIL_PATH_SIZE];
char program[UTIL_PATH_SIZE];
int devnull;
int i;
int err = 0;
/* build argv from command */
i = 0;
if (pos[0] == '\'') {
/* do not separate quotes */
pos++;
pos++;
} else {
}
i++;
}
} else {
}
/* prepare pipes from child to parent */
return -1;
}
}
return -1;
}
}
if (argv[0][0] != '/') {
}
switch(pid) {
case 0:
/* child closes parent ends of pipes */
/* discard child output or connect to pipe */
if (devnull > 0) {
} else
}
}
/* may be on a filesytem which is not mounted right now */
} else {
/* other problems */
}
_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;
err = -1;
break;
}
/* get stdout */
char inbuf[1024];
char *pos;
char *line;
if (count <= 0) {
if (count < 0) {
err = -1;
}
continue;
}
/* store result for rule processing */
if (result) {
} else {
err = -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)
err = -1;
} else {
err = -1;
}
}
return err;
}