mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-02 13:05:42 +08:00
* fhandler.h (fhandler_base::pc): Make public.
* fhandler_disk_file.cc (fhandler_disk_file::link): Drop extern declaration of stat_suffixes. Use NT native path in debug output. (fhandler_base::utimes_fs): Simplify closeit case. Use close_fs to close newly opened file handle. (fhandler_base::open_fs): Use NT native path in debug output. * path.cc: Throughout drop extern declaration of stat_suffixes. * path.h (stat_suffixes): Declare. * sec_acl.cc (acl_worker): Drop extern declaration of stat_suffixes. * times.cc (utimes_worker): Take path_conv as parameter instead of single-byte pathnam, drop nofollow argument, accommodate throughout. Compare UNICODE paths when enumerating file descriptors. Fix formatting. Use NT native path in debug output.
This commit is contained in:
parent
7d2ade3341
commit
4a971ce403
@ -1,3 +1,19 @@
|
|||||||
|
2007-08-14 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler.h (fhandler_base::pc): Make public.
|
||||||
|
* fhandler_disk_file.cc (fhandler_disk_file::link): Drop extern
|
||||||
|
declaration of stat_suffixes. Use NT native path in debug output.
|
||||||
|
(fhandler_base::utimes_fs): Simplify closeit case. Use close_fs
|
||||||
|
to close newly opened file handle.
|
||||||
|
(fhandler_base::open_fs): Use NT native path in debug output.
|
||||||
|
* path.cc: Throughout drop extern declaration of stat_suffixes.
|
||||||
|
* path.h (stat_suffixes): Declare.
|
||||||
|
* sec_acl.cc (acl_worker): Drop extern declaration of stat_suffixes.
|
||||||
|
* times.cc (utimes_worker): Take path_conv as parameter instead of
|
||||||
|
single-byte pathnam, drop nofollow argument, accommodate throughout.
|
||||||
|
Compare UNICODE paths when enumerating file descriptors. Fix
|
||||||
|
formatting. Use NT native path in debug output.
|
||||||
|
|
||||||
2007-08-13 Corinna Vinschen <corinna@vinschen.de>
|
2007-08-13 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* mmap.cc: Call NtClose instead of CloseHandle throughout.
|
* mmap.cc: Call NtClose instead of CloseHandle throughout.
|
||||||
|
@ -138,7 +138,6 @@ class fhandler_base
|
|||||||
|
|
||||||
DWORD fs_flags;
|
DWORD fs_flags;
|
||||||
HANDLE read_state;
|
HANDLE read_state;
|
||||||
path_conv pc;
|
|
||||||
int wait_overlapped (bool&, bool, DWORD *) __attribute__ ((regparm (3)));
|
int wait_overlapped (bool&, bool, DWORD *) __attribute__ ((regparm (3)));
|
||||||
bool setup_overlapped () __attribute__ ((regparm (1)));
|
bool setup_overlapped () __attribute__ ((regparm (1)));
|
||||||
void destroy_overlapped () __attribute__ ((regparm (1)));
|
void destroy_overlapped () __attribute__ ((regparm (1)));
|
||||||
@ -147,6 +146,8 @@ class fhandler_base
|
|||||||
class fhandler_base *archetype;
|
class fhandler_base *archetype;
|
||||||
int usecount;
|
int usecount;
|
||||||
|
|
||||||
|
path_conv pc;
|
||||||
|
|
||||||
virtual void set_name (path_conv &pc);
|
virtual void set_name (path_conv &pc);
|
||||||
int error () const {return pc.error;}
|
int error () const {return pc.error;}
|
||||||
void set_error (int error) {pc.error = error;}
|
void set_error (int error) {pc.error = error;}
|
||||||
@ -250,7 +251,7 @@ class fhandler_base
|
|||||||
bool has_attribute (DWORD x) const {return pc.has_attribute (x);}
|
bool has_attribute (DWORD x) const {return pc.has_attribute (x);}
|
||||||
const char *get_name () const { return pc.normalized_path; }
|
const char *get_name () const { return pc.normalized_path; }
|
||||||
const char *get_win32_name () { return pc.get_win32 (); }
|
const char *get_win32_name () { return pc.get_win32 (); }
|
||||||
__ino64_t get_namehash () { return namehash ?: namehash = hash_path_name (0, get_win32_name ()); }
|
__ino64_t get_namehash () { return namehash ?: namehash = hash_path_name (0, get_win32_name ()); }
|
||||||
/* Returns name used for /proc/<pid>/fd in buf. */
|
/* Returns name used for /proc/<pid>/fd in buf. */
|
||||||
virtual char *get_proc_fd_name (char *buf);
|
virtual char *get_proc_fd_name (char *buf);
|
||||||
|
|
||||||
|
@ -1050,7 +1050,6 @@ int
|
|||||||
fhandler_disk_file::link (const char *newpath)
|
fhandler_disk_file::link (const char *newpath)
|
||||||
{
|
{
|
||||||
extern bool allow_winsymlinks;
|
extern bool allow_winsymlinks;
|
||||||
extern suffix_info stat_suffixes[];
|
|
||||||
|
|
||||||
path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX,
|
path_conv newpc (newpath, PC_SYM_NOFOLLOW | PC_POSIX,
|
||||||
transparent_exe ? stat_suffixes : NULL);
|
transparent_exe ? stat_suffixes : NULL);
|
||||||
@ -1062,7 +1061,7 @@ fhandler_disk_file::link (const char *newpath)
|
|||||||
|
|
||||||
if (newpc.exists ())
|
if (newpc.exists ())
|
||||||
{
|
{
|
||||||
syscall_printf ("file '%s' exists?", newpc.get_win32 ());
|
syscall_printf ("file '%S' exists?", newpc.get_nt_native_path ());
|
||||||
set_errno (EEXIST);
|
set_errno (EEXIST);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1195,17 +1194,15 @@ fhandler_base::utimes_fs (const struct timeval *tvp)
|
|||||||
fbi.FileAttributes = 0;
|
fbi.FileAttributes = 0;
|
||||||
NTSTATUS status = NtSetInformationFile (get_handle (), &io, &fbi, sizeof fbi,
|
NTSTATUS status = NtSetInformationFile (get_handle (), &io, &fbi, sizeof fbi,
|
||||||
FileBasicInformation);
|
FileBasicInformation);
|
||||||
|
if (closeit)
|
||||||
|
close_fs ();
|
||||||
/* Opening a directory on a 9x share from a NT machine works(!), but
|
/* Opening a directory on a 9x share from a NT machine works(!), but
|
||||||
then NtSetInformationFile fails with STATUS_NOT_SUPPORTED. Oh well... */
|
then NtSetInformationFile fails with STATUS_NOT_SUPPORTED. Oh well... */
|
||||||
if (!NT_SUCCESS (status) && status != STATUS_NOT_SUPPORTED)
|
if (!NT_SUCCESS (status) && status != STATUS_NOT_SUPPORTED)
|
||||||
{
|
{
|
||||||
if (closeit)
|
|
||||||
close ();
|
|
||||||
__seterrno_from_nt_status (status);
|
__seterrno_from_nt_status (status);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (closeit)
|
|
||||||
close ();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,8 +1262,8 @@ fhandler_base::open_fs (int flags, mode_t mode)
|
|||||||
set_fs_flags (pc.fs_flags ());
|
set_fs_flags (pc.fs_flags ());
|
||||||
|
|
||||||
out:
|
out:
|
||||||
syscall_printf ("%d = fhandler_disk_file::open (%s, %p)", res,
|
syscall_printf ("%d = fhandler_disk_file::open (%S, %p)", res,
|
||||||
get_win32_name (), flags);
|
pc.get_nt_native_path (), flags);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2863,8 +2863,6 @@ int
|
|||||||
symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
|
symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
|
||||||
bool isdevice)
|
bool isdevice)
|
||||||
{
|
{
|
||||||
extern suffix_info stat_suffixes[];
|
|
||||||
|
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
path_conv win32_path, win32_oldpath;
|
path_conv win32_path, win32_oldpath;
|
||||||
@ -3682,8 +3680,6 @@ symlink_info::case_check (char *path)
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
readlink (const char *path, char *buf, int buflen)
|
readlink (const char *path, char *buf, int buflen)
|
||||||
{
|
{
|
||||||
extern suffix_info stat_suffixes[];
|
|
||||||
|
|
||||||
if (buflen < 0)
|
if (buflen < 0)
|
||||||
{
|
{
|
||||||
set_errno (ENAMETOOLONG);
|
set_errno (ENAMETOOLONG);
|
||||||
@ -3968,8 +3964,6 @@ cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
|
|||||||
extern "C" char *
|
extern "C" char *
|
||||||
realpath (const char *path, char *resolved)
|
realpath (const char *path, char *resolved)
|
||||||
{
|
{
|
||||||
extern suffix_info stat_suffixes[];
|
|
||||||
|
|
||||||
/* Make sure the right errno is returned if path is NULL. */
|
/* Make sure the right errno is returned if path is NULL. */
|
||||||
if (!path)
|
if (!path)
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,8 @@ struct suffix_info
|
|||||||
suffix_info (const char *s, int addit = 0): name (s), addon (addit) {}
|
suffix_info (const char *s, int addit = 0): name (s), addon (addit) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern suffix_info stat_suffixes[];
|
||||||
|
|
||||||
enum pathconv_arg
|
enum pathconv_arg
|
||||||
{
|
{
|
||||||
PC_SYM_FOLLOW = 0x0001,
|
PC_SYM_FOLLOW = 0x0001,
|
||||||
|
@ -399,7 +399,6 @@ static int
|
|||||||
acl_worker (const char *path, int cmd, int nentries, __aclent32_t *aclbufp,
|
acl_worker (const char *path, int cmd, int nentries, __aclent32_t *aclbufp,
|
||||||
unsigned fmode)
|
unsigned fmode)
|
||||||
{
|
{
|
||||||
extern suffix_info stat_suffixes[];
|
|
||||||
int res = -1;
|
int res = -1;
|
||||||
fhandler_base *fh = build_fh_name (path, NULL, fmode, stat_suffixes);
|
fhandler_base *fh = build_fh_name (path, NULL, fmode, stat_suffixes);
|
||||||
if (fh->error ())
|
if (fh->error ())
|
||||||
|
@ -29,6 +29,7 @@ details. */
|
|||||||
#include "cygtls.h"
|
#include "cygtls.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
|
#include "ntdll.h"
|
||||||
|
|
||||||
#define FACTOR (0x19db1ded53e8000LL)
|
#define FACTOR (0x19db1ded53e8000LL)
|
||||||
#define NSPERSEC 10000000LL
|
#define NSPERSEC 10000000LL
|
||||||
@ -445,10 +446,9 @@ gmtime (const time_t *tim_p)
|
|||||||
#endif /* POSIX_LOCALTIME */
|
#endif /* POSIX_LOCALTIME */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
utimes_worker (const char *path, const struct timeval *tvp, int nofollow)
|
utimes_worker (path_conv &win32, const struct timeval *tvp)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
path_conv win32 (path, PC_POSIX | (nofollow ? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW));
|
|
||||||
|
|
||||||
if (win32.error)
|
if (win32.error)
|
||||||
set_errno (win32.error);
|
set_errno (win32.error);
|
||||||
@ -460,7 +460,9 @@ utimes_worker (const char *path, const struct timeval *tvp, int nofollow)
|
|||||||
cygheap_fdenum cfd (true);
|
cygheap_fdenum cfd (true);
|
||||||
while (cfd.next () >= 0)
|
while (cfd.next () >= 0)
|
||||||
if (cfd->get_access () & (FILE_WRITE_ATTRIBUTES | GENERIC_WRITE)
|
if (cfd->get_access () & (FILE_WRITE_ATTRIBUTES | GENERIC_WRITE)
|
||||||
&& strcmp (cfd->get_win32_name (), win32) == 0)
|
&& RtlEqualUnicodeString (cfd->pc.get_nt_native_path (),
|
||||||
|
win32.get_nt_native_path (),
|
||||||
|
TRUE))
|
||||||
{
|
{
|
||||||
fh = cfd;
|
fh = cfd;
|
||||||
fromfd = true;
|
fromfd = true;
|
||||||
@ -476,7 +478,7 @@ utimes_worker (const char *path, const struct timeval *tvp, int nofollow)
|
|||||||
{
|
{
|
||||||
debug_printf ("got %d error from build_fh_name", fh->error ());
|
debug_printf ("got %d error from build_fh_name", fh->error ());
|
||||||
set_errno (fh->error ());
|
set_errno (fh->error ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = fh->utimes (tvp);
|
res = fh->utimes (tvp);
|
||||||
@ -486,7 +488,8 @@ utimes_worker (const char *path, const struct timeval *tvp, int nofollow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
syscall_printf ("%d = utimes (%s, %p)", res, path, tvp);
|
syscall_printf ("%d = utimes (%S, %p)",
|
||||||
|
res, win32.get_nt_native_path (), tvp);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,14 +497,16 @@ error:
|
|||||||
extern "C" int
|
extern "C" int
|
||||||
utimes (const char *path, const struct timeval *tvp)
|
utimes (const char *path, const struct timeval *tvp)
|
||||||
{
|
{
|
||||||
return utimes_worker (path, tvp, 0);
|
path_conv win32 (path, PC_POSIX | PC_SYM_FOLLOW, stat_suffixes);
|
||||||
|
return utimes_worker (win32, tvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BSD */
|
/* BSD */
|
||||||
extern "C" int
|
extern "C" int
|
||||||
lutimes (const char *path, const struct timeval *tvp)
|
lutimes (const char *path, const struct timeval *tvp)
|
||||||
{
|
{
|
||||||
return utimes_worker (path, tvp, 1);
|
path_conv win32 (path, PC_POSIX | PC_SYM_NOFOLLOW, stat_suffixes);
|
||||||
|
return utimes_worker (win32, tvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BSD */
|
/* BSD */
|
||||||
@ -516,7 +521,7 @@ futimes (int fd, const struct timeval *tvp)
|
|||||||
else if (cfd->get_access () & (FILE_WRITE_ATTRIBUTES | GENERIC_WRITE))
|
else if (cfd->get_access () & (FILE_WRITE_ATTRIBUTES | GENERIC_WRITE))
|
||||||
res = cfd->utimes (tvp);
|
res = cfd->utimes (tvp);
|
||||||
else
|
else
|
||||||
res = utimes_worker (cfd->get_win32_name (), tvp, 1);
|
res = utimes_worker (cfd->pc, tvp);
|
||||||
syscall_printf ("%d = futimes (%d, %p)", res, fd, tvp);
|
syscall_printf ("%d = futimes (%d, %p)", res, fd, tvp);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user