* Issue creating directories in a VHD volume
@ 2016-06-29 6:32 David Lee
0 siblings, 0 replies; only message in thread
From: David Lee @ 2016-06-29 6:32 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
Hi,
I found some issues while trying to create directories to a volume on
a virtual disk (VHD).
-- SETUP --
* Windows 7 SP1 x64
* Cygwin 2.5.2 x86 installed and run under C:\Cygwin
* 100 MB Virtual Disk on D:\Test.vhd
* VHD has a 100 MB simple volume formatted as NTFS
* Tests were done under an account the joined the Local Administrators group.
-- TEST 1 --
1. I used Disk Management Console (diskmgmt.msc) to:
a. Attach the VHD using Disk Management Console (GUI) (diskmgmt.msc).
b. Mount the volume under C:\Cygwin\tmp\mount (Cygwin saw it as /tmp/mount).
2. Then I tried to create a directory in /tmp/mount inside bash:
mkdir /tmp/mount/12345
3. Result: success (note: elevation was not needed).
-- TEST 2 --
Same procedure but used the diskpart.exe console utility instead.
1. It fired up a UAC prompt and I accepted it.
2. I created another directory: mkdir /tmp/mount/67890.
3. Result: success (note: although diskpart.exe was elevated, the bash
prompt itself wasn't.)
-- TEST 3 --
I wrote a simple utility in C/C++ to attach the VHD (using Win32 API
such as OpenVirtualDisk() and AttachVirtualDIsk()).
Source was attached with this message (demo.c)
1. I fired up an *elevated* Command Prompt.
2. Ran the utility to attach the DISK. Result: success.
3. Mounted the volume under C:\Cygwin\tmp\mount, either diskmgmt.msc
or diskpart.exe
4. Inside a bash prompt (no elevation), typed mkdir /tmp/mount/abcde
5. Result: permission denied (no directory was created).
6. In a Command Prompt (no elevation), the following SUCCEED:
mkdir C:\Cygwin\tmp\mount\abcde
Any help is appreciated on why I got the 'permission denied' message.
David Lee.
[-- Attachment #2: demo.c --]
[-- Type: text/x-csrc, Size: 1161 bytes --]
/*
* rename to demo.c and compile under cygwin as
*
* i686-w64-mingw32-gcc demo.c -lVirtDisk
*/
#define _WIN32_WINNT 0x601
#define INITGUID
#include <Windows.h>
#include <VirtDisk.h>
#include <tchar.h>
#include <stdio.h>
#define VHDPATH L"D:\\test.vhd"
int
main (void)
{
VIRTUAL_STORAGE_TYPE vst;
HANDLE hVhd;
ATTACH_VIRTUAL_DISK_PARAMETERS params;
DWORD rc;
vst.DeviceId = VIRTUAL_STORAGE_TYPE_DEVICE_VHD;
vst.VendorId = VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
rc = OpenVirtualDisk (
&vst,
VHDPATH,
(VIRTUAL_DISK_ACCESS_MASK) (VIRTUAL_DISK_ACCESS_ATTACH_RW | VIRTUAL_DISK_ACCESS_DETACH),
OPEN_VIRTUAL_DISK_FLAG_NONE,
NULL,
&hVhd
);
if (rc != ERROR_SUCCESS)
{
fwprintf (stderr, L"OpenVirtualDisk() failed, rc = %lu\n", rc);
return 10;
}
params.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
rc = AttachVirtualDisk (
hVhd,
NULL,
(ATTACH_VIRTUAL_DISK_FLAG)(ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME),
0,
¶ms,
NULL
);
if (rc != ERROR_SUCCESS)
{
fwprintf (stderr, L"AttachVirtualDisk() failed, rc = %lu\n", rc);
return 10;
}
wprintf (L"OK!\n");
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 218 bytes --]
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-06-29 3:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-29 6:32 Issue creating directories in a VHD volume David Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).