static const char *file_type(const struct stat *st) { /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 * for some of these formats. * To keep diagnostics grammatical in English, the * returned string must start with a consonant. */ if (S_ISREG(st->st_mode)) return st->st_size == 0 ? "regular empty file" : "regular file"; if (S_ISDIR(st->st_mode)) return "directory"; if (S_ISBLK(st->st_mode)) return "block special file"; if (S_ISCHR(st->st_mode)) return "character special file"; if (S_ISFIFO(st->st_mode)) return "fifo"; if (S_ISLNK(st->st_mode)) return "symbolic link"; if (S_ISSOCK(st->st_mode)) return "socket"; #ifdef S_TYPEISMQ if (S_TYPEISMQ(st)) return "message queue"; #endif #ifdef S_TYPEISSEM if (S_TYPEISSEM(st)) return "semaphore"; #endif #ifdef S_TYPEISSHM if (S_TYPEISSHM(st)) return "shared memory object"; #endif #ifdef S_TYPEISTMO if (S_TYPEISTMO(st)) return "typed memory object"; #endif return "weird file"; }
void filemodestring (struct stat const *statp, char *str) { strmode (statp->st_mode, str); if (S_TYPEISSEM (statp)) str[0] = 'F'; else if (S_TYPEISMQ (statp)) str[0] = 'Q'; else if (S_TYPEISSHM (statp)) str[0] = 'S'; }
int mq_close(mqd_t mq) { struct stat st; if(fstat(mq, &st) != 0) { return -1; } if(!S_TYPEISMQ(&st)) { errno = EBADF; return -1; } return close(mq); }
char const * file_type (struct stat const *stat) { /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of these formats. To keep diagnostics grammatical in English, the returned string must start with a consonant. */ /* Do these three first, as they're the most common. */ if (S_ISREG (stat->st_mode)) return stat->st_size == 0 ? "regular empty file" : "regular file"; if (S_ISDIR (stat->st_mode)) return "directory"; if (S_ISLNK (stat->st_mode)) return "symbolic link"; /* Do the S_TYPEIS* macros next, as they may be implemented in terms of S_ISNAM, and we want the more-specialized interpretation. */ if (S_TYPEISMQ (stat)) return "message queue"; if (S_TYPEISSEM (stat)) return "semaphore"; if (S_TYPEISSHM (stat)) return "shared memory object"; /* The remaining are in alphabetical order. */ if (S_ISBLK (stat->st_mode)) return "block special file"; if (S_ISCHR (stat->st_mode)) return "character special file"; if (S_ISFIFO (stat->st_mode)) return "fifo"; if (S_ISSOCK (stat->st_mode)) return "socket"; return "weird file"; }
void filemodestring (struct stat const *statp, char *str) { strmode (statp->st_mode, str); if (S_TYPEISSEM (statp)) str[0] = 'F'; else if (IS_MIGRATED_FILE (statp)) str[0] = 'M'; else if (S_TYPEISMQ (statp)) str[0] = 'Q'; else if (S_TYPEISSHM (statp)) str[0] = 'S'; else if (S_TYPEISTMO (statp)) str[0] = 'T'; }
char const * file_type (struct stat const *st) { /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of these formats. To keep diagnostics grammatical in English, the returned string must start with a consonant. */ if (S_ISREG (st->st_mode)) return st->st_size == 0 ? _("regular empty file") : _("regular file"); if (S_ISDIR (st->st_mode)) return _("directory"); if (S_ISBLK (st->st_mode)) return _("block special file"); if (S_ISCHR (st->st_mode)) return _("character special file"); if (S_ISFIFO (st->st_mode)) return _("fifo"); if (S_ISLNK (st->st_mode)) return _("symbolic link"); if (S_ISSOCK (st->st_mode)) return _("socket"); if (S_TYPEISMQ (st)) return _("message queue"); if (S_TYPEISSEM (st)) return _("semaphore"); if (S_TYPEISSHM (st)) return _("shared memory object"); if (S_TYPEISTMO (st)) return _("typed memory object"); return _("weird file"); }
void writeFileStatus(TAThread thread, struct stat* buffer) { writeULLong(thread, buffer->st_dev); writeULong(thread, buffer->st_ino); //Encoding st_mode if(S_ISBLK(buffer->st_mode)) writeInt(thread, 1); else if(S_ISCHR(buffer->st_mode)) writeInt(thread, 2); else if(S_ISFIFO(buffer->st_mode)) writeInt(thread, 3); else if(S_ISREG(buffer->st_mode)) writeInt(thread, 4); else if(S_ISDIR(buffer->st_mode)) writeInt(thread, 5); else if(S_ISLNK(buffer->st_mode)) writeInt(thread, 6); else if(S_ISSOCK(buffer->st_mode)) writeInt(thread, 7); else if(S_TYPEISMQ(buffer)) writeInt(thread, 8); else if(S_TYPEISSEM(buffer)) writeInt(thread, 9); else if(S_TYPEISSHM(buffer)) writeInt(thread, 10); #ifdef S_TYPEISTMO else if(S_TYPEISTMO(buffer)) writeInt(thread, 11); #endif else writeInt(thread, 0); //Encoding S_IRWXU if(buffer->st_mode & S_IRUSR) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IWUSR) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IXUSR) writeInt(thread, 1); else writeInt(thread, 0); //Encoding S_IRWXG if(buffer->st_mode & S_IRGRP) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IWGRP) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IXGRP) writeInt(thread, 1); else writeInt(thread, 0); //Encoding S_IRWXO if(buffer->st_mode & S_IROTH) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IWOTH) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_IXOTH) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_ISUID) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_ISGID) writeInt(thread, 1); else writeInt(thread, 0); if(buffer->st_mode & S_ISVTX) writeInt(thread, 1); else writeInt(thread, 0); //End of encoding st_mode writeULong(thread, buffer->st_nlink); writeUInt(thread, buffer->st_uid); writeUInt(thread, buffer->st_gid); writeULLong(thread, buffer->st_rdev); writeLLong(thread, buffer->st_size); writeLong(thread, buffer->st_atime); writeLong(thread, buffer->st_mtime); writeLong(thread, buffer->st_ctime); writeLLong(thread, buffer->st_blksize); writeLLong(thread, buffer->st_blocks); }
char const * file_type (struct stat const *st) { /* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107 for some of these formats. To keep diagnostics grammatical in English, the returned string must start with a consonant. */ /* Do these three first, as they're the most common. */ if (S_ISREG (st->st_mode)) return st->st_size == 0 ? _("regular empty file") : _("regular file"); if (S_ISDIR (st->st_mode)) return _("directory"); if (S_ISLNK (st->st_mode)) return _("symbolic link"); /* Do the S_TYPEIS* macros next, as they may be implemented in terms of S_ISNAM, and we want the more-specialized interpretation. */ if (S_TYPEISMQ (st)) return _("message queue"); if (S_TYPEISSEM (st)) return _("semaphore"); if (S_TYPEISSHM (st)) return _("shared memory object"); if (S_TYPEISTMO (st)) return _("typed memory object"); /* The remaining are in alphabetical order. */ if (S_ISBLK (st->st_mode)) return _("block special file"); if (S_ISCHR (st->st_mode)) return _("character special file"); if (S_ISCTG (st->st_mode)) return _("contiguous data"); if (S_ISFIFO (st->st_mode)) return _("fifo"); if (S_ISDOOR (st->st_mode)) return _("door"); if (S_ISMPB (st->st_mode)) return _("multiplexed block special file"); if (S_ISMPC (st->st_mode)) return _("multiplexed character special file"); if (S_ISMPX (st->st_mode)) return _("multiplexed file"); if (S_ISNAM (st->st_mode)) return _("named file"); if (S_ISNWK (st->st_mode)) return _("network special file"); if (S_ISOFD (st->st_mode)) return _("migrated file with data"); if (S_ISOFL (st->st_mode)) return _("migrated file without data"); if (S_ISPORT (st->st_mode)) return _("port"); if (S_ISSOCK (st->st_mode)) return _("socket"); if (S_ISWHT (st->st_mode)) return _("whiteout"); return _("weird file"); }