Commit Graph

357 Commits

Author SHA1 Message Date
Corinna Vinschen 2b31bc47a7 * fhandler_disk_file.cc (fhandler_disk_file::pread): Correctly return
with errno set to EBADF if file open mode is incorrect.
	(fhandler_disk_file::pwrite): Ditto.
2011-05-05 13:45:06 +00:00
Corinna Vinschen 392323df55 * fhandler.cc (is_at_eof): Drop static storage class. Drop err
parameter since we don't change the Win32 error here anymore.
	(fhandler_base::raw_read): Accommodate change to is_at_eof.

	* fhandler_disk_file.cc (fhandler_disk_file::pread): In binary mode use
	direct call to NtReadFile, rather than lseek/read.
	(fhandler_disk_file::pwrite): In binary mode use direct call to
	NtWriteFile, rather than lseek/write.
2011-05-05 09:05:04 +00:00
Corinna Vinschen 158e516b9d * advapi32.cc (InitializeSid): Remove.
(EqualPrefixSid): Remove.
	(GetLengthSid): Remove.
	(GetSidSubAuthority): Remove.
	(GetSidSubAuthorityCount): Remove.
	(GetSidIdentifierAuthority): Remove.
	* fhandler_disk_file.cc: Remove above functions throughout with their
	ntdll.dll equivalent.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
2011-04-28 08:34:49 +00:00
Corinna Vinschen 41e9c14558 * advapi32.cc (AllocateLocallyUniqueId): Remove.
* fhandler_disk_file.cc (fhandler_base::open_fs): Replace call to
	AllocateLocallyUniqueId with call to NtAllocateLocallyUniqueId;
	* posix_ipc.cc (mq_open): Ditto.  Drop error handling for that call.
	(sem_open): Ditto.
2011-04-28 08:15:56 +00:00
Corinna Vinschen 6ce541281e Drop NT4 support.
* autoload.cc (DnsQuery_A): Fatal if not available.
	(DnsRecordListFree): Ditto.
	(DsGetDcNameW): Ditto.
	(NetGetAnyDCName): Remove.
	(NetGetDCName): Remove.
	(EnumProcessModules): Fatal if not available.
	(GetModuleFileNameExW): Ditto.
	(GetModuleInformation): Ditto.
	(GetProcessMemoryInfo): Ditto.
	(QueryWorkingSet): Ditto.
	(LsaRegisterLogonProcess): Ditto.
	* fenv.cc (_feinitialise): Drop supports_sse condition.
	* fhandler_disk_file.cc (path_conv::isgood_inode): Fix comment.
	(fhandler_base::fstat_by_name): Drop has_fileid_dirinfo condition.
	(fhandler_disk_file::opendir): Ditto.
	* fhandler_netdrive.cc (fhandler_netdrive::readdir): Fix comment.
	* fhandler_proc.cc (format_proc_partitions): Drop NT4-only code.
	* fhandler_process.cc (get_process_state): Ditto.
	* kernel32.cc (GetWindowsDirectoryW): Remove.
	(GetWindowsDirectoryA): Remove.
	* miscfuncs.cc (nice_to_winprio): Drop NT4-only code.
	* mount.cc (fs_info::update): Fix comments.
	* net.cc (get_2k_ifs): Drop NT4-only code.
	* sec_auth.cc (get_logon_server): Ditto.
	(lsaauth): Drop NT4-specific error handling.
	* security.cc (alloc_sd): Set SE_DACL_PROTECTED unconditionally.
	* select.cc (select_stuff::wait): Always use MWMO_INPUTAVAILABLE.
	(peek_windows): Drop NT4-only condition in call to PeekMessage.
	* syscalls.cc (gethostid): Remove NT4-only workaround.
	* wincap.cc: Througout, drop has_dacl_protect,
	has_broken_if_oper_status, has_process_io_counters,
	has_terminal_services, has_extended_priority_class, has_guid_volumes,
	has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse from
	wincaps.
	(wincap_nt4sp4): Remove.
	(wincap_minimal): Set to wincap_2000.
	(wincapc::init): Rely on availability of OSVERSIONINFOEX structure.
	Treat error from GetVersionEx as fatal.  Treat NT4 as fatal.
	* wincap.h (struct wincaps): Drop has_dacl_protect,
	has_broken_if_oper_status, has_process_io_counters,
	has_terminal_services, has_extended_priority_class, has_guid_volumes,
	has_fileid_dirinfo, has_mwmo_inputavailable and supports_sse flags
	and methods.
	* winlean.h (GetWindowsDirectoryW) Define as GetSystemWindowsDirectoryW.
	(GetWindowsDirectoryA): Define as GetSystemWindowsDirectoryA.
2011-04-04 12:23:36 +00:00
Corinna Vinschen 91b3d1ed7a * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Only use
file id as inode number if it masters the isgood_inode check.
2011-03-14 09:14:17 +00:00
Corinna Vinschen 69d7815eae * fhandler.cc (fhandler_base::open): When creating a file on a
filesystem supporting ACLs, create the file with WRITE_DAC access.
	Explain why.
	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Ditto for
	directories.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto for sockets.
	* path.cc (symlink_worker): Ditto for symlinks.
	* security.cc (get_file_sd): Always call GetSecurityInfo for directories
	on XP and Server 2003.  Improve comment to explain why.
	(set_file_attribute): Explicitely cast mode_t value to bool in call to
	get_file_sd.
	* wincap.h (wincaps::use_get_sec_info_on_dirs): New element.
	* wincap.cc: Implement above element throughout.
2011-03-08 14:26:15 +00:00
Corinna Vinschen c48947b454 * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Don't
append slash if there is one already.
2011-02-15 10:47:24 +00:00
Corinna Vinschen 2908e3eb80 * fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Use POSIX
path to check for symlink.
2011-02-15 10:31:54 +00:00
Corinna Vinschen 40aca06884 * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Fix
computation of st_blocks.
	(fhandler_base::fstat_helper): Fix formatting.
2011-01-26 10:55:13 +00:00
Corinna Vinschen 49d31b4e82 Fix typo, fix copyright 2011-01-13 14:00:00 +00:00
Corinna Vinschen 07c43238cf * fhandler_disk_file.cc (fhandler_base::fstat_helper): Alwasy set
st_size of directories to 0.  Explain why.
2011-01-13 13:50:02 +00:00
Corinna Vinschen dd0821e345 * fhandler.h (fhandler_base::get_stat_access): Delete.
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Always check
	executable suffix to get x-bits for .exe files also in notexec case.
	Always reopen file when checking for file header.
	* ntdll.h (wait_pending): Delete.
	* path.cc (symlink_info::check_shortcut): Drop call to wait_pending
	since file is always opened for sync IO.
	(symlink_info::check_sysfile): Ditto.
	(MIN_STAT_ACCESS): Remove.
	(FULL_STAT_ACCESS): Remove.
	(symlink_info::check): Drop access flag.  Revert to open file with
	just read attributes access.  Reorder symlink check to check for
	reparse points first.  Don't check reparse points for anything else,
	even on remote drives.  Open file for GENERIC_READ when trying to
	read shortcuts or system-bit symlinks. Accommodate dropped access
	flag in call to path_conv_handle::set.
	* path.h (class path_conv_handle): Drop access flag and accommodate
	all related methods.
2010-10-07 14:03:26 +00:00
Corinna Vinschen 1da77c2678 * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Simplify.
Just call nfs_fetch_fattr3 if called via fstat.
	* nfs.cc (nfs_fetch_fattr3): New function to fetch NFS fattr3 info from
	file handle.
	* nfs.h (nfs_fetch_fattr3): Declare.
	* path.cc (symlink_info::check): Simplify NFS case.  Just call
	nfs_fetch_fattr3.
2010-10-02 19:03:44 +00:00
Corinna Vinschen 2d355410b7 * fhandler.cc: Drop including nfs.h.
* fhandler_disk_file.cc: Ditto.
	(fhandler_base::fstat_by_nfs_ea): Use fattr3 from path_conv member,
	unless called from fstat.
	* path.cc: Drop including nfs.h.
	(symlink_info::check): Rearrange definition of file info buffers.
	Fetch fattr3 info for files on NFS and store in conv_hdl for later
	use in fhandler_base::fstat_by_nfs_ea.  Use fattr3 file type to
	recognize symlink on NFS and try to fetch symlink target only for
	actual symlinks.
	* path.h: Include nfs.h.
	(class path_conv_handle): Change file info storage to union of
	FILE_NETWORK_OPEN_INFORMATION and fattr3 structures.
	(path_conv_handle::fnoi): Align to aforementioned change.
	(path_conv_handle::nfsattr): New method.
	(path_conv::nfsattr): New method.
2010-09-30 13:52:34 +00:00
Corinna Vinschen 7438a10a01 * fhandler.cc (fhandler_base::open): Handle query_write_dac flag.
* fhandler.h (enum query_state): Add query_write_dac flag.
	* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Open file
	with query_write_dac instead of query_write_control.
2010-09-24 16:22:53 +00:00
Corinna Vinschen 3498f76deb * errno.cc (errmap): Map ERROR_BAD_NET_RESP to ENOSYS.
* fhandler_disk_file.cc (fhandler_disk_file::facl): Handle ENOSYS and
	point to  the explanation.
	* ntdll.h (STATUS_NOT_IMPLEMENTED): Define.
	* path.cc (symlink_info::check): Handle the inability of NT4 to use
	FileNetworkOpenInformation on share root dirs in either direction.
	* path.h (slash_unc_prefix_p): Remove unused declaration.
	* security.cc (get_info_from_sd): Handle ENOSYS from get_file_sd.
	Explain when this happens.
2010-09-24 12:41:33 +00:00
Corinna Vinschen 4c9d01fdad * mount.h (class fs_info): Add has_buggy_reopen flag and accessor
methods.
	* mount.cc (fs_info::update): Set has_buggy_reopen flag for NWFS.
	Add comment.
	* path.h (path_conv::get_object_attr) Make inline method.
	(path_conv::init_reopen_attr): New inline method.
	* path.cc (path_conv::get_object_attr): Remove.
	* fhandler_disk_file.cc (fhandler_base::fstat_helper): Use
	path_conv::init_reopen_attr method to initialize OBJECT_ATTRIBUTE for
	reopening file.
	(fhandler_disk_file::fchmod): Ditto.
	(fhandler_base::utimens_fs): Ditto.
	(fhandler_disk_file::rewinddir): Ditto.
	* syscalls.cc (unlink_nt): Ditto.
2010-09-21 16:32:22 +00:00
Corinna Vinschen 7ba1698ed9 * fhandler.cc (fhandler_base::open): Always open NFS files with
FILE_READ_EA, even when opening with O_WRONLY to allow fstat.
	* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Call
	FlushFileBuffers if file has been opened for writing.  Explain why.
	(fhandler_base::fstat_by_handle): Renew content of pc.fnoi if called
	via fstat.  Explain why.  Fix formatting.
	* path.cc (symlink_info::check): Try to open file the second time with
	FILE_READ_EA permissions since it's needed in later calls to
	fhandler_base::fstat_by_nfs_ea.
2010-09-21 16:07:20 +00:00
Corinna Vinschen 421ff3ff77 * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Fetch number
of links and inode number only if path has good inodes.
	(fhandler_base::fstat_by_name): Fetch inode number only if path has
	good inodes.
2010-09-15 11:26:10 +00:00
Corinna Vinschen c80480bfa0 * fhandler.h (class fhandler_base): Change inheritance of fstat_helper
and fstat_by_...  methods to private.
	(fhandler_base::fstat_helper): Drop all redundant arguments.
	* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Drop call
	to fstat_by_nfs_ea here.  Drop fetching basic file information.
	Drop setting file attributes.  Accommodate change in fstat_helper call.
	(fhandler_base::fstat_by_name): Simplify.  Only fetch directory
	information to get the inode number.  Drop setting file attributes.
	Accommodate change in fstat_helper call.
	(fhandler_base::fstat_fs): Call fstat_by_nfs_ea if on NFS.
	(fhandler_base::fstat_helper): Drop all redundant arguments.  Use
	information already collected in the fhandler.  Move heading comment
	into code and drop dwFileAttributes comment.
	* mmap.cc (mmap64): Call fstat_fs rather than fstat_by_handle.
	* mount.cc (fs_info::update): Note that has_buggy_basic_info is unused.
	* path.cc (symlink_info::check_reparse_point): Add comment.
	(symlink_info::check): Fetch FileNetworkOpenInformation rather than
	FileBasicInformation throughout, except on NFS.  Explain why.  Store
	FILE_NETWORK_OPEN_INFORMATION in conv_hdl.  Remove
	FILE_ATTRIBUTE_DIRECTORY attribute in conv_hdl for reparse point
	symlinks.
	* path.h (class path_conv_handle): Add FILE_NETWORK_OPEN_INFORMATION
	member _fnoi.
	(path_conv_handle::fnoi): New accessor method for _fnoi.
	(path_conv::fnoi): New accessor method for cubv_hdl._fnoi.

	* fhandler_tty.cc (fhandler_tty_slave::init): Use tty::setpgid method.
2010-09-13 11:17:36 +00:00
Corinna Vinschen 99544f92a0 * fhandler_disk_file.cc (fhandler_disk_file::rmdir): More thoroughly
check the existence condition on remote drives.  Enhance comment.
2010-09-11 10:58:42 +00:00
Corinna Vinschen 43f65cdd7d * Makefile.in (DLL_OFILES): Add fhandler_procsys.o.
* devices.h (enum fh_devices): Add FH_PROCSYS.
	* devices.in (dev_procsys_storage): New device.
	* devices.cc: Regenerate.
	* dtable.cc (build_fh_pc): Add code to allocate fhandler_procsys.
	* fhandler.h (proc_len): Convert to size_t.
	(procsys): Declare.
	(procsys_len): Declare.
	(enum virtual_ftype_t): Move here from fhandler_virtual.h.
	Add members supported by fhandler_procsys.
	(fhandler_virtual::exists): Return virtual_ftype_t.  Change
	in all derived classes.
	(class fhandler_procsys): New class.
	(fhandler_union): Add fhandler_procnet and fhandler_procsys members.
	* fhandler_disk_file.cc (__DIR_mounts::check_missing_mount): Use
	ro_u_proc.
	(fhandler_base::fstat_by_handle): Don't copy attributes if file is an
	NT device.
	(fhandler_base::fstat_by_name): Ditto.
	* fhandler_netdrive.cc (fhandler_netdrive::exists): Return
	virtual_ftype_t.
	* fhandler_proc.cc (proc_tab): Sort alphabetically.  Use _VN macro
	to store length.
	(proc_len): Change to size_t.
	(proc_tab_cmp): New static function.
	(virt_tab_search): New function to search entry in virt_tab_t
	arrays.  Use throughout in /proc and sibling classes instead of
	loop.
	(fhandler_proc::exists): Return virtual_ftype_t.
	* fhandler_process.cc (process_tab): Sort alphabetically.  Use _VN
	macro to store length.
	(fhandler_process::exists): Return virtual_ftype_t.
	(fhandler_process::open): Simplify code.
	* fhandler_procnet.cc (procnet_tab): Sort alphabetically.  Use _VN
	macro to store length.
	(fhandler_procnet::exists): Return virtual_ftype_t.
	(fhandler_procnet::open): Simplify.
	* fhandler_procsys.cc: New file.
	* fhandler_registry.cc (fhandler_registry::exists): Return
	virtual_ftype_t.
	* fhandler_virtual.cc (fhandler_virtual::exists): Ditto.
	* fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h.
	(virt_tab_t): Add name_len member.
	(_VN): New macro.
	(virt_tab_search): Declare.
	* mount.cc (mount_info::conv_to_win32_path): Fix comment.  Backslashify
	isprocsys_dev paths.
	* ntdll.h (STATUS_OBJECT_TYPE_MISMATCH): Define
	(STATUS_INSTANCE_NOT_AVAILABLE): Define.
	(STATUS_PIPE_NOT_AVAILABLE): Define.
	(STATUS_INVALID_PIPE_STATE): Define.
	(STATUS_PIPE_BUSY): Define.
	(SYMBOLIC_LINK_QUERY): Define.
	(NtOpenSymbolicLinkObject): Declare.
	(NtQuerySymbolicLinkObject): Declare.
	* path.cc (path_conv::check): Accommodate fact that exists method
	returns virtual_ftype_t now.  Add cases for new virtual_ftype_t
	types.
	(cygwin_conv_path): Add GLOBALROOT prefix to native device paths.
	Make sure to strip \\?\ prefix only for actual filesystem-based
	paths, not for all paths.
	* path.h (isproc_dev): Add FH_PROCSYS.
	(isprocsys_dev): Define.
2010-09-06 09:47:01 +00:00
Corinna Vinschen a6c83569dc * fhandler_disk_file.cc (readdir_check_reparse_point): Rename from
is_volume_mountpoint.  Return valid d_type value for underlying
	reparse point type.
	(readdir_get_ino): Don't rely on the handle set in pc.check.  Open
	file here if pc.handle() is NULL.
	(fhandler_disk_file::readdir_helper): Try to set a correct d_type value
	more diligent.
	(fhandler_disk_file::readdir): Don't reset dirent_set_d_ino unless
	we're really sure it's due to an untrusted FS.  Simplify usage of
	FileAttributes, which is 0 if buf is NULL, anyway.  Set d_type
	correctly for faked "." and ".." entries.  Improve debug output.
	* path.cc (symlink_info::check): Don't keep handle to volume mount
	point open.  Explain why.
2010-08-20 11:18:58 +00:00
Corinna Vinschen dd442880af * fhandler_disk_file.cc (fhandler_disk_file::fstatvfs): Revert usage
of get_stat_handle () to get_handle ().  Add comment to explain why.
	* syscalls.cc (statvfs): Drop using PC_KEEP_HANDLE.
2010-08-20 08:52:25 +00:00
Corinna Vinschen d15ed91c04 * fhandler_disk_file.cc (fhandler_base::fstat_helper): Set st_rdev
to correct device number for fs_special devices.
2010-08-18 10:10:14 +00:00
Corinna Vinschen c492992f13 Align seekdir and telldir API to POSIX definition.
* Makefile.in (NEW_FUNCTIONS): Remove seekdir and telldir mappings.
	* dir.cc (telldir): Move functionality from telldir64 here.  Use
	long, rather than _off_t.
	(telldir64): Just call telldir.  Only keep for backward compatibility.
	(seekdir): Move functionality from seekdir64 here.  Use long, rather
	than _off_t.
	(seekdir64): Just call seekdir.  Only keep for backward compatibility.
	* fhandler.h: Throughout, change prototypes of seekdir and telldir
	methods to use long, rather than _off64_t.
	* fhandler_disk_file.cc: Change aforementioned methods accordingly.
	* fhandler_netdrive.cc: Ditto.
	* fhandler_registry.cc: Ditto.
	* fhandler_virtual.cc: Ditto.
	* include/sys/dirent.h (struct __DIR): Change __d_position from
	_off_t to long to reflect API change.
	(telldir): Change prototype to use long, rather than off_t.
	(seekdir): Ditto.
2010-07-05 16:59:56 +00:00
Corinna Vinschen 4365c1598b * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Fetch stat
handle only after checking for NFS.
2010-06-17 10:25:15 +00:00
Corinna Vinschen 342814df29 * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Use handle
returned by get_stat_handle.
	(fhandler_base::fstat_helper): Reinstatiate code to re-open the file
	when checking for executability if called via fstat.  Explain why.
2010-06-15 15:10:42 +00:00
Corinna Vinschen 5a0d1edba4 * dtable.cc (dtable::dup_worker): Reset path_conv handle in duplicated
fhandler.
	* fhandler.cc (fhandler_base::fstatvfs): Keep handle in created
	path_conv.
	* fhandler.h (fhandler_base::get_stat_access): New method.
	(fhandler_base::get_stat_handle): New method.
	* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Use handle
	returned by get_stat_handle.  Only request inode from system if it
	isn't already set in the fhandler, and only for filesystems supporting
	them.
	(fhandler_base::fstat_fs): Use handle returned by get_stat_handle.
	Change the way open_fs is called.  Explain why.
	(fhandler_base::fstat_helper): Use handle returned by get_stat_handle.
	Never use 0 inode number.  Simplify executable recognition by re-using
	get_stat_handle if file could be opened with sufficient rights.
	(fhandler_disk_file::fstatvfs): Use handle returned by get_stat_handle.
	(fhandler_disk_file::facl): Use handle returned by get_stat_handle in
	GETACL and GETACLCNT cases.
	(fhandler_disk_file::link): Use handle returned by get_stat_handle
	instead of opening file here again.  Add comment.
	(readdir_get_ino): Keep handle in created path_conv and drop
	opening file.
	* ntdll.h (wait_pending): New helper function.
	* path.cc (symlink_info::check): Drop unused 'opt' parameter from
	declaration.  Add path_conv_handle argument.
	(path_conv::check): Make sure conv_handle is closed.  Keep
	PC_KEEP_HANDLE flag in pflags_or.  Accommodate call to sym.check to
	new args.
	(path_conv::~path_conv): Close conv_handle.
	(symlink_info::check_shortcut): Don't re-open file here, just use
	incoming handle.  Drop goto's and label out.
	(symlink_info::check_sysfile): Don't re-open file here, just use
	incoming handle.  Keep track of file position to accommodate the fact
	that file has been opened asynchronously in calling function.
	(symlink_info::check_nfs_symlink): Don't re-open file here, just use
	incoming handle.
	(symlink_info::check): Drop unused 'opt' parameter.  Add
	path_conv_handle argument.  Always try to open file with GENERIC_READ
	rights first to allow reading file content w/o having to re-open the
	file.  Drop back to READ_CONTROL | FILE_READ_ATTRIBUTES otherwise.
	Call symlink test functions (except for check_reparse_point) only if
	file could be opened with GENERIC_READ.  Keep file handle open if
	PC_KEEP_HANDLE is set in pflags.
	* path.h (enum pathconv_arg): Add PC_KEEP_HANDLE flag.
	(class path_conv_handle): New class.
	(class path_conv): Add conv_handle member.
	(path_conv::operator =): Duplicate conv_handle.
	(path_conv::handle): New method.
	(path_conv::access): New method.
	(path_conv::reset_conv_handle): New method.
	(path_conv::close_conv_handle): New method.
2010-06-15 12:05:15 +00:00
Corinna Vinschen 51ec3f5c98 * fhandler_disk_file.cc (fhandler_disk_file::fstatvfs): Fix indentation. 2010-06-15 09:58:56 +00:00
Corinna Vinschen 5e3dd23eee * fhandler_disk_file.cc (path_conv::get_ino_by_handle): Convert from
static function to path_conv method.  Accommodate throughout.
	(path_conv::ndisk_links): Unused, comment out.
	* path.h (path_conv::get_ino_by_handle): Declare.
	(path_conv::ndisk_links): Comment out declaration.
2010-06-15 08:51:55 +00:00
Corinna Vinschen 0f6de51ae2 * fhandler_disk_file.cc (fhandler_cygdrive::fstat): Add standard read
permissions again.
2010-03-19 10:59:49 +00:00
Corinna Vinschen 1929fc8ece * fhandler_disk_file.cc (fhandler_disk_file::opendir): Try to open
directory with stat()-friendly access mask first.  Explain why.
2010-02-19 13:28:49 +00:00
Corinna Vinschen eb67604071 * fhandler_disk_file.cc (fhandler_base::fstat_helper): Set st_rdev
to same value as st_dev.  Avoid useless debug output in executable
	check.  Add filename to debug output.
	(fhandler_disk_file::facl): Simplify code calling fstat methods to
	just call fstat to avoid errors with the cygdrive directory.
2010-02-19 12:37:37 +00:00
Corinna Vinschen 4a49c71595 * fhandler_disk_file.cc (fhandler_base::fstat_helper): Workaround
another bug in NWFS.  Add comment to explain why.  Improve debug output
	in case the NT calls to test for binary fail.
	* path.h (path_conv::fs_is_cifs): New method.
	(path_conv::fs_is_nwfs): New method.
2010-02-03 16:05:33 +00:00
Corinna Vinschen 3432d6f1f7 Throughout, use FileBothDirectoryInformation info class rather than
FileDirectoryInformation info class to avoid problems with incomplete
	filesystem implementations.  Fix comments accordingly.
	* fhandler_disk_file.cc (fhandler_disk_file::readdir_helper): Set
	fname->Length to 0 in error case to avoid potential crash in debug
	output.
	(fhandler_disk_file::readdir): Try to speed up the working default case.
	Check for STATUS_INVALID_NETWORK_RESPONSE as potential status value
	returned by filesystems not implementing FileIdBothDirectoryInformation.
	* ntdll.h (STATUS_INVALID_NETWORK_RESPONSE): Define.
	(FILE_BOTH_DIRECTORY_INFORMATION): Rename to official name.
	* path.cc (symlink_info::check): Don't request FILE_READ_EA access, it's
	not required for NFS.  Try to speed up the working default case.  Check
	for STATUS_INVALID_NETWORK_RESPONSE as potential status value returned
	by filesystems not supporting non-NULL EA parameters.  Fix the way
	fs.update is called.  Improve debug output.
2010-01-29 11:20:06 +00:00
Corinna Vinschen c04ed45d82 * globals.cc (ro_u_nwfs): New R/O unicode string.
* mount.cc (fs_info::update): Check for NWFS filesystem.  Set
	has_buggy_basic_info, if so.  Add comment to explain why.
	(fillout_mntent): Add "nwfs" string to fs_names array.
	* mount.h (enum fs_info_type): Add nwfs.
	(class fs_info): Add has_buggy_basic_info status flag.  Add accessors
	for has_buggy_basic_info and is_nwfs.
	* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Accommodate
	filesystems with broken FileBasicInformation handling.
	* path.cc (symlink_info::check): Ditto.
	* path.h (path_conv::has_buggy_basic_info): Add method.
2010-01-12 14:47:46 +00:00
Corinna Vinschen f1817d368a * fhandler.h (fhandler_base::fstat_helper): Declare timestamps as
PLARGE_INTEGER.
	* fhandler_disk_file.cc (fhandler_base::fstat_by_handle):
	Accommodate fstat_helper change of timestamp arguments.
	(fhandler_base::fstat_by_name): Ditto.
	(fhandler_base::fstat_helper): Define with timestamps as PLARGE_INTEGER.
	Accommodate in call to to_timestruc_t.
2010-01-10 11:12:52 +00:00
Corinna Vinschen 667d9ad130 * fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix typos in
comments.  Always open file synchronized when reading header bytes,
	otherwise suffer stack corruption.
2009-11-27 14:27:22 +00:00
Corinna Vinschen 3aec0f00b1 * fhandler_disk_file.cc (is_volume_mountpoint): Align check with
symlink_info::check_reparse_point().
	* path.cc (symlink_info::check_reparse_point): Rearrange slightly.
	Add code path for unrecognized repare point types.  Add comment.
2009-11-10 08:54:24 +00:00
Corinna Vinschen aa9681ec35 * fhandler_disk_file.cc (fhandler_base::fstat_helper): Drop all "other"
permissions from st_mode, if the reading the file's security descriptor
	failed.  Explain why.
2009-11-08 10:22:28 +00:00
Corinna Vinschen b42441d32b * sec_helper.cc (security_descriptor::free): If sd_size is 0, call
LocalFree instead of ::free.

	* sec_acl.cc: Throughout replace old ACE flag definitions with current
	definitions as used in MSDN man pages.
	* security.cc: Ditto.

	* fhandler.cc (fhandler_base::open): Make sure file has really been
	just created before fixing file permissions.  Add S_JUSTCREATED
	attribute to set_file_attribute call.
	* fhandler_disk_file.cc (fhandler_disk_file::mkdir): Always create dir
	with default security descriptor and fix descriptor afterwards.
	Add S_JUSTCREATED flag to set_file_attribute call.
	* fhandler_socket.cc (fhandler_socket::bind): Ditto for AF_LOCAL
	socket files.
	* path.cc (symlink_worker): Ditto for symlinks.
	* security.cc (get_file_sd): Call GetSecurityInfo rather than
	NtQuerySecurityObject.  Explain why.  Change error handling accordingly.
	(alloc_sd): Skip non-inherited, non-standard entries in ACL if
	S_JUSTCREATED attribute is set.  Explain why.  Minor format fixes.
	* security.h (S_JUSTCREATED): New define.
	(security_descriptor::operator=): New operator.
2009-10-30 19:58:53 +00:00
Corinna Vinschen 460af5f9c0 * smallprint.cc (hex_str): New const string.
(__rn): Drop str and use hex_str instead.
	(__small_vsprintf): If 'l' modifier has been found, print subsequent
	multibyte or wide char string using the s, S, or W options in extended
	hex value layout.

	* fhandler_disk_file.cc (fhandler_disk_file::readdir): Print WCHAR
	and resulting multibyte filename in extended hex value layout in
	debug output.
2009-10-30 09:02:30 +00:00
Corinna Vinschen cbea3f7d93 * fhandler_disk_file.cc (fhander_disk_file::readdir): Handle a status
code STATUS_NOT_SUPPORTED.  Add matching comment.
2009-10-20 10:12:05 +00:00
Eric Blake b8a35083c6 Improve clock_gettime and utimensat resolution.
* hires.h (hires_ms): Change initime_us to initime_ns, with 10x
more resolution.
(hires_ms::nsecs): New prototype.
(hires_ms::usecs, hires_ms::msecs, hires_ms::uptime): Adjust.
* times.cc (systime_ns): New helper function.
(hires_ms::prime): Use it for more resolution.
(hires_ms::usecs): Change to...
(hires_ms::nsecs): ...with more resolution.
(clock_gettime): Use more resolution.
(systime): Rewrite in terms of systime_ns.
(timespec_to_filetime): Rewrite math to reflect true operation.
* fhandler_disk_file.cc (utimens_fs): Use higher resolution.
2009-10-13 02:26:33 +00:00
Corinna Vinschen d358c9e9b0 * fhandler_disk_file.cc (fhandler_disk_file::link): Only append .lnk
if the original device had one, too.  Add comment.

	* fhandler_socket.cc (fhandler_socket::fstat): Always return a size of
	0 on sockets.
2009-10-12 11:57:29 +00:00
Eric Blake 80636211bc * fhandler_disk_file.cc (utimens_fs): Plug fd leak on EINVAL. 2009-10-08 11:13:45 +00:00
Eric Blake 52dba6a5c4 Fix some POSIX-compliance bugs in link, rename, mkdir.
* syscalls.cc (link): Delete obsolete comment.  Reject directories
and missing source up front.
(rename): Use correct errno for trailing '.'.  Detect empty
strings.  Allow trailing slash to newpath iff oldpath is
directory.
* dir.cc (mkdir): Reject dangling symlink with trailing slash.
* fhandler_disk_file.cc (fhandler_disk_file::link): Reject
trailing slash.
* fhandler.cc (fhandler_base::link): Match Linux errno.
2009-09-26 15:51:53 +00:00
Corinna Vinschen 6cabe044dd * fhandler_disk_file.cc (fhandler_disk_file::link): Drop faking hardlink
creation on filesystems not supporting hardlinks.
2009-09-21 10:56:50 +00:00