Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 532514 | Differences between
and this patch

Collapse All | Expand All

(-)a/support/include/nfslib.h (-7 lines)
Lines 152-162 struct nfs_fh_len * getfh(const struct sockaddr_in *sin, const char *path); Link Here
152
struct nfs_fh_len *	getfh_size(const struct sockaddr_in *sin,
152
struct nfs_fh_len *	getfh_size(const struct sockaddr_in *sin,
153
					const char *path, int const size);
153
					const char *path, int const size);
154
154
155
void qword_print(FILE *f, char *str);
156
void qword_printhex(FILE *f, char *str, int slen);
157
void qword_printint(FILE *f, int num);
158
int qword_eol(FILE *f);
159
int readline(int fd, char **buf, int *lenp);
160
int qword_get(char **bpp, char *dest, int bufsize);
155
int qword_get(char **bpp, char *dest, int bufsize);
161
int qword_get_int(char **bpp, int *anint);
156
int qword_get_int(char **bpp, int *anint);
162
void cache_flush(int force);
157
void cache_flush(int force);
Lines 167-174 void qword_addint(char **bpp, int *lp, int n); Link Here
167
void qword_adduint(char **bpp, int *lp, unsigned int n);
162
void qword_adduint(char **bpp, int *lp, unsigned int n);
168
void qword_addeol(char **bpp, int *lp);
163
void qword_addeol(char **bpp, int *lp);
169
int qword_get_uint(char **bpp, unsigned int *anint);
164
int qword_get_uint(char **bpp, unsigned int *anint);
170
void qword_printuint(FILE *f, unsigned int num);
171
void qword_printtimefrom(FILE *f, unsigned int num);
172
165
173
void closeall(int min);
166
void closeall(int min);
174
167
(-)a/support/nfs/cacheio.c (-111 lines)
Lines 121-194 void qword_addeol(char **bpp, int *lp) Link Here
121
	(*lp)--;
121
	(*lp)--;
122
}
122
}
123
123
124
static char qword_buf[8192];
125
void qword_print(FILE *f, char *str)
126
{
127
	char *bp = qword_buf;
128
	int len = sizeof(qword_buf);
129
	qword_add(&bp, &len, str);
130
	if (fwrite(qword_buf, bp-qword_buf, 1, f) != 1) {
131
		xlog_warn("qword_print: fwrite failed: errno %d (%s)",
132
			errno, strerror(errno));
133
	}
134
}
135
136
void qword_printhex(FILE *f, char *str, int slen)
137
{
138
	char *bp = qword_buf;
139
	int len = sizeof(qword_buf);
140
	qword_addhex(&bp, &len, str, slen);
141
	if (fwrite(qword_buf, bp-qword_buf, 1, f) != 1) {
142
		xlog_warn("qword_printhex: fwrite failed: errno %d (%s)",
143
			errno, strerror(errno));
144
	}
145
}
146
147
void qword_printint(FILE *f, int num)
148
{
149
	fprintf(f, "%d ", num);
150
}
151
152
void qword_printuint(FILE *f, unsigned int num)
153
{
154
	fprintf(f, "%u ", num);
155
}
156
157
void qword_printtimefrom(FILE *f, unsigned int num)
158
{
159
	fprintf(f, "%lu ", time(0) + num);
160
}
161
162
int qword_eol(FILE *f)
163
{
164
	int err;
165
166
	err = fprintf(f,"\n");
167
	if (err < 0) {
168
		xlog_warn("qword_eol: fprintf failed: errno %d (%s)",
169
			    errno, strerror(errno));
170
	} else {
171
		err = fflush(f);
172
		if (err) {
173
			xlog_warn("qword_eol: fflush failed: errno %d (%s)",
174
				  errno, strerror(errno));
175
		}
176
	}
177
	/*
178
	 * We must send one line (and one line only) in a single write
179
	 * call.  In case of a write error, libc may accumulate the
180
	 * unwritten data and try to write it again later, resulting in a
181
	 * multi-line write.  So we must explicitly ask it to throw away
182
	 * any such cached data.  But we return any original error
183
	 * indication to the caller.
184
	 */
185
	__fpurge(f);
186
	fflush(f);
187
	return err;
188
}
189
190
191
192
#define isodigit(c) (isdigit(c) && c <= '7')
124
#define isodigit(c) (isdigit(c) && c <= '7')
193
int qword_get(char **bpp, char *dest, int bufsize)
125
int qword_get(char **bpp, char *dest, int bufsize)
194
{
126
{
Lines 266-313 int qword_get_uint(char **bpp, unsigned int *anint) Link Here
266
	return 0;
198
	return 0;
267
}
199
}
268
200
269
#define READLINE_BUFFER_INCREMENT 2048
270
271
int readline(int fd, char **buf, int *lenp)
272
{
273
	/* read a line into *buf, which is malloced *len long
274
	 * realloc if needed until we find a \n
275
	 * nul out the \n and return
276
	 * 0 on eof, 1 on success
277
	 */
278
	int len;
279
280
	if (*lenp == 0) {
281
		char *b = malloc(READLINE_BUFFER_INCREMENT);
282
		if (b == NULL)
283
			return 0;
284
		*buf = b;
285
		*lenp = READLINE_BUFFER_INCREMENT;
286
	}
287
	len = read(fd, *buf, *lenp);
288
	if (len <= 0)
289
		return 0;
290
	while ((*buf)[len-1] != '\n') {
291
	/* now the less common case.  There was no newline,
292
	 * so we have to keep reading after re-alloc
293
	 */
294
		char *new;
295
		int nl;
296
		*lenp += READLINE_BUFFER_INCREMENT;
297
		new = realloc(*buf, *lenp);
298
		if (new == NULL)
299
			return 0;
300
		*buf = new;
301
		nl = read(fd, *buf + len, *lenp - len);
302
		if (nl <= 0)
303
			return 0;
304
		len += nl;
305
	}
306
	(*buf)[len-1] = '\0';
307
	return 1;
308
}
309
310
311
/* Check if we should use the new caching interface
201
/* Check if we should use the new caching interface
312
 * This succeeds iff the "nfsd" filesystem is mounted on
202
 * This succeeds iff the "nfsd" filesystem is mounted on
313
 * /proc/fs/nfs
203
 * /proc/fs/nfs
314
- 

Return to bug 532514