* syscalls.cc (stat_worker): Make global. Accept path_conv parameter for

passing information back to caller.
* winsup.h: Declare stat_worker.
* dir.cc (opendir): Use stat_worker rather than stat and pass path_conv
parameter to stat_worker for later inspection.
* syslog.cc (syslog): Teach syslog about syslog priorities other than LOG_ERR,
LOG_WARNING and LOG_INFO
* path.cc (path_conv::check): Don't perform file system or rootdir checks on
devices.
This commit is contained in:
Christopher Faylor 2001-10-05 00:17:57 +00:00
parent 8af0f81d52
commit 32fb80db07
6 changed files with 102 additions and 60 deletions

View File

@ -1,3 +1,21 @@
Thu Oct 4 18:49:23 2001 Christopher Faylor <cgf@cygnus.com>
* syscalls.cc (stat_worker): Make global. Accept path_conv parameter
for passing information back to caller.
* winsup.h: Declare stat_worker.
* dir.cc (opendir): Use stat_worker rather than stat and pass path_conv
parameter to stat_worker for later inspection.
2001-10-04 Karellen (karellen@boreworms.com)
* syslog.cc (syslog): Teach syslog about syslog priorities other than
LOG_ERR, LOG_WARNING and LOG_INFO
Thu Oct 4 15:50:03 2001 Christopher Faylor <cgf@cygnus.com>
* path.cc (path_conv::check): Don't perform file system or rootdir
checks on devices.
Wed Oct 3 19:40:36 2001 Christopher Faylor <cgf@cygnus.com>
* dcrt0.cc (dll_crt0_1): Don't close hexec_proc if it is NULL.

View File

@ -83,15 +83,9 @@ opendir (const char *dirname)
DIR *res = 0;
struct stat statbuf;
path_conv real_dirname (dirname, PC_SYM_FOLLOW | PC_FULL);
path_conv real_dirname;
if (real_dirname.error)
{
set_errno (real_dirname.error);
goto failed;
}
if (stat (real_dirname, &statbuf) == -1)
if (stat_worker (dirname, &statbuf, 1, &real_dirname) == -1)
goto failed;
if (!(statbuf.st_mode & S_IFDIR))

View File

@ -471,8 +471,6 @@ path_conv::check (const char *src, unsigned opt,
if (error)
return;
update_fs_info (full_path);
/* devn should not be a device. If it is, then stop parsing now. */
if (devn != FH_BAD)
{
@ -480,6 +478,8 @@ path_conv::check (const char *src, unsigned opt,
goto out; /* Found a device. Stop parsing. */
}
update_fs_info (full_path);
/* Eat trailing slashes */
char *dostail = strchr (full_path, '\0');
@ -668,6 +668,8 @@ out:
return;
}
if (devn == FH_BAD)
{
update_fs_info (path);
if (!fs_name[0])
{
@ -687,6 +689,7 @@ out:
in fhandler.cc (fhandler_disk_file::open). */
set_has_buggy_open (strcmp (fs_name, "SUNWNFS") == 0);
}
}
if (!(opt & PC_FULL))
{

View File

@ -1067,9 +1067,8 @@ suffix_info stat_suffixes[] =
};
/* Cygwin internal */
static int
stat_worker (const char *caller, const char *name, struct stat *buf,
int nofollow)
int __stdcall
stat_worker (const char *name, struct stat *buf, int nofollow, path_conv *pc)
{
int res = -1;
int oret;
@ -1078,36 +1077,38 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
path_conv real_path;
fhandler_base *fh = NULL;
if (!pc)
pc = &real_path;
MALLOC_CHECK;
int open_flags = O_RDONLY | O_BINARY | O_DIROPEN
| (nofollow ? O_NOSYMLINK : 0);
debug_printf ("%s (%s, %p)", caller, name, buf);
if (check_null_invalid_struct_errno (buf))
goto done;
fh = cygheap->fdtab.build_fhandler_from_name (-1, name, NULL, real_path,
fh = cygheap->fdtab.build_fhandler_from_name (-1, name, NULL, *pc,
(nofollow ?
PC_SYM_NOFOLLOW
: PC_SYM_FOLLOW)
| PC_FULL, stat_suffixes);
if (real_path.error)
if (pc->error)
{
set_errno (real_path.error);
set_errno (pc->error);
goto done;
}
debug_printf ("(%s, %p, %d, %p)", name, buf, nofollow, pc);
memset (buf, 0, sizeof (struct stat));
if (real_path.is_device ())
return stat_dev (real_path.get_devn (), real_path.get_unitn (),
hash_path_name (0, real_path.get_win32 ()), buf);
if (pc->is_device ())
return stat_dev (pc->get_devn (), pc->get_unitn (),
hash_path_name (0, pc->get_win32 ()), buf);
debug_printf ("%d = file_attributes for '%s'", (DWORD) real_path,
(char *) real_path);
if ((oret = fh->open (&real_path, open_flags, 0)))
if ((oret = fh->open (pc, open_flags, 0)))
/* ok */;
else
{
@ -1115,9 +1116,9 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
/* If we couldn't open the file, try a "query open" with no permissions.
This will allow us to determine *some* things about the file, at least. */
fh->set_query_open (TRUE);
if ((oret = fh->open (&real_path, open_flags, 0)))
if ((oret = fh->open (pc, open_flags, 0)))
/* ok */;
else if (allow_ntsec && real_path.has_acls () && get_errno () == EACCES
else if (allow_ntsec && pc->has_acls () && get_errno () == EACCES
&& !get_file_attribute (TRUE, real_path, &ntsec_atts, &uid, &gid)
&& !ntsec_atts && uid == myself->uid && gid == myself->gid)
{
@ -1127,7 +1128,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
in a failing open call in the same process. Check that
case. */
set_file_attribute (TRUE, real_path, 0400);
oret = fh->open (&real_path, open_flags, 0);
oret = fh->open (pc, open_flags, 0);
set_file_attribute (TRUE, real_path, ntsec_atts);
}
}
@ -1141,44 +1142,44 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
set the number of links to 2. */
/* Unfortunately the count of 2 confuses `find (1)' command. So
let's try it with `1' as link count. */
if (real_path.isdir ())
buf->st_nlink = (real_path.isremote ()
? 1 : num_entries (real_path.get_win32 ()));
if (pc->isdir ())
buf->st_nlink = (pc->isremote ()
? 1 : num_entries (pc->get_win32 ()));
fh->close ();
}
else if (real_path.exists ())
else if (pc->exists ())
{
/* Unfortunately, the above open may fail if the file exists, though.
So we have to care for this case here, too. */
WIN32_FIND_DATA wfd;
HANDLE handle;
buf->st_nlink = 1;
if (real_path.isdir () && real_path.isremote ())
buf->st_nlink = num_entries (real_path.get_win32 ());
if (pc->isdir () && pc->isremote ())
buf->st_nlink = num_entries (pc->get_win32 ());
buf->st_dev = FHDEVN (FH_DISK) << 8;
buf->st_ino = hash_path_name (0, real_path.get_win32 ());
if (real_path.isdir ())
buf->st_ino = hash_path_name (0, pc->get_win32 ());
if (pc->isdir ())
buf->st_mode = S_IFDIR;
else if (real_path.issymlink ())
else if (pc->issymlink ())
buf->st_mode = S_IFLNK;
else if (real_path.issocket ())
else if (pc->issocket ())
buf->st_mode = S_IFSOCK;
else
buf->st_mode = S_IFREG;
if (!real_path.has_acls ()
|| get_file_attribute (TRUE, real_path.get_win32 (),
if (!pc->has_acls ()
|| get_file_attribute (TRUE, pc->get_win32 (),
&buf->st_mode,
&buf->st_uid, &buf->st_gid))
{
buf->st_mode |= STD_RBITS | STD_XBITS;
if (!(real_path.has_attribute (FILE_ATTRIBUTE_READONLY)))
if (!(pc->has_attribute (FILE_ATTRIBUTE_READONLY)))
buf->st_mode |= STD_WBITS;
if (real_path.issymlink ())
if (pc->issymlink ())
buf->st_mode |= S_IRWXU | S_IRWXG | S_IRWXO;
get_file_attribute (FALSE, real_path.get_win32 (),
get_file_attribute (FALSE, pc->get_win32 (),
NULL, &buf->st_uid, &buf->st_gid);
}
if ((handle = FindFirstFile (real_path.get_win32 (), &wfd))
if ((handle = FindFirstFile (pc->get_win32 (), &wfd))
!= INVALID_HANDLE_VALUE)
{
buf->st_atime = to_time_t (&wfd.ftLastAccessTime);
@ -1197,7 +1198,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
if (fh)
delete fh;
MALLOC_CHECK;
syscall_printf ("%d = %s (%s, %p)", res, caller, name, buf);
syscall_printf ("%d = (%s, %p)", res, name, buf);
return res;
}
@ -1205,7 +1206,8 @@ extern "C" int
_stat (const char *name, struct stat *buf)
{
sigframe thisframe (mainthread);
return stat_worker ("stat", name, buf, 0);
syscall_printf ("entering");
return stat_worker (name, buf, 0);
}
/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
@ -1213,7 +1215,8 @@ extern "C" int
lstat (const char *name, struct stat *buf)
{
sigframe thisframe (mainthread);
return stat_worker ("lstat", name, buf, 1);
syscall_printf ("entering");
return stat_worker (name, buf, 1);
}
extern int acl_access (const char *, int);

View File

@ -257,13 +257,18 @@ syslog (int priority, const char *message, ...)
WORD eventType;
switch (LOG_PRI (priority))
{
case LOG_EMERG:
case LOG_ALERT:
case LOG_CRIT:
case LOG_ERR:
eventType = EVENTLOG_ERROR_TYPE;
break;
case LOG_WARNING:
eventType = EVENTLOG_WARNING_TYPE;
break;
case LOG_NOTICE:
case LOG_INFO:
case LOG_DEBUG:
eventType = EVENTLOG_INFORMATION_TYPE;
break;
default:
@ -307,15 +312,30 @@ syslog (int priority, const char *message, ...)
eventlog capability. */
switch (LOG_PRI (priority))
{
case LOG_EMERG:
pass.print ("%s : ", "LOG_EMERG");
break;
case LOG_ALERT:
pass.print ("%s : ", "LOG_ALERT");
break;
case LOG_CRIT:
pass.print ("%s : ", "LOG_CRIT");
break;
case LOG_ERR:
pass.print ("%s : ", "LOG_ERR");
break;
case LOG_WARNING:
pass.print ("%s : ", "LOG_WARNING");
break;
case LOG_NOTICE:
pass.print ("%s : ", "LOG_NOTICE");
break;
case LOG_INFO:
pass.print ("%s : ", "LOG_INFO");
break;
case LOG_DEBUG:
pass.print ("%s : ", "LOG_DEBUG");
break;
default:
pass.print ("%s : ", "LOG_ERR");
break;

View File

@ -214,6 +214,10 @@ extern "C" void __malloc_unlock (struct _reent *);
extern "C" void __malloc_lock (struct _reent *);
extern "C" void __malloc_unlock (struct _reent *);
class path_conv;
int __stdcall stat_worker (const char *name, struct stat *buf, int nofollow,
path_conv *pc = NULL) __attribute__ ((regparm (3)));
/**************************** Exports ******************************/
extern "C" {