Return unique inode numbers when calling stat/fstat on pipes and IP sockets
* fhandler.h (class fhandler_base): Convert unique_id to int64_t. (fhandler_base::set_ino): New protected inline method. (fhandler_base::get_unique_id): Convert to int64_t. (fhandler_base::set_unique_id): New inline method taking int64_t. (fhandler_pipe::fstat): Declare. (fhandler_pipe::init): Take extra parameter. (fhandler_pipe::create): Ditto. * fhandler_socket.cc (fhandler_socket::init_events): Set inode number to serial number. (fhandler_socket::fstat): Set device to DEV_TCP_MAJOR. Create st_ino from get_ino. * include/cygwin/signal.h (struct _sigcommune): Replace _si_pipe_fhandler with _si_pipe_unique_id. * pinfo.h (_pinfo::pipe_fhandler): Take unique id instead of HANDLE. * pinfo.cc (commune_process): Accommodate change to _si_pipe_unique_id. (_pinfo::commune_request): Ditto. (_pinfo::pipe_fhandler): Ditto. * pipe.cc (fhandler_pipe::init): Take unique id as argument and set inode number and unique_id from there. (fhandler_pipe::open): Rework to find any matching pipe from unique id in filename. (fhandler_pipe::get_proc_fd_name): Create filename using inode number. (fhandler_pipe::create): Generate and return unique id from process pid and pipe_unique_id. In outer method, call init with additional unique id as parameter. (fhandler_pipe::fstat): New method. (pipe_worker): Accommodate using 64 bit inode number in filename. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
@ -182,8 +182,9 @@ class fhandler_base
|
||||
size_t rabuflen;
|
||||
|
||||
/* Used for advisory file locking. See flock.cc. */
|
||||
long long unique_id;
|
||||
int64_t unique_id;
|
||||
void del_my_locks (del_lock_called_from);
|
||||
void set_ino (ino_t i) { ino = i; }
|
||||
|
||||
HANDLE read_state;
|
||||
|
||||
@ -304,7 +305,7 @@ class fhandler_base
|
||||
const char *get_win32_name () { return pc.get_win32 (); }
|
||||
virtual dev_t get_dev () { return get_device (); }
|
||||
ino_t get_ino () { return ino ?: ino = hash_path_name (0, pc.get_nt_native_path ()); }
|
||||
long long get_unique_id () const { return unique_id; }
|
||||
int64_t get_unique_id () const { return unique_id; }
|
||||
/* Returns name used for /proc/<pid>/fd in buf. */
|
||||
virtual char *get_proc_fd_name (char *buf);
|
||||
|
||||
@ -319,6 +320,7 @@ class fhandler_base
|
||||
int open_null (int flags);
|
||||
virtual int open (int, mode_t);
|
||||
virtual void open_setup (int flags);
|
||||
void set_unique_id (int64_t u) { unique_id = u; }
|
||||
void set_unique_id () { NtAllocateLocallyUniqueId ((PLUID) &unique_id); }
|
||||
|
||||
int close_with_arch ();
|
||||
@ -731,13 +733,14 @@ public:
|
||||
int open (int flags, mode_t mode = 0);
|
||||
int dup (fhandler_base *child, int);
|
||||
int ioctl (unsigned int cmd, void *);
|
||||
int __reg2 fstat (struct stat *buf);
|
||||
int __reg2 fstatvfs (struct statvfs *buf);
|
||||
int __reg3 fadvise (off_t, off_t, int);
|
||||
int __reg3 ftruncate (off_t, bool);
|
||||
int init (HANDLE, DWORD, mode_t);
|
||||
int init (HANDLE, DWORD, mode_t, int64_t);
|
||||
static int create (fhandler_pipe *[2], unsigned, int);
|
||||
static DWORD create (LPSECURITY_ATTRIBUTES, HANDLE *, HANDLE *, DWORD,
|
||||
const char *, DWORD);
|
||||
const char *, DWORD, int64_t *unique_id = NULL);
|
||||
fhandler_pipe (void *) {}
|
||||
|
||||
void copyto (fhandler_base *x)
|
||||
|
Reference in New Issue
Block a user