/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Bell Laboratories25*26* return strperm() expression for perm27*/2829#include <ast.h>30#include <ls.h>3132char*33fmtperm(register int perm)34{35register char* s;36char* buf;3738s = buf = fmtbuf(32);3940/*41* u42*/4344*s++ = 'u';45*s++ = '=';46if (perm & S_ISVTX)47*s++ = 't';48if (perm & S_ISUID)49*s++ = 's';50if (perm & S_IRUSR)51*s++ = 'r';52if (perm & S_IWUSR)53*s++ = 'w';54if (perm & S_IXUSR)55*s++ = 'x';56if ((perm & (S_ISGID|S_IXGRP)) == S_ISGID)57*s++ = 'l';5859/*60* g61*/6263*s++ = ',';64*s++ = 'g';65*s++ = '=';66if ((perm & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP))67*s++ = 's';68if (perm & S_IRGRP)69*s++ = 'r';70if (perm & S_IWGRP)71*s++ = 'w';72if (perm & S_IXGRP)73*s++ = 'x';7475/*76* o77*/7879*s++ = ',';80*s++ = 'o';81*s++ = '=';82if (perm & S_IROTH)83*s++ = 'r';84if (perm & S_IWOTH)85*s++ = 'w';86if (perm & S_IXOTH)87*s++ = 'x';88*s = 0;89return buf;90}919293