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

Collapse All | Expand All

(-)a/include/strutils.h (-2 lines)
Lines 28-35 static inline void xstrncpy(char *dest, const char *src, size_t n) Link Here
28
	dest[n-1] = 0;
28
	dest[n-1] = 0;
29
}
29
}
30
30
31
extern void strmode(mode_t mode, char *str);
32
33
/* Options for size_to_human_string() */
31
/* Options for size_to_human_string() */
34
enum
32
enum
35
{
33
{
(-)a/lib/strutils.c (-39 lines)
Lines 265-309 err: Link Here
265
}
265
}
266
266
267
/*
267
/*
268
 * Converts stat->st_mode to ls(1)-like mode string. The size of "str" must
269
 * be 10 bytes.
270
 */
271
void strmode(mode_t mode, char *str)
272
{
273
	if (S_ISDIR(mode))
274
		str[0] = 'd';
275
	else if (S_ISLNK(mode))
276
		str[0] = 'l';
277
	else if (S_ISCHR(mode))
278
		str[0] = 'c';
279
	else if (S_ISBLK(mode))
280
		str[0] = 'b';
281
	else if (S_ISSOCK(mode))
282
		str[0] = 's';
283
	else if (S_ISFIFO(mode))
284
		str[0] = 'p';
285
	else if (S_ISREG(mode))
286
		str[0] = '-';
287
288
	str[1] = mode & S_IRUSR ? 'r' : '-';
289
	str[2] = mode & S_IWUSR ? 'w' : '-';
290
	str[3] = (mode & S_ISUID
291
		? (mode & S_IXUSR ? 's' : 'S')
292
		: (mode & S_IXUSR ? 'x' : '-'));
293
	str[4] = mode & S_IRGRP ? 'r' : '-';
294
	str[5] = mode & S_IWGRP ? 'w' : '-';
295
	str[6] = (mode & S_ISGID
296
		? (mode & S_IXGRP ? 's' : 'S')
297
		: (mode & S_IXGRP ? 'x' : '-'));
298
	str[7] = mode & S_IROTH ? 'r' : '-';
299
	str[8] = mode & S_IWOTH ? 'w' : '-';
300
	str[9] = (mode & S_ISVTX
301
		? (mode & S_IXOTH ? 't' : 'T')
302
		: (mode & S_IXOTH ? 'x' : '-'));
303
	str[10] = '\0';
304
}
305
306
/*
307
 * returns exponent (2^x=n) in range KiB..PiB
268
 * returns exponent (2^x=n) in range KiB..PiB
308
 */
269
 */
309
static int get_exp(uint64_t n)
270
static int get_exp(uint64_t n)

Return to bug 412201