mirror of
https://github.com/systemd/systemd.git
synced 2024-10-29 21:55:36 +03:00
stat-util: add inode_type_to_string() helper for showing mode_t inode type as string
This commit is contained in:
parent
8732cfb4bf
commit
d83ce13636
@ -471,3 +471,26 @@ int inode_compare_func(const struct stat *a, const struct stat *b) {
|
||||
}
|
||||
|
||||
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(inode_hash_ops, struct stat, inode_hash_func, inode_compare_func, free);
|
||||
|
||||
const char* inode_type_to_string(mode_t m) {
|
||||
|
||||
/* Returns a short string for the inode type. We use the same name as the underlying macros for each
|
||||
* inode type. */
|
||||
|
||||
switch (m & S_IFMT) {
|
||||
case S_IFREG:
|
||||
return "reg";
|
||||
case S_IFDIR:
|
||||
return "dir";
|
||||
case S_IFCHR:
|
||||
return "chr";
|
||||
case S_IFBLK:
|
||||
return "blk";
|
||||
case S_IFIFO:
|
||||
return "fifo";
|
||||
case S_IFSOCK:
|
||||
return "sock";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -101,3 +101,5 @@ int statx_fallback(int dfd, const char *path, int flags, unsigned mask, struct s
|
||||
void inode_hash_func(const struct stat *q, struct siphash *state);
|
||||
int inode_compare_func(const struct stat *a, const struct stat *b);
|
||||
extern const struct hash_ops inode_hash_ops;
|
||||
|
||||
const char* inode_type_to_string(mode_t m);
|
||||
|
Loading…
Reference in New Issue
Block a user