chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] correct apply_format() for symlink only rules
[elogind.git]
/
udev_config.c
diff --git
a/udev_config.c
b/udev_config.c
index 6714c1b73d50857a72e38870b466e047db554e29..57a512d711464f1dd32ef52ecfa005cb283d3a23 100644
(file)
--- a/
udev_config.c
+++ b/
udev_config.c
@@
-32,11
+32,12
@@
#include <errno.h>
#include <ctype.h>
#include <errno.h>
#include <ctype.h>
+#include "libsysfs/sysfs/libsysfs.h"
#include "udev.h"
#include "udev.h"
+#include "udev_lib.h"
#include "udev_version.h"
#include "logging.h"
#include "namedev.h"
#include "udev_version.h"
#include "logging.h"
#include "namedev.h"
-#include "libsysfs/libsysfs.h"
/* global variables */
char sysfs_path[SYSFS_PATH_MAX];
/* global variables */
char sysfs_path[SYSFS_PATH_MAX];
@@
-81,7
+82,7
@@
static void init_variables(void)
#define set_var(_name, _var) \
if (strcasecmp(variable, _name) == 0) { \
dbg_parse("%s = '%s'", _name, value); \
#define set_var(_name, _var) \
if (strcasecmp(variable, _name) == 0) { \
dbg_parse("%s = '%s'", _name, value); \
- str
ncpy(_var, value, sizeof(_var));
\
+ str
fieldcpymax(_var, value, sizeof(_var));
\
}
#define set_bool(_name, _var) \
}
#define set_bool(_name, _var) \
@@
-131,12
+132,14
@@
static int parse_config_file(void)
char *temp;
char *variable;
char *value;
char *temp;
char *variable;
char *value;
- FILE *fd;
- int lineno = 0;
+ char *buf;
+ size_t bufsize;
+ size_t cur;
+ size_t count;
+ int lineno;
int retval = 0;
int retval = 0;
-
- fd = fopen(udev_config_filename, "r");
- if (fd != NULL) {
+
+ if (file_map(udev_config_filename, &buf, &bufsize) == 0) {
dbg("reading '%s' as config file", udev_config_filename);
} else {
dbg("can't open '%s' as config file", udev_config_filename);
dbg("reading '%s' as config file", udev_config_filename);
} else {
dbg("can't open '%s' as config file", udev_config_filename);
@@
-144,13
+147,20
@@
static int parse_config_file(void)
}
/* loop through the whole file */
}
/* loop through the whole file */
+ lineno = 0;
+ cur = 0;
while (1) {
while (1) {
- /* get a line */
- temp = fgets(line, sizeof(line), fd);
- if (temp == NULL)
- goto exit;
+ count = buf_get_line(buf, bufsize, cur);
+
+ strncpy(line, buf + cur, count);
+ line[count] = '\0';
+ temp = line;
lineno++;
lineno++;
+ cur += count+1;
+ if (cur > bufsize)
+ break;
+
dbg_parse("read '%s'", temp);
/* eat the whitespace at the beginning of the line */
dbg_parse("read '%s'", temp);
/* eat the whitespace at the beginning of the line */
@@
-182,8
+192,8
@@
static int parse_config_file(void)
}
dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
lineno, temp - line, temp);
}
dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
lineno, temp - line, temp);
-exit:
- f
close(fd
);
+
+ f
ile_unmap(buf, bufsize
);
return retval;
}
return retval;
}