1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#ifndef POTD_UTILS_H #define POTD_UTILS_H 1 #ifndef SIZEOF #define SIZEOF(arr) (sizeof(arr)/sizeof(arr[0])) #endif extern char *arg0; int set_fd_nonblock(int fd); int set_child_sighandler(void); void set_procname(const char *new_arg0); pid_t daemonize(int stay_foreground); int close_fds_except(int fd, ...); int redirect_devnull_to(int fds, ...); int change_user_group(const char *user, const char *group); int safe_chroot(const char *newroot); int dir_is_mountpoint(const char *path); void chk_chroot(void); void mount_root(void); int mount_dev(const char *mount_path); int mount_pts(const char *mount_path); int mount_proc(const char *mount_path); int create_device_file_checked(const char *mount_path, const char *device_file, mode_t mode, int add_mode, dev_t dev); int create_device_files(const char *mount_path); #endif