Ignore:
Timestamp:
May 9, 2002, 3:55:35 PM (23 years ago)
Author:
sandervl
Message:

volume api updates (LVM)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmdisk.cpp

    r8258 r8397  
    1 /* $Id: hmdisk.cpp,v 1.42 2002-04-13 06:21:39 bird Exp $ */
     1/* $Id: hmdisk.cpp,v 1.43 2002-05-09 13:55:33 sandervl Exp $ */
    22
    33/*
     
    1212#include <os2win.h>
    1313#include <string.h>
     14#include <versionos2.h>
    1415
    1516#include <misc.h>
    1617#include "hmdisk.h"
    1718#include "mmap.h"
    18 #include "oslibdos.h"
    1919#include <win\winioctl.h>
    2020#include <win\ntddscsi.h>
    2121#include <win\wnaspi32.h>
    2222#include <win\aspi.h>
     23#include "oslibdos.h"
     24#include "osliblvm.h"
    2325
    2426#define DBG_LOCALLOG    DBG_hmdisk
     
    5052{
    5153    HMDeviceRegisterEx("\\\\.\\PHYSICALDRIVE", this, NULL);
     54    HMDeviceRegisterEx(VOLUME_NAME_PREFIX, this, NULL);
    5255}
    5356
     
    8386    //\\.\PHYSICALDRIVEn    -> length 18
    8487    if(namelength != 6 && namelength != 18) {
     88        if(VERSION_IS_WIN2000_OR_HIGHER()) {
     89            if(!strncmp(lpDeviceName, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) {
     90                return TRUE;
     91            }
     92        }
    8593        return FALSE;
    8694    }
     
    124132
    125133    char szDrive[4];
    126     szDrive[0] = *lpFileName;
    127134    szDrive[1] = ':';
    128135    szDrive[2] = '\0';
     136
     137    //if volume name, query
     138    if(VERSION_IS_WIN2000_OR_HIGHER() && !strncmp(lpFileName, VOLUME_NAME_PREFIX, sizeof(VOLUME_NAME_PREFIX)-1)) {
     139        char *pszVolume;
     140        int   length;
     141
     142        //strip volume name prefix (\\\\?\\Volume\\)
     143        length = strlen(lpFileName);
     144        pszVolume = (char *)alloca(length);
     145
     146        strcpy(pszVolume, &lpFileName[sizeof(VOLUME_NAME_PREFIX)-1+1]);  //-zero term + starting '{'
     147        length -= sizeof(VOLUME_NAME_PREFIX)-1+1;
     148        if(pszVolume[length-2] == '}') {
     149            pszVolume[length-2] = 0;
     150            szDrive[0] = OSLibLVMQueryDriveFromVolumeName(pszVolume);
     151        }
     152        else return ERROR_FILE_NOT_FOUND;
     153
     154    }
     155    else {
     156        szDrive[0] = *lpFileName;
     157    }
    129158    dwDriveType = GetDriveTypeA(szDrive);
    130159
     
    550579        msg = "IOCTL_CDROM_FIND_NEW_DEVICES";
    551580        break;
     581    case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS:
     582        msg = "IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS";
     583        break;
    552584    }
    553585    if(msg) {
     
    713745
    714746    case IOCTL_DISK_GET_PARTITION_INFO:
     747    {
     748        PPARTITION_INFORMATION pPartition = (PPARTITION_INFORMATION)lpOutBuffer;
     749        if(nOutBufferSize < sizeof(PARTITION_INFORMATION) || !pPartition) {
     750            SetLastError(ERROR_INSUFFICIENT_BUFFER);
     751            return FALSE;
     752        }
     753        if(lpBytesReturned) {
     754            *lpBytesReturned = sizeof(PARTITION_INFORMATION);
     755        }
     756        if(OSLibLVMGetPartitionInfo(drvInfo->driveLetter, pPartition)) {
     757            SetLastError(ERROR_NOT_ENOUGH_MEMORY); //wrong error, but who cares
     758            return FALSE;
     759        }
     760
     761        SetLastError(ERROR_SUCCESS);
     762        return TRUE;
     763    }
     764
    715765    case IOCTL_DISK_LOAD_MEDIA:
    716766    case IOCTL_DISK_MEDIA_REMOVAL:
     
    723773        break;
    724774
     775
     776    case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS:
     777    {
     778        PVOLUME_DISK_EXTENTS pVolExtent = (PVOLUME_DISK_EXTENTS)lpOutBuffer;
     779        if(nOutBufferSize < sizeof(VOLUME_DISK_EXTENTS) || !pVolExtent) {
     780            SetLastError(ERROR_INSUFFICIENT_BUFFER);
     781            return FALSE;
     782        }
     783        if(OSLibLVMGetVolumeExtents(drvInfo->driveLetter, pVolExtent)) {
     784            SetLastError(ERROR_NOT_ENOUGH_MEMORY); //wrong error, but who cares
     785            return FALSE;
     786        }
     787
     788        if(lpBytesReturned) {
     789            *lpBytesReturned = sizeof(VOLUME_DISK_EXTENTS);
     790        }
     791        SetLastError(ERROR_SUCCESS);
     792        return TRUE;
     793    }
    725794
    726795    // -----------
Note: See TracChangeset for help on using the changeset viewer.