Mirror of git://git.busybox.net/busybox with our patches on top
Source
/* vi: set sw=4 ts=4: */
/*
* mode_string implementation for busybox
*
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* Aug 13, 2003
* Fix a bug reported by junkio@cox.net involving the mode_chars index.
*/
static const mode_t mode_flags[] = {
S_IRUSR, S_IWUSR, S_IXUSR, S_ISUID,
S_IRGRP, S_IWGRP, S_IXGRP, S_ISGID,
S_IROTH, S_IWOTH, S_IXOTH, S_ISVTX
};
/* The static const char arrays below are duplicated for the two cases
* because moving them ahead of the mode_flags declaration cause a text
* size increase with the gcc version I'm using. */
/* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C',
* and 'B' types don't appear to be available on linux. So I removed them. */
static const char type_chars[16] = "?pc?d?b?-?l?s???";
/* 0123456789abcdef */
static const char mode_chars[7] = "rwxSTst";
const char *bb_mode_string(int mode)
{
static char buf[12];
char *p = buf;
int i, j, k;
*p = type_chars[ (mode >> 12) & 0xf ];
i = 0;
do {