From 83af1d349100c3cdf6455fab2887b0d93466594f Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 7 Aug 2016 13:00:48 -0400 Subject: driver: --sysroot: support dos drive notation. --- src/internal/ptycon_open_impl.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/internal/ptycon_open_impl.c b/src/internal/ptycon_open_impl.c index 8ab9d61..24318fd 100644 --- a/src/internal/ptycon_open_impl.c +++ b/src/internal/ptycon_open_impl.c @@ -67,12 +67,42 @@ static int32_t ptyc_open( options | NT_FILE_SYNCHRONOUS_IO_ALERT); } +static int32_t ptyc_open_volume( + void ** hfile, + void * hat, + const char * arg, + uint32_t options, + bool fprivate) +{ + int32_t status; + void * hvolume = 0; + wchar16_t drive = arg[0]; + + if ((arg[1]==':') && ((arg[2]=='\\') || (arg[2]=='/'))) { + if ((status = ntapi->tt_get_dos_drive_root_handle( + &hvolume,&drive))) + return status; + + hat = hvolume; + arg = &arg[3]; + } + + status = ptyc_open( + hfile,hat,arg, + options,fprivate); + + if (hvolume) + ntapi->zw_close(hvolume); + + return status; +} + int32_t ptyc_open_file(void ** hfile, void * hat, const char * arg, bool fprivate) { - return ptyc_open(hfile,hat,arg,NT_FILE_NON_DIRECTORY_FILE,fprivate); + return ptyc_open_volume(hfile,hat,arg,NT_FILE_NON_DIRECTORY_FILE,fprivate); } int32_t ptyc_open_dir(void ** hfile, void * hat, const char * arg, bool fprivate) { - return ptyc_open(hfile,hat,arg,NT_FILE_DIRECTORY_FILE,fprivate); + return ptyc_open_volume(hfile,hat,arg,NT_FILE_DIRECTORY_FILE,fprivate); } -- cgit v1.2.3