* devices.in (dev_storage): Map /dev/zero and /dev/full to \Device\Null.

* devices.cc: Regenerate.
	* dtable.h (struct dtable): Make fhandler_base friend, rather
	than fhandler_disk_file.
	* fhandler.cc (fhandler_base::open_with_arch): Create unique id.
	(fhandler_base::cleanup): Call del_my_locks.
	(fhandler_base::fcntl): Handle F_GETLK, F_SETLK and F_SETLKW.
	* fhandler.h (fhandler_base::get_dev): Return real device number.
	(fhandler_base::set_unique_id): New inline method.
	(fhandler_disk_file::lock): Drop declaration.
	(fhandler_disk_file::get_dev): New method, return pc.fs_serial_number.
	(fhandler_dev_zero::open): Drop declaration.
	* fhandler_disk_file.cc (fhandler_disk_file::close): Move
	del_my_locks call to fhandler_base::open_with_arch.
	(fhandler_disk_file::fcntl): Move handling of locking commands to
	fhandler_base::fcntl.
	(fhandler_base::open_fs): Drop call to NtAllocateLocallyUniqueId.
	* fhandler_zero.cc (fhandler_dev_zero::open): Remove so that default
	fhandler_base::open is used to open \Device\Null.
	* flock.cc (fixup_lockf_after_exec): Finding a single fhandler is
	enough here.
	(fhandler_base::lock): Replace fhandler_disk_file::lock.  Refuse to lock
	nohandle devices.  Handle read/write test using POSIX flags.  Explain
	why.  Never fail on SEEK_CUR or SEEK_END, rather assume position 0,
	just as Linux.
	* net.cc (fdsock): Create unique id.
This commit is contained in:
Corinna Vinschen
2013-10-24 09:41:17 +00:00
parent 72a386373e
commit 95ff6fc6da
11 changed files with 109 additions and 64 deletions

View File

@ -296,7 +296,7 @@ class fhandler_base
bool has_attribute (DWORD x) const {return pc.has_attribute (x);}
const char *get_name () const { return pc.normalized_path; }
const char *get_win32_name () { return pc.get_win32 (); }
dev_t get_dev () { return pc.fs_serial_number (); }
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; }
/* Returns name used for /proc/<pid>/fd in buf. */
@ -312,6 +312,7 @@ class fhandler_base
int open_with_arch (int, mode_t = 0);
virtual int open (int, mode_t);
virtual void open_setup (int flags) { return; }
void set_unique_id () { NtAllocateLocallyUniqueId ((PLUID) &unique_id); }
int close_with_arch ();
virtual int close ();
@ -979,7 +980,6 @@ class fhandler_disk_file: public fhandler_base
int fcntl (int cmd, intptr_t);
int dup (fhandler_base *child, int);
void fixup_after_fork (HANDLE parent);
int lock (int, struct flock *);
int mand_lock (int, struct flock *);
bool isdevice () const { return false; }
int __reg2 fstat (struct stat *buf);
@ -1012,6 +1012,7 @@ class fhandler_disk_file: public fhandler_base
ssize_t __reg3 pwrite (void *, size_t, off_t);
fhandler_disk_file (void *) {}
dev_t get_dev () { return pc.fs_serial_number (); }
void copyto (fhandler_base *x)
{
@ -1618,7 +1619,6 @@ class fhandler_dev_zero: public fhandler_base
{
public:
fhandler_dev_zero ();
int open (int flags, mode_t mode = 0);
ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len);
off_t lseek (off_t offset, int whence);