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.
/* * 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; }
-- 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