projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add support for powerpc/powerpc64 unaligned relocations
[musl]
/
src
/
misc
/
mntent.c
diff --git
a/src/misc/mntent.c
b/src/misc/mntent.c
index
3eafba5
..
eabb820
100644
(file)
--- a/
src/misc/mntent.c
+++ b/
src/misc/mntent.c
@@
-3,6
+3,11
@@
#include <mntent.h>
#include <errno.h>
#include <mntent.h>
#include <errno.h>
+static char *internal_buf;
+static size_t internal_bufsize;
+
+#define SENTINEL (char *)&internal_buf
+
FILE *setmntent(const char *name, const char *mode)
{
return fopen(name, mode);
FILE *setmntent(const char *name, const char *mode)
{
return fopen(name, mode);
@@
-10,19
+15,24
@@
FILE *setmntent(const char *name, const char *mode)
int endmntent(FILE *f)
{
int endmntent(FILE *f)
{
- fclose(f);
+
if (f)
fclose(f);
return 1;
}
struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen)
{
return 1;
}
struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen)
{
- int cnt, n[8];
+ int cnt, n[8]
, use_internal = (linebuf == SENTINEL)
;
mnt->mnt_freq = 0;
mnt->mnt_passno = 0;
do {
mnt->mnt_freq = 0;
mnt->mnt_passno = 0;
do {
- fgets(linebuf, buflen, f);
+ if (use_internal) {
+ getline(&internal_buf, &internal_bufsize, f);
+ linebuf = internal_buf;
+ } else {
+ fgets(linebuf, buflen, f);
+ }
if (feof(f) || ferror(f)) return 0;
if (!strchr(linebuf, '\n')) {
fscanf(f, "%*[^\n]%*[\n]");
if (feof(f) || ferror(f)) return 0;
if (!strchr(linebuf, '\n')) {
fscanf(f, "%*[^\n]%*[\n]");
@@
-49,9
+59,8
@@
struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int bufle
struct mntent *getmntent(FILE *f)
{
struct mntent *getmntent(FILE *f)
{
- static char linebuf[256];
static struct mntent mnt;
static struct mntent mnt;
- return getmntent_r(f, &mnt,
linebuf, sizeof linebuf
);
+ return getmntent_r(f, &mnt,
SENTINEL, 0
);
}
int addmntent(FILE *f, const struct mntent *mnt)
}
int addmntent(FILE *f, const struct mntent *mnt)