namedev_parse.c revision 3db7fa27027110fde92a1b6061fab434fe708e9f
/*
*
* Userspace devfs
*
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
*
*
* 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.
*
*/
#ifdef DEBUG
/* define this to enable parsing debugging also */
/* #define DEBUG_PARSER */
#endif
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include "udev.h"
#include "udev_lib.h"
#include "logging.h"
#include "namedev.h"
{
struct config_device *tmp_dev;
return -ENOMEM;
//dump_config_dev(tmp_dev);
return 0;
}
{
dbg_parse("name='%s', symlink='%s', bus='%s', place='%s', id='%s', "
"sysfs_file[0]='%s', sysfs_value[0]='%s', "
"kernel='%s', program='%s', result='%s'"
"owner='%s', group='%s', mode=%#o",
}
void dump_config_dev_list(void)
{
struct config_device *dev;
}
{
struct perm_device *dev;
struct perm_device *tmp_dev;
/* update the values if we already have the device */
continue;
return 0;
}
/* not found, add new structure to the perm list */
if (!tmp_dev)
return -ENOMEM;
//dump_perm_dev(tmp_dev);
return 0;
}
{
dbg_parse("name='%s', owner='%s', group='%s', mode=%#o",
}
void dump_perm_dev_list(void)
{
struct perm_device *dev;
}
/* extract possible KEY{attr} or KEY_attr */
static char *get_key_attribute(char *str)
{
char *pos;
char *attr;
attr++;
dbg("missing closing brace for format");
return NULL;
}
pos[0] = '\0';
return attr;
}
attr++;
return attr;
}
return NULL;
}
static int namedev_parse_rules(char *filename)
{
char *bufline;
int lineno;
char *temp;
char *temp2;
char *temp3;
char *attr;
char *buf;
int program_given = 0;
int valid;
int retval = 0;
struct config_device dev;
} else {
return -1;
}
/* loop through the whole file */
cur = 0;
lineno = 0;
lineno++;
info("line too long, rule skipped %s, line %d",
continue;
}
/* eat the whitespace */
bufline++;
count--;
}
if (count == 0)
continue;
/* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER)
continue;
/* get all known keys */
valid = 0;
while (1) {
if (retval)
break;
valid = 1;
continue;
}
valid = 1;
continue;
}
valid = 1;
continue;
}
int sysfs_pair_num = 0;
/* find first unused pair */
if (sysfs_pair_num >= MAX_SYSFS_PAIRS) {
break;
}
++pair;
}
if (pair) {
continue;
}
valid = 1;
}
continue;
}
valid = 1;
continue;
}
program_given = 1;
valid = 1;
continue;
}
valid = 1;
continue;
}
dbg_parse("creation of partition nodes requested");
}
valid = 1;
continue;
}
valid = 1;
continue;
}
valid = 1;
continue;
}
valid = 1;
continue;
}
valid = 1;
continue;
}
goto error;
}
/* skip line if not any valid key was found */
if (!valid)
goto error;
/* simple plausibility checks for given keys */
goto error;
}
FIELD_PROGRAM " is called in any rule before");
goto error;
}
if (retval) {
continue;
info("parse error %s, line %d:%d, rule skipped",
}
}
return retval;
}
static int namedev_parse_permissions(char *filename)
{
char *bufline;
char *temp;
char *temp2;
char *buf;
int retval = 0;
struct perm_device dev;
int lineno;
} else {
return -1;
}
/* loop through the whole file */
cur = 0;
lineno = 0;
lineno++;
info("line too long, rule skipped %s, line %d",
continue;
}
/* eat the whitespace */
bufline++;
count--;
}
if (count == 0)
continue;
/* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER)
continue;
/* parse the line */
if (!temp2) {
continue;
}
if (!temp2) {
continue;
}
if (!temp2) {
continue;
}
if (!temp) {
continue;
}
dbg_parse("name='%s', owner='%s', group='%s', mode=%#o",
if (retval) {
goto exit;
}
}
exit:
return retval;
}
int namedev_init_rules()
{
return namedev_parse_rules(udev_rules_filename);
else
return call_foreach_file(namedev_parse_rules,
}
int namedev_init_permissions()
{
else
}