/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos72L src/bos/kernel/sys/fdinfo.h 1.17.1.18 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2006,2018 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ /* @(#)80 1.17.1.18 src/bos/kernel/sys/fdinfo.h, syslfs, bos72L, l2018_09C5 2/27/18 12:11:12 */ #ifndef _H_FDINFO #define _H_FDINFO /* * COMPONENT_NAME: SYSLFS - Logical File System * * FUNCTIONS: fdinfo * * ORIGINS: 27 */ #ifdef __cplusplus extern "C" { #endif #include #include #include /* fdinfo commands */ #define FDINFO_GET_USAGE 0 #define FDINFO_GET_PATH 1 #define FDINFO_GET_FLOCKS 2 #define FDINFO_SET_FLOCKS 3 #define FDINFO_GET_QUEUED_AIO 4 #define FDINFO_PUT_QUEUED_AIO 5 #define FDINFO_GET_PENDING_IO 6 #define FDINFO_PUT_PENDING_IO 7 #define FDINFO_SOCKSTATE_GET 8 #define FDINFO_SOCKSTATE_PUT 9 #define FDINFO_STREAMSTATE_GET 10 #define FDINFO_STREAMSTATE_PUT 11 #define FDINFO_SOCK_DELETE 12 #define FDINFO_USOCK_CONNECT 13 #define FDINFO_USOCK_INFLT_GET 14 #define FDINFO_USOCK_INFLT_PUT 15 #define FDINFO_CHK_CHROOTED 16 #define FDINFO_GET_NONCHROOT_PATH 17 #define FDINFO_UNCHROOT 18 #define FDINFO_GET_RTSHM_IDX 19 #define FDINFO_GET_IOCPFDS 20 /* List IOCP fds */ #define FDINFO_GET_IOCPPKTS 21 /* Get I/O comp pkts */ #define FDINFO_PUT_IOCPPKTS 22 /* Put I/O comp pkts */ /* FDINFO_UNLINKED_GETINFO 23 DEPRECATED */ /* FDINFO_UNLINKED_REOPEN 24 DEPRECATED */ #define FDINFO_GETINFO 25 /* info on open files */ #define FDINFO_REOPEN 26 /* reopen an open file */ #define FDINFO_TRACESTATE_PUT 27 /* Trace Restore command */ #define FDINFO_TRACESTATE_GET 28 /* Trace Checkpoint command */ #define FDINFO_GETCWD 29 /* Get fid of cwd vnode */ #define FDINFO_SETCWD 30 /* Get vnode from fid of cwd */ #define FDINFO_BPF_GET 31 #define FDINFO_BPF_PUT 32 #define FDINFO_GET_FLOCKS_ALL 33 /* get all flocks regardless of PID */ #define FDINFO_GET_FLOCKS_WAITERS 34 /* get the flocks waiting */ #define FDINFO_CHECK_REMOTE 35 /* Check if the fd is remote */ /* file descriptor types */ enum fdtype { FDTYPE_UNKNOWN = -1, /* unknown */ FDTYPE_REG = 1, /* regular file */ FDTYPE_DIR, /* directory */ FDTYPE_CHR, /* character device */ FDTYPE_BLK, /* block device */ FDTYPE_FIFO, /* pipe (named/unnamed) */ FDTYPE_RTSHM, /* POSIX shared memory */ FDTYPE_ISOCK_DGRAM, /* inet dgram socket */ FDTYPE_ISOCK_STREAM, /* inet stream socket */ FDTYPE_USOCK_DGRAM, /* unix dgram socket */ FDTYPE_USOCK_STREAM, /* unix stream socket */ FDTYPE_I6SOCK_DGRAM, /* inet6 dgram socket */ FDTYPE_I6SOCK_STREAM, /* inet6 stream socket */ FDTYPE_ISOCK_RAW, /* inet raw socket */ FDTYPE_I6SOCK_RAW, /* inet6 raw socket */ FDTYPE_ROUTE_RAW, /* routing raw socket */ FDTYPE_IOCPCP, /* IOCP ControlPort */ FDTYPE_SMSOCK, /* Shared Memory Socket */ }; typedef enum fdtype fdtype_t; /* current version of fdinfo structure */ #define FDINFO_VERSION 1 /* structure to capture file descriptor information */ struct fdinfo { int fd_version; /* version of fdinfo struct */ int fd; /* file descriptor */ fdtype_t fd_type; /* file descriptor type */ int fd_fcount; /* number of file descriptors */ /* sharing the file structure */ int64 fd_flags; /* file descriptor flags */ offset_t fd_offset; /* 64-bit file offset */ uint64_t fd_unique; /* file descriptor uniquifier */ /* duped descriptors have the */ /* same uniquifier */ }; typedef struct fdinfo fdinfo_t; /* structure for handling fdinfo i/o. this allows fdinfo to perform i/o * into a buffer or to redirect i/o to a file. the buffer is used only * if fd_io is not a valid descriptor. */ struct fdinfo_io { int fd; /* file descriptor being examined */ int fd_io; /* file descriptor for redirecting i/o */ void * fd_iobuf; /* i/o buffer */ size_t fd_iosize; /* amount of i/o to be performed */ }; typedef struct fdinfo_io fdinfo_io_t; typedef struct net_fdinfo { int fd; /* file descriptor to ckpt/restart */ int fdout; /* file descriptor */ caddr_t msgout; /* msg to add to ckpt data */ int msglen; /* msg length */ caddr_t buf; /* output buffer */ size_t bufsize; /* buffer size provided/required */ int protocol; /* protocol */ } net_fdinfo_t, *net_fdinfop_t, **net_fdinfopp_t; typedef struct inflt_file { long long fkey; /* file key to identify the file */ int fd; /* file descriptor */ int pad; /* padding for alignment */ } inflt_file_t; typedef struct rtshm_fdinfo { int fd; /* file descriptor */ fdtype_t fd_type; /* file descriptor type */ int fd_rtipcx; /* rtshm index if fd_type == DTYPE_RTSHM */ } rtshm_fdinfo_t; /* File descriptor to key mapping */ typedef struct fdinfo_fd2key { int fd2key_nbr; /* Number of entries */ struct fd2key_map { long long fkey; /* key to identify the file */ int fd; /* File descriptor */ } fd2key_list[0]; } fdinfo_fd2key_t; typedef struct fdinfo_io_iocp { int fd_iocp; /* file descriptor (HANDLE) for IOCP Completion port */ fdinfo_fd2key_t *fd_fd2key; /* mappings from fd to fkey, used with FDINFO_PUT_IOCPPKTS only*/ void *fd_iobuf; /* i/o buffer */ size_t fd_iosize; /* Size of fd_iobuf */ } fdinfo_io_iocp_t; typedef struct fdinfo_iocp { int fd; /* file descriptor */ uint fd_iocp_flags; /* iocp related flags */ #define FDINFO_IOCP_CLOSEFD 1 /* fd opened by fdinfo and should be closed after c/r */ long long fkey; /* file key to identify file */ uint64_t fd_iocp_key; /* CompletionKey value */ uint64_t fd_iocp_cthrds; /* ConcurrentThreads value */ } fdinfo_iocp_t; /**************************************************************************** * REOPEN by handle * ****************************************************************************/ /* fd_flags definition */ #define FDINFO_UNLINKED 0x0001 /* unlinked */ #define FDINFO_NONAME 0x0002 /* object has no name in parent */ #define FDINFO_ROVFS 0x0004 /* VFS is read-only */ /* Macros to find pointer to and length of variable length opaque data given * a pointer to fdinfo_reopen structure and index to object. */ #define FDINFO_DATA_FIDOBJ 0 /* fid of object */ #define FDINFO_DATA_FIDDIR 1 /* fid of parent directory */ #define FDINFO_DATA_MNTSTB 2 /* pathname of mount stub */ #define FDINFO_DATA_MNTOBJ 3 /* pathname of mount object */ #define FDINFO_DATA_OBJECTS 4 /* total number of opaque objects */ #define FDD2DATAPTR(_fdr, _idx) ((caddr_t)(((long)(_fdr)) + \ ((_fdr)->fd_data[(_idx)].fdd_off))) #define FDD2DATALEN(_fdr, _idx) ((_fdr)->fd_data[(_idx)].fdd_len) #define FDINFO_REOPEN_SIZEHINT 4096 /* Compare opaque data: Returns TRUE if equal, FALSE if not. This macro must * not call any C library function directly. */ #define FDDCOMPARE(_f1, _f2) (((_f1)->fd_datalen != (_f2)->fd_datalen) \ ? FALSE \ : !memcmp(FDD2DATAPTR((_f1),0), \ FDD2DATAPTR((_f2),0), \ (_f1)->fd_datalen)) typedef struct fd_data { short fdd_off; /* offset double-word aligned data */ short fdd_len; /* actual data length */ } fd_data_t; typedef struct fdinfo_reopen { #define FDINFO_REOPEN_VERSION 3 ushort_t fd_version; /* version of fdinfo_reopen */ ushort_t fd_flags; /* fdinfo_reopen flags */ short fd_len; /* total length of struct */ short fd_datalen; /* opaque data length */ short fd_pfstype; /* underlying file system type */ short fd_pfskcid; /* underlying vfs kcid */ short fd_vfskcid; /* mounted vfs kcid */ short fd_reserved1; int fd_reserved2; int fd_fd; /* active file descriptor */ int64_t fd_oflags; /* file open flags */ offset_t fd_size; /* size of the file */ fd_data_t fd_data[FDINFO_DATA_OBJECTS]; /* opaque reopen data */ /* * Actual variable length opaque data goes here, double-word aligned. */ } fdinfo_reopen_t; /* For chdir by handle */ #define FDINFO_CDIR_SIZE_HINT 4096 /* Max pathname of Mount Object + * Max pathname of Mount Stub + * sizeof(fd_data_t)*4 + * Max fidsz of object + * Pathname of current directory + * padding */ typedef struct fdinfo_cdir { short fd_vfskcid; int fd_unlinked; fd_data_t fd_data[FDINFO_DATA_OBJECTS]; /* opaque data begins here */ } fdinfo_cdir_t; /* no fid will be larger than this */ #define FDINFO_MAXFIDSZ 64 typedef struct fdinfo_fid_max { uint_t fid_len; char fid_data[FDINFO_MAXFIDSZ]; } fdinfo_fidmax_t; typedef struct fdinfo_vn_fid { int64 flag; caddr_t parentp; fdinfo_fidmax_t fid; } fdinfo_vn_fid_t; #ifdef _KERNEL int fdinfo_getinfo_vp(fdinfo_reopen_t *fdrop, vnode_t *vp, caddr_t parentp, long oflags, cred_t *crp); int fdinfo_getinfo_size(vnode_t *vp); #endif /****************************************************************************/ #ifdef _KERNEL /* Infrastructure for supporting 32-bit applications */ typedef struct net_fdinfo32 { int fd; /* file descriptor to ckpt/restart */ int fdout; /* file descriptor */ ptr32 msgout; /* msg to add to ckpt data */ int msglen; /* msg length */ ptr32 buf; /* output buffer */ uint bufsize; /* buffer size provided/required */ int protocol; /* protocol */ } net_fdinfo32_t, *net_fdinfo32p_t, **net_fdinfo32pp_t; #ifdef _KERNSYS typedef struct fdinfo_io32 { int fd; /* file descriptor to ckpt/restart */ int fd_io; /* i/o output file */ ptr32 fd_iobuf; /* i/o buffer */ uint fd_iosize; /* Size of fd_iobuf */ } fdinfo_io32_t; typedef struct fdinfo_io_iocp32 { int fd_iocp; /* file descriptor (HANDLE) for IOCP Completion port */ ptr32 fd_fd2key; /* mappings from fd to fkey, used with FDINFO_PUT_IOCPPKTS only*/ ptr32 fd_iobuf; /* i/o buffer */ uint fd_iosize; /* Size of fd_iobuf */ } fdinfo_io_iocp32_t; #endif /* _KERNSYS */ #endif /* _KERNEL */ #ifdef _NO_PROTO extern int fdinfo(); #else extern int fdinfo(pid_t pid, int cmd, void *arg); #endif #ifdef __cplusplus } #endif #endif /* _H_FDINFO */