* dir.cc (readdir): Fill out new old_d_ino field.

* fhandler.h (fhandler_base::namehash): Define as ino_t.
(fhandler_base::get_namehash): Ditto.
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Accommodate new 64
bit st_ino.
* fhandler_socket.cc (fhandler_socket::fstat): Ditto.
* path.cc (hash_path_name): Return ino_t.
* syscalls.cc (stat64_to_stat32): Convert 64 bit inode to 32 bit.
* winsup.h (hash_path_name): Declare as returning ino_t.
* include/cygwin/stat.h (__stat32): Use 32 bit st_ino.
(__stat64): Use 64 bit st_ino.
* include/cygwin/types.h (__ino64_t): Define.
(__ino32_t): Ditto.
(ino_t): Define appropriately.
This commit is contained in:
Christopher Faylor 2003-05-11 00:10:11 +00:00
parent bf759a5ae6
commit 066ca06fd0
11 changed files with 82 additions and 56 deletions

View File

@ -1,3 +1,20 @@
2003-05-10 Christopher Faylor <cgf@redhat.com>
* dir.cc (readdir): Fill out new old_d_ino field.
* fhandler.h (fhandler_base::namehash): Define as ino_t.
(fhandler_base::get_namehash): Ditto.
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Accommodate
new 64 bit st_ino.
* fhandler_socket.cc (fhandler_socket::fstat): Ditto.
* path.cc (hash_path_name): Return ino_t.
* syscalls.cc (stat64_to_stat32): Convert 64 bit inode to 32 bit.
* winsup.h (hash_path_name): Declare as returning ino_t.
* include/cygwin/stat.h (__stat32): Use 32 bit st_ino.
(__stat64): Use 64 bit st_ino.
* include/cygwin/types.h (__ino64_t): Define.
(__ino32_t): Ditto.
(ino_t): Define appropriately.
2003-05-10 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (NEW_FUNCTIONS): All 32/64 from 0.79 API get

View File

@ -146,6 +146,7 @@ readdir (DIR *dir)
dir->__d_dirent->d_ino = hash_path_name (dino, res->d_name);
}
}
dir->__d_dirent->old_d_ino = dir->__d_dirent->d_ino; // just truncate
return res;
}

View File

@ -10,6 +10,7 @@ details. */
#define _sys_nerr FOO_sys_nerr
#define sys_nerr FOOsys_nerr
#define _sys_errlist FOO_sys_errlist
#include "winsup.h"
#define _REENT_ONLY
#include <stdio.h>
@ -18,6 +19,7 @@ details. */
#include "thread.h"
#undef _sys_nerr
#undef sys_nerr
#undef _sys_errlist
/* Table to map Windows error codes to Errno values. */
/* FIXME: Doing things this way is a little slow. It's trivial to change
@ -25,13 +27,12 @@ details. */
#define X(w, e) {ERROR_##w, #w, e}
static const NO_COPY struct
{
DWORD w; /* windows version of error */
const char *s; /* text of windows version */
int e; /* errno version of error */
}
errmap[] =
static NO_COPY struct
{
DWORD w; /* windows version of error */
const char *s; /* text of windows version */
int e; /* errno version of error */
} errmap[] =
{
/* FIXME: Some of these choices are arbitrary! */
X (INVALID_FUNCTION, EBADRQC),
@ -116,42 +117,8 @@ errmap[] =
{ 0, NULL, 0}
};
int __stdcall
geterrno_from_win_error (DWORD code, int deferrno)
{
for (int i = 0; errmap[i].w != 0; ++i)
if (code == errmap[i].w)
{
syscall_printf ("windows error %u == errno %d", code, errmap[i].e);
return errmap[i].e;
}
syscall_printf ("unknown windows error %u, setting errno to %d", code,
deferrno);
return deferrno; /* FIXME: what's so special about EACCESS? */
}
/* seterrno_from_win_error: Given a Windows error code, set errno
as appropriate. */
void __stdcall
seterrno_from_win_error (const char *file, int line, DWORD code)
{
syscall_printf ("%s:%d windows error %d", file, line, code);
set_errno (geterrno_from_win_error (code, EACCES));
return;
}
/* seterrno: Set `errno' based on GetLastError (). */
void __stdcall
seterrno (const char *file, int line)
{
seterrno_from_win_error (file, line, GetLastError ());
}
extern char *_user_strerror _PARAMS ((int));
extern "C" {
const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
const char __declspec(dllexport) * _sys_errlist[] NO_COPY_INIT =
{
/* NOERROR 0 */ "No error",
/* EPERM 1 */ "Operation not permitted",
@ -295,9 +262,43 @@ const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
/* EOVERFLOW 139 */ "Value too large for defined data type"
};
extern const int NO_COPY __declspec(dllexport) _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
int NO_COPY_INIT _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
};
int __stdcall
geterrno_from_win_error (DWORD code, int deferrno)
{
for (int i = 0; errmap[i].w != 0; ++i)
if (code == errmap[i].w)
{
syscall_printf ("windows error %u == errno %d", code, errmap[i].e);
return errmap[i].e;
}
syscall_printf ("unknown windows error %u, setting errno to %d", code,
deferrno);
return deferrno; /* FIXME: what's so special about EACCESS? */
}
/* seterrno_from_win_error: Given a Windows error code, set errno
as appropriate. */
void __stdcall
seterrno_from_win_error (const char *file, int line, DWORD code)
{
syscall_printf ("%s:%d windows error %d", file, line, code);
set_errno (geterrno_from_win_error (code, EACCES));
return;
}
/* seterrno: Set `errno' based on GetLastError (). */
void __stdcall
seterrno (const char *file, int line)
{
seterrno_from_win_error (file, line, GetLastError ());
}
extern char *_user_strerror _PARAMS ((int));
/* FIXME: Why is strerror() a long switch and not just:
return sys_errlist[errnum];
(or moral equivalent).

View File

@ -151,7 +151,7 @@ class fhandler_base
int access;
HANDLE io_handle;
unsigned long namehash; /* hashed filename, used as inode num */
ino_t namehash; /* hashed filename, used as inode num */
protected:
/* Full unix path name of this file */
@ -292,7 +292,7 @@ class fhandler_base
const char *get_name () { return unix_path_name; }
const char *get_win32_name () { return win32_path_name; }
unsigned long get_namehash () { return namehash; }
ino_t get_namehash () { return namehash; }
virtual void hclose (HANDLE h) {CloseHandle (h);}
virtual void set_inheritance (HANDLE &h, int not_inheriting);

View File

@ -250,7 +250,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
case DRIVE_RAMDISK:
/* Although the documentation indicates otherwise, it seems like
"inodes" on these devices are persistent, at least across reboots. */
buf->st_ino = nFileIndexHigh | nFileIndexLow;
buf->st_ino = (((ino_t) nFileIndexHigh) << 32) | (ino_t) nFileIndexLow;
break;
default:
/* Either the nFileIndex* fields are unreliable or unavailable. Use the

View File

@ -442,14 +442,14 @@ fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
if (get_socket_type ()) /* fstat */
{
buf->st_dev = 0;
buf->st_ino = (ino_t) get_handle ();
buf->st_ino = (ino_t) ((DWORD) get_handle ());
buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO;
}
else
{
path_conv spc ("/dev", PC_SYM_NOFOLLOW | PC_NULLEMPTY, NULL);
buf->st_dev = spc.volser ();
buf->st_ino = (ino_t) get_namehash ();
buf->st_ino = get_namehash ();
buf->st_mode &= ~S_IRWXO;
buf->st_rdev = (get_device () << 16) | get_unit ();
}

View File

@ -19,9 +19,9 @@ extern "C" {
#ifdef __INSIDE_CYGWIN__
struct __stat32
{
__dev16_t st_dev;
ino_t st_ino;
mode_t st_mode;
__dev16_t st_dev;
__ino32_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
__uid16_t st_uid;
__gid16_t st_gid;
@ -38,7 +38,7 @@ struct __stat32
struct __stat64
{
__dev32_t st_dev;
ino_t st_ino;
__ino64_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
__uid32_t st_uid;

View File

@ -90,7 +90,13 @@ typedef __gid16_t gid_t;
#ifndef __ino_t_defined
#define __ino_t_defined
typedef unsigned long ino_t;
typedef unsigned long __ino32_t;
typedef unsigned long long __ino64_t;
#ifdef __CYGWIN_USE_BIG_TYPES__
typedef __ino64_t ino_t;
#else
typedef __ino32_t ino_t;
#endif
#endif /*__ino_t_defined*/
#ifndef __BIT_TYPES_DEFINED

View File

@ -3185,7 +3185,7 @@ readlink (const char *path, char *buf, int buflen)
the directory. FIXME: Not bullet-proof. */
/* Cygwin internal */
unsigned long __stdcall
ino_t __stdcall
hash_path_name (ino_t hash, const char *name)
{
if (!*name)

View File

@ -990,7 +990,7 @@ static void
stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst)
{
dst->st_dev = ((src->st_dev >> 8) & 0xff00) | (src->st_dev & 0xff);
dst->st_ino = src->st_ino;
dst->st_ino = ((unsigned) (src->st_ino >> 32)) | (unsigned) src->st_ino;
dst->st_mode = src->st_mode;
dst->st_nlink = src->st_nlink;
dst->st_uid = src->st_uid;

View File

@ -24,6 +24,7 @@ details. */
#endif
#define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
#define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy")))
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
#define NEW_MACRO_VARARGS
@ -198,7 +199,7 @@ int __stdcall writable_directory (const char *file);
int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
extern BOOL allow_ntsec;
unsigned long __stdcall hash_path_name (ino_t hash, const char *name) __attribute__ ((regparm(2)));
ino_t __stdcall hash_path_name (ino_t hash, const char *name) __attribute__ ((regparm(2)));
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
extern "C" char *__stdcall rootdir (char *full_path) __attribute__ ((regparm(1)));