14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*8462SApril.Chin@Sun.COM * Copyright (c) 1985-2008 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 7*8462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * Glenn Fowler 254887Schin * AT&T Bell Laboratories 264887Schin * 274887Schin * return strperm() expression for perm 284887Schin */ 294887Schin 304887Schin #include <ast.h> 314887Schin #include <ls.h> 324887Schin 334887Schin char* 344887Schin fmtperm(register int perm) 354887Schin { 364887Schin register char* s; 374887Schin char* buf; 384887Schin 394887Schin s = buf = fmtbuf(32); 404887Schin 414887Schin /* 424887Schin * u 434887Schin */ 444887Schin 454887Schin *s++ = 'u'; 464887Schin *s++ = '='; 474887Schin if (perm & S_ISVTX) 484887Schin *s++ = 't'; 494887Schin if (perm & S_ISUID) 504887Schin *s++ = 's'; 514887Schin if (perm & S_IRUSR) 524887Schin *s++ = 'r'; 534887Schin if (perm & S_IWUSR) 544887Schin *s++ = 'w'; 554887Schin if (perm & S_IXUSR) 564887Schin *s++ = 'x'; 574887Schin if ((perm & (S_ISGID|S_IXGRP)) == S_ISGID) 584887Schin *s++ = 'l'; 594887Schin 604887Schin /* 614887Schin * g 624887Schin */ 634887Schin 644887Schin *s++ = ','; 654887Schin *s++ = 'g'; 664887Schin *s++ = '='; 674887Schin if ((perm & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) 684887Schin *s++ = 's'; 694887Schin if (perm & S_IRGRP) 704887Schin *s++ = 'r'; 714887Schin if (perm & S_IWGRP) 724887Schin *s++ = 'w'; 734887Schin if (perm & S_IXGRP) 744887Schin *s++ = 'x'; 754887Schin 764887Schin /* 774887Schin * o 784887Schin */ 794887Schin 804887Schin *s++ = ','; 814887Schin *s++ = 'o'; 824887Schin *s++ = '='; 834887Schin if (perm & S_IROTH) 844887Schin *s++ = 'r'; 854887Schin if (perm & S_IWOTH) 864887Schin *s++ = 'w'; 874887Schin if (perm & S_IXOTH) 884887Schin *s++ = 'x'; 894887Schin *s = 0; 904887Schin return buf; 914887Schin } 92