Better support for device handles in NtQueryVolumeInformationFile.
This commit is contained in:
parent
c7c9f93913
commit
0adec9a7c1
|
@ -30,6 +30,9 @@
|
||||||
#ifdef HAVE_SYS_ERRNO_H
|
#ifdef HAVE_SYS_ERRNO_H
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LINUX_MAJOR_H
|
||||||
|
# include <linux/major.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_STATVFS_H
|
#ifdef HAVE_SYS_STATVFS_H
|
||||||
# include <sys/statvfs.h>
|
# include <sys/statvfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -963,6 +966,7 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
|
||||||
FS_INFORMATION_CLASS info_class )
|
FS_INFORMATION_CLASS info_class )
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if ((io->u.Status = wine_server_handle_to_fd( handle, 0, &fd, NULL, NULL )) != STATUS_SUCCESS)
|
if ((io->u.Status = wine_server_handle_to_fd( handle, 0, &fd, NULL, NULL )) != STATUS_SUCCESS)
|
||||||
return io->u.Status;
|
return io->u.Status;
|
||||||
|
@ -984,15 +988,25 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE_FS_SIZE_INFORMATION *info = buffer;
|
FILE_FS_SIZE_INFORMATION *info = buffer;
|
||||||
struct statvfs st;
|
struct statvfs stvfs;
|
||||||
|
|
||||||
if (fstatvfs( fd, &st ) < 0) io->u.Status = FILE_GetNtStatus();
|
if (fstat( fd, &st ) < 0)
|
||||||
|
{
|
||||||
|
io->u.Status = FILE_GetNtStatus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))
|
||||||
|
{
|
||||||
|
io->u.Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fstatvfs( fd, &stvfs ) < 0) io->u.Status = FILE_GetNtStatus();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->TotalAllocationUnits.QuadPart = st.f_blocks;
|
info->TotalAllocationUnits.QuadPart = stvfs.f_blocks;
|
||||||
info->AvailableAllocationUnits.QuadPart = st.f_bavail;
|
info->AvailableAllocationUnits.QuadPart = stvfs.f_bavail;
|
||||||
info->SectorsPerAllocationUnit = 1;
|
info->SectorsPerAllocationUnit = 1;
|
||||||
info->BytesPerSector = st.f_frsize;
|
info->BytesPerSector = stvfs.f_frsize;
|
||||||
io->Information = sizeof(*info);
|
io->Information = sizeof(*info);
|
||||||
io->u.Status = STATUS_SUCCESS;
|
io->u.Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1006,40 +1020,74 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
|
||||||
FILE_FS_DEVICE_INFORMATION *info = buffer;
|
FILE_FS_DEVICE_INFORMATION *info = buffer;
|
||||||
|
|
||||||
#if defined(linux) && defined(HAVE_FSTATFS)
|
#if defined(linux) && defined(HAVE_FSTATFS)
|
||||||
struct stat st;
|
|
||||||
struct statfs stfs;
|
struct statfs stfs;
|
||||||
|
|
||||||
info->DeviceType = FILE_DEVICE_DISK;
|
|
||||||
info->Characteristics = 0;
|
info->Characteristics = 0;
|
||||||
if (fstatfs( fd, &stfs ) < 0) stfs.f_type = 0;
|
|
||||||
switch (stfs.f_type)
|
if (fstat( fd, &st ) < 0)
|
||||||
{
|
{
|
||||||
case 0x9660: /* iso9660 */
|
io->u.Status = FILE_GetNtStatus();
|
||||||
case 0x15013346: /* udf */
|
|
||||||
info->DeviceType = FILE_DEVICE_CD_ROM_FILE_SYSTEM;
|
|
||||||
info->Characteristics = FILE_REMOVABLE_MEDIA|FILE_READ_ONLY_DEVICE;
|
|
||||||
break;
|
|
||||||
case 0x6969: /* nfs */
|
|
||||||
case 0x517B: /* smbfs */
|
|
||||||
case 0x564c: /* ncpfs */
|
|
||||||
info->DeviceType = FILE_DEVICE_NETWORK_FILE_SYSTEM;
|
|
||||||
info->Characteristics = FILE_REMOTE_DEVICE;
|
|
||||||
break;
|
|
||||||
case 0x01021994: /* tmpfs */
|
|
||||||
case 0x28cd3d45: /* cramfs */
|
|
||||||
case 0x1373: /* devfs */
|
|
||||||
case 0x9fa0: /* procfs */
|
|
||||||
info->DeviceType = FILE_DEVICE_VIRTUAL_DISK;
|
|
||||||
info->Characteristics = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
info->DeviceType = FILE_DEVICE_DISK_FILE_SYSTEM;
|
|
||||||
info->Characteristics = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* check for floppy disk */
|
if (S_ISCHR( st.st_mode ))
|
||||||
if (!fstat( fd, &st ) && major(st.st_dev) == 2 /*FLOPPY_MAJOR*/)
|
{
|
||||||
info->Characteristics |= FILE_REMOVABLE_MEDIA;
|
switch(major(st.st_rdev))
|
||||||
|
{
|
||||||
|
case MEM_MAJOR:
|
||||||
|
info->DeviceType = FILE_DEVICE_NULL;
|
||||||
|
break;
|
||||||
|
case TTY_MAJOR:
|
||||||
|
info->DeviceType = FILE_DEVICE_SERIAL_PORT;
|
||||||
|
break;
|
||||||
|
case LP_MAJOR:
|
||||||
|
info->DeviceType = FILE_DEVICE_PARALLEL_PORT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
info->DeviceType = FILE_DEVICE_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (S_ISBLK( st.st_mode ))
|
||||||
|
{
|
||||||
|
info->DeviceType = FILE_DEVICE_DISK;
|
||||||
|
}
|
||||||
|
else if (S_ISFIFO( st.st_mode ) || S_ISSOCK( st.st_mode ))
|
||||||
|
{
|
||||||
|
info->DeviceType = FILE_DEVICE_NAMED_PIPE;
|
||||||
|
}
|
||||||
|
else /* regular file or directory */
|
||||||
|
{
|
||||||
|
info->Characteristics |= FILE_DEVICE_IS_MOUNTED;
|
||||||
|
|
||||||
|
/* check for floppy disk */
|
||||||
|
if (major(st.st_dev) == FLOPPY_MAJOR)
|
||||||
|
info->Characteristics |= FILE_REMOVABLE_MEDIA;
|
||||||
|
|
||||||
|
if (fstatfs( fd, &stfs ) < 0) stfs.f_type = 0;
|
||||||
|
switch (stfs.f_type)
|
||||||
|
{
|
||||||
|
case 0x9660: /* iso9660 */
|
||||||
|
case 0x15013346: /* udf */
|
||||||
|
info->DeviceType = FILE_DEVICE_CD_ROM_FILE_SYSTEM;
|
||||||
|
info->Characteristics |= FILE_REMOVABLE_MEDIA|FILE_READ_ONLY_DEVICE;
|
||||||
|
break;
|
||||||
|
case 0x6969: /* nfs */
|
||||||
|
case 0x517B: /* smbfs */
|
||||||
|
case 0x564c: /* ncpfs */
|
||||||
|
info->DeviceType = FILE_DEVICE_NETWORK_FILE_SYSTEM;
|
||||||
|
info->Characteristics |= FILE_REMOTE_DEVICE;
|
||||||
|
break;
|
||||||
|
case 0x01021994: /* tmpfs */
|
||||||
|
case 0x28cd3d45: /* cramfs */
|
||||||
|
case 0x1373: /* devfs */
|
||||||
|
case 0x9fa0: /* procfs */
|
||||||
|
info->DeviceType = FILE_DEVICE_VIRTUAL_DISK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
info->DeviceType = FILE_DEVICE_DISK_FILE_SYSTEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static int warned;
|
static int warned;
|
||||||
if (!warned++) FIXME( "device info not supported on this platform\n" );
|
if (!warned++) FIXME( "device info not supported on this platform\n" );
|
||||||
|
|
Loading…
Reference in New Issue