Merge pull request #27041 from poettering/fdstore-dump
add ability to show contents of service fdstore + teach systemd-notify passing fds into the fdstore
This commit is contained in:
@@ -83,7 +83,7 @@ int device_path_make_canonical(mode_t mode, dev_t devnum, char **ret) {
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (major(devnum) == 0 && minor(devnum) == 0)
|
||||
if (devnum_is_zero(devnum))
|
||||
/* A special hack to make sure our 'inaccessible' device nodes work. They won't have symlinks in
|
||||
* /dev/block/ and /dev/char/, hence we handle them specially here. */
|
||||
return device_path_make_inaccessible(mode, ret);
|
||||
|
||||
@@ -50,3 +50,7 @@ static inline char *format_devnum(dev_t d, char buf[static DEVNUM_STR_MAX]) {
|
||||
}
|
||||
|
||||
#define FORMAT_DEVNUM(d) format_devnum((d), (char[DEVNUM_STR_MAX]) {})
|
||||
|
||||
static inline bool devnum_is_zero(dev_t d) {
|
||||
return major(d) == 0 && minor(d) == 0;
|
||||
}
|
||||
|
||||
@@ -940,3 +940,16 @@ int dir_fd_is_root(int dir_fd) {
|
||||
*/
|
||||
return statx_inode_same(&st.sx, &pst.sx) && statx_mount_same(&st.nsx, &pst.nsx);
|
||||
}
|
||||
|
||||
const char *accmode_to_string(int flags) {
|
||||
switch (flags & O_ACCMODE) {
|
||||
case O_RDONLY:
|
||||
return "ro";
|
||||
case O_WRONLY:
|
||||
return "wo";
|
||||
case O_RDWR:
|
||||
return "rw";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,3 +115,5 @@ static inline char *format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int f
|
||||
|
||||
#define FORMAT_PROC_FD_PATH(fd) \
|
||||
format_proc_fd_path((char[PROC_FD_PATH_MAX]) {}, (fd))
|
||||
|
||||
const char *accmode_to_string(int flags);
|
||||
|
||||
@@ -58,3 +58,12 @@
|
||||
#ifndef O_TMPFILE
|
||||
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
|
||||
#endif
|
||||
|
||||
/* So O_LARGEFILE is generally implied by glibc, and defined to zero hence, because we only build in LFS
|
||||
* mode. However, when invoking fcntl(F_GETFL) the flag is ORed into the result anyway — glibc does not mask
|
||||
* it away. Which sucks. Let's define the actual value here, so that we can mask it ourselves. */
|
||||
#if O_LARGEFILE != 0
|
||||
#define RAW_O_LARGEFILE O_LARGEFILE
|
||||
#else
|
||||
#define RAW_O_LARGEFILE 0100000
|
||||
#endif
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -979,7 +979,7 @@ int get_ctty_devnr(pid_t pid, dev_t *d) {
|
||||
&ttynr) != 1)
|
||||
return -EIO;
|
||||
|
||||
if (major(ttynr) == 0 && minor(ttynr) == 0)
|
||||
if (devnum_is_zero(ttynr))
|
||||
return -ENXIO;
|
||||
|
||||
if (d)
|
||||
|
||||
Reference in New Issue
Block a user