mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 04:49:25 +08:00
* fhandler_proc.cc (fhandler_proc::readdir): Set dirent d_type.
* fhandler_process.cc (fhandler_process::readdir): Ditto. * fhandler_procnet.cc (fhandler_procnet::readdir): Ditto. * fhandler_procsys.cc (fhandler_procsys::readdir): Ditto. * fhandler_procsysvipc.cc (fhandler_procsysvipc::readdir): Ditto. * fhandler_virtual.h (virt_ftype_to_dtype): Define new inline function to generate dirent d_type from virtual_ftype_t.
This commit is contained in:
parent
633cf9b5dd
commit
54338f169f
@ -1,3 +1,13 @@
|
||||
2014-10-09 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler_proc.cc (fhandler_proc::readdir): Set dirent d_type.
|
||||
* fhandler_process.cc (fhandler_process::readdir): Ditto.
|
||||
* fhandler_procnet.cc (fhandler_procnet::readdir): Ditto.
|
||||
* fhandler_procsys.cc (fhandler_procsys::readdir): Ditto.
|
||||
* fhandler_procsysvipc.cc (fhandler_procsysvipc::readdir): Ditto.
|
||||
* fhandler_virtual.h (virt_ftype_to_dtype): Define new inline function
|
||||
to generate dirent d_type from virtual_ftype_t.
|
||||
|
||||
2014-10-08 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* common.din (ffsl): Export.
|
||||
|
@ -254,7 +254,9 @@ fhandler_proc::readdir (DIR *dir, dirent *de)
|
||||
int res;
|
||||
if (dir->__d_position < PROC_LINK_COUNT)
|
||||
{
|
||||
strcpy (de->d_name, proc_tab[dir->__d_position++].name);
|
||||
strcpy (de->d_name, proc_tab[dir->__d_position].name);
|
||||
de->d_type = virt_ftype_to_dtype (proc_tab[dir->__d_position].type);
|
||||
dir->__d_position++;
|
||||
dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
|
||||
res = 0;
|
||||
}
|
||||
@ -267,6 +269,7 @@ fhandler_proc::readdir (DIR *dir, dirent *de)
|
||||
if (found++ == dir->__d_position - PROC_LINK_COUNT)
|
||||
{
|
||||
__small_sprintf (de->d_name, "%d", pids[i]->pid);
|
||||
de->d_type = DT_DIR;
|
||||
dir->__d_position++;
|
||||
res = 0;
|
||||
break;
|
||||
|
@ -230,9 +230,14 @@ fhandler_process::readdir (DIR *dir, dirent *de)
|
||||
{
|
||||
int *p = (int *) filebuf;
|
||||
__small_sprintf (de->d_name, "%d", p[dir->__d_position++ - 2]);
|
||||
de->d_type = DT_LNK;
|
||||
}
|
||||
else
|
||||
strcpy (de->d_name, process_tab[dir->__d_position++].name);
|
||||
{
|
||||
strcpy (de->d_name, process_tab[dir->__d_position].name);
|
||||
de->d_type = virt_ftype_to_dtype (process_tab[dir->__d_position].type);
|
||||
dir->__d_position++;
|
||||
}
|
||||
dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
|
||||
res = 0;
|
||||
out:
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* fhandler_procnet.cc: fhandler for /proc/net virtual filesystem
|
||||
|
||||
Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
|
||||
Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -115,7 +115,9 @@ fhandler_procnet::readdir (DIR *dir, dirent *de)
|
||||
if (procnet_tab[dir->__d_position].type == virt_file
|
||||
&& !get_adapters_addresses (NULL, AF_INET6))
|
||||
goto out;
|
||||
strcpy (de->d_name, procnet_tab[dir->__d_position++].name);
|
||||
strcpy (de->d_name, procnet_tab[dir->__d_position].name);
|
||||
de->d_type = virt_ftype_to_dtype (procnet_tab[dir->__d_position].type);
|
||||
dir->__d_position++;
|
||||
dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
|
||||
res = 0;
|
||||
out:
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* fhandler_procsys.cc: fhandler for native NT namespace.
|
||||
|
||||
Copyright 2010, 2011, 2012, 2013 Red Hat, Inc.
|
||||
Copyright 2010, 2011, 2012, 2013, 2014 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -346,6 +346,7 @@ fhandler_procsys::readdir (DIR *dir, dirent *de)
|
||||
WCHAR buf[2][NAME_MAX + 1];
|
||||
} f;
|
||||
int res = EBADF;
|
||||
tmp_pathbuf tp;
|
||||
|
||||
if (dir->__handle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@ -357,10 +358,17 @@ fhandler_procsys::readdir (DIR *dir, dirent *de)
|
||||
res = ENMFILE;
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
char *file = tp.c_get ();
|
||||
|
||||
sys_wcstombs (de->d_name, NAME_MAX + 1, f.dbi.ObjectName.Buffer,
|
||||
f.dbi.ObjectName.Length / sizeof (WCHAR));
|
||||
de->d_ino = hash_path_name (get_ino (), de->d_name);
|
||||
de->d_type = 0;
|
||||
stpcpy (stpcpy (stpcpy (file, get_name ()), "/"), de->d_name);
|
||||
if (!lstat64 (file, &st))
|
||||
de->d_type = IFTODT (st.st_mode);
|
||||
else
|
||||
de->d_type = DT_UNKNOWN;
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,9 @@ fhandler_procsysvipc::readdir (DIR *dir, dirent *de)
|
||||
if (cygserver_running != CYGSERVER_OK)
|
||||
goto out;
|
||||
}
|
||||
strcpy (de->d_name, procsysvipc_tab[dir->__d_position++].name);
|
||||
strcpy (de->d_name, procsysvipc_tab[dir->__d_position].name);
|
||||
de->d_type = virt_ftype_to_dtype (procsysvipc_tab[dir->__d_position].type);
|
||||
dir->__d_position++;
|
||||
dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
|
||||
res = 0;
|
||||
out:
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* fhandler_virtual.h: Header for virtual fhandlers
|
||||
|
||||
Copyright 2009, 2010, 2011 Red Hat, Inc.
|
||||
Copyright 2009, 2010, 2011, 2014 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -20,3 +20,26 @@ struct virt_tab_t {
|
||||
|
||||
extern virt_tab_t *virt_tab_search (const char *, bool, const virt_tab_t *,
|
||||
size_t);
|
||||
|
||||
static inline unsigned char
|
||||
virt_ftype_to_dtype (virtual_ftype_t type)
|
||||
{
|
||||
unsigned char d_type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case virt_directory:
|
||||
d_type = DT_DIR;
|
||||
break;
|
||||
case virt_symlink:
|
||||
d_type = DT_LNK;
|
||||
break;
|
||||
case virt_file:
|
||||
d_type = DT_REG;
|
||||
break;
|
||||
default:
|
||||
d_type = DT_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return d_type;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user