summaryrefslogtreecommitdiffhomepage
path: root/src/fs/ntapi_tt_statfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/ntapi_tt_statfs.c')
-rw-r--r--src/fs/ntapi_tt_statfs.c67
1 files changed, 22 insertions, 45 deletions
diff --git a/src/fs/ntapi_tt_statfs.c b/src/fs/ntapi_tt_statfs.c
index 450d2bc..21785fd 100644
--- a/src/fs/ntapi_tt_statfs.c
+++ b/src/fs/ntapi_tt_statfs.c
@@ -12,15 +12,13 @@
int32_t __stdcall __ntapi_tt_statfs(
__in void * hfile,
- __in void * hroot __optional,
- __in nt_unicode_string * path,
__out nt_statfs * statfs,
+ __in uint32_t infolen,
__out uintptr_t * buffer,
__in uint32_t buffer_size,
__in uint32_t flags)
{
int32_t status;
- nt_oa oa;
nt_iosb iosb;
nt_unicode_string * sdev;
wchar16_t * wch;
@@ -33,39 +31,18 @@ int32_t __stdcall __ntapi_tt_statfs(
nt_fsfsi * fsfsi;
uint32_t * fsid;
uint64_t * pguid;
+ uint32_t written;
/* validation */
- if (!hfile && !path)
- return NT_STATUS_INVALID_HANDLE;
+ if (infolen < sizeof(*statfs))
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
- /* hfile */
- if (hfile) {
- statfs->flags = 0;
- } else {
- /* oa */
- oa.len = sizeof(nt_oa);
- oa.root_dir = hroot;
- oa.obj_name = path;
- oa.obj_attr = 0;
- oa.sec_desc = 0;
- oa.sec_qos = 0;
-
- /* open file/folder */
- if ((status = __ntapi->zw_open_file(
- &hfile,
- NT_SEC_SYNCHRONIZE
- | NT_FILE_READ_ATTRIBUTES
- | NT_FILE_READ_ACCESS,
- &oa,
- &iosb,
- NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE,
- NT_FILE_SYNCHRONOUS_IO_ALERT)))
- return status;
-
- statfs->flags = NT_STATFS_NEW_HANDLE;
- }
+ /* init */
+ __ntapi->tt_aligned_block_memset(
+ statfs,0,sizeof(*statfs));
- statfs->hfile = hfile;
+ statfs->hfile = hfile;
+ statfs->dev_name_maxlen = infolen - sizeof(*statfs);
/* maximum component length, file system type */
if ((status = __ntapi->zw_query_volume_information_file(
@@ -81,8 +58,7 @@ int32_t __stdcall __ntapi_tt_statfs(
statfs->f_namelen = fsai->maximum_component_name_length;
statfs->nt_fstype_hash = __ntapi->tt_buffer_crc32(
- 0,
- &fsai->file_system_name,
+ 0,&fsai->file_system_name,
fsai->file_system_name_length);
/* max files per volume */
@@ -121,7 +97,7 @@ int32_t __stdcall __ntapi_tt_statfs(
NT_FILE_FS_FULL_SIZE_INFORMATION)))
return status;
- fsfsi = (nt_fsfsi *)buffer;
+ fsfsi = (nt_fsfsi *)buffer;
statfs->f_blocks = fsfsi->total_allocation_units.quad;
statfs->f_bfree = fsfsi->actual_available_allocation_units.quad;
statfs->f_bavail = fsfsi->caller_available_allocation_units.quad;
@@ -134,14 +110,14 @@ int32_t __stdcall __ntapi_tt_statfs(
NT_OBJECT_NAME_INFORMATION,
buffer,
buffer_size,
- (uint32_t *)&iosb.info)))
+ &written)))
return status;
sdev = (nt_unicode_string *)buffer;
wch = sdev->buffer;
if (sdev->strlen < __DEVICE_PATH_PREFIX_LEN)
- return NT_STATUS_INVALID_HANDLE;
+ return NT_STATUS_NOT_SUPPORTED;
if ((wch[0] != '\\')
|| (wch[1] != 'D')
@@ -151,7 +127,7 @@ int32_t __stdcall __ntapi_tt_statfs(
|| (wch[5] != 'c')
|| (wch[6] != 'e')
|| (wch[7] != '\\'))
- return NT_STATUS_INVALID_HANDLE;
+ return NT_STATUS_NOT_SUPPORTED;
if (sdev->strlen < __DEVICE_MUP_PREFIX_LEN)
return NT_STATUS_INVALID_HANDLE;
@@ -160,15 +136,16 @@ int32_t __stdcall __ntapi_tt_statfs(
&& (wch[9]=='u')
&& (wch[10]=='p')
&& (wch[11]=='\\')) {
- flags &= ~NT_STATFS_VOLUME_GUID;
+ statfs->nt_drive_letter = 0;
+ hash = __DEVICE_MUP_PREFIX_HASH;
+ flags &= ~NT_STATFS_VOLUME_GUID;
statfs->flags |= NT_STATFS_MUP_DEVICE;
- hash = __DEVICE_MUP_PREFIX_HASH;
wch_mark = &wch[12];
- statfs->nt_drive_letter = 0;
+ wch = wch_mark;
- for (wch=wch_mark; *wch!='\\'; wch++)
- (void)0;
+ for (; *wch!='\\'; )
+ wch++;
wch++;
} else {
wch_mark = &wch[8];
@@ -181,10 +158,10 @@ int32_t __stdcall __ntapi_tt_statfs(
statfs->obj_name_strlen = sdev->strlen;
statfs->obj_name_maxlen = statfs->dev_name_maxlen;
- statfs->dev_name_strlen = (uint16_t)((wch - sdev->buffer) * sizeof(uint16_t));
+ statfs->dev_name_strlen = sizeof(uint16_t) * (uint16_t)(wch - sdev->buffer);
statfs->dev_name_hash = __ntapi->tt_buffer_crc32(
hash,wch_mark,
- sizeof(wchar16_t)*(wch-wch_mark));
+ sizeof(wchar16_t) * (wch - wch_mark));
/* device name */
if (!(flags & NT_STATFS_DEV_NAME_COPY))