(Interim checkin while we work on this)
* devices.cc: Regenerate. * devices.h (device::noexpose): New field. (device::dev_on_fs): Make a bit field. (get_major): Use proper type for declaration. (expose): New field. (ext_dev_storage): Delete declaration. (dev_storage_size): Ditto. (dev_storage): New declaration. (dev_storage_end): Ditto. * devices.in: Mark /dev/ptym*, /dev/com*, /dev/pipe, /dev/fifo, and "/dev" as "no expose". * fhandler.h (fhandler_dev::lastrealpos): Delete declaration. (fhandler_dev::devidx): Declare new field. * fhandler_disk_file.cc: Move fhandler_dev functions into fhandler_dev.cc. * fhandler_dev.cc: Add includes needed for functions moved from fhandler_disk_file.cc. (dev_storage_scan_start): Define place to start listing devices. (dev_storage_size): Define size of array to scan. (fhandler_dev::fhandler_dev): Move here from fhandler_disk_file.cc. (fhandler_dev::opendir): Ditto. (fhandler_dev::readdir): Just check devidx for non-NULL to determine when to go to disk for /dev content. Use dev_storage rather than ext_dev_storage. Iterate over dev_storage using devidx pointer. Use accessor functions rather than raw references to the device struct. Only increment dir->__d_position when we are actually going to be returning something. Add debug_printf for exit. (fhandler_dev::rewinddir): Set devidx as appropriate depending on whether there's a /dev on disk or not. * gendevices: Don't mark dev_storage static but do put it in the _RDATA section. * path.cc (path_conv::check): Use new "device::expose()" function to decide to forbid programs from referencing internal device types.
This commit is contained in:
@@ -2365,66 +2365,6 @@ fhandler_disk_file::closedir (DIR *dir)
|
||||
return res;
|
||||
}
|
||||
|
||||
fhandler_dev::fhandler_dev () :
|
||||
fhandler_disk_file (), lastrealpos (0), dir_exists (true)
|
||||
{
|
||||
}
|
||||
|
||||
DIR *
|
||||
fhandler_dev::opendir (int fd)
|
||||
{
|
||||
DIR *dir;
|
||||
DIR *res = NULL;
|
||||
|
||||
dir = fhandler_disk_file::opendir (fd);
|
||||
if (dir)
|
||||
return dir;
|
||||
if ((dir = (DIR *) malloc (sizeof (DIR))) == NULL)
|
||||
set_errno (ENOMEM);
|
||||
else if ((dir->__d_dirent =
|
||||
(struct dirent *) malloc (sizeof (struct dirent))) == NULL)
|
||||
{
|
||||
set_errno (ENOMEM);
|
||||
goto free_dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
cygheap_fdnew cfd;
|
||||
if (cfd < 0 && fd < 0)
|
||||
goto free_dirent;
|
||||
|
||||
dir->__d_dirname = NULL;
|
||||
dir->__d_dirent->__d_version = __DIRENT_VERSION;
|
||||
dir->__d_cookie = __DIRENT_COOKIE;
|
||||
dir->__handle = INVALID_HANDLE_VALUE;
|
||||
dir->__d_position = 0;
|
||||
dir->__flags = 0;
|
||||
dir->__d_internal = 0;
|
||||
|
||||
if (fd >= 0)
|
||||
dir->__d_fd = fd;
|
||||
else
|
||||
{
|
||||
cfd = this;
|
||||
dir->__d_fd = cfd;
|
||||
cfd->nohandle (true);
|
||||
}
|
||||
set_close_on_exec (true);
|
||||
dir->__fh = this;
|
||||
dir_exists = false;
|
||||
res = dir;
|
||||
}
|
||||
|
||||
syscall_printf ("%p = opendir (%s)", res, get_name ());
|
||||
return res;
|
||||
|
||||
free_dirent:
|
||||
free (dir->__d_dirent);
|
||||
free_dir:
|
||||
free (dir);
|
||||
return res;
|
||||
}
|
||||
|
||||
fhandler_cygdrive::fhandler_cygdrive () :
|
||||
fhandler_disk_file (), ndrives (0), pdrive (NULL)
|
||||
{
|
||||
|
Reference in New Issue
Block a user