DefineDosDevice & DiskPerf problem

Hi,
I have a file system filter driver. I am defining a dos device using
DefineDosDevice API followed by CreateFile to open the handle to the newly
created Symbolic link. I get error “File not found” (error # 2) in few
cases.

If I disable Disk Performance monitor using “DiskPerf -NV” followed by
reboot, problem does not appear. This happen only after installation of
Veritas Volume Manager. Even if I uninstall Veritas Volume Manager,
problem still exists until & unless I disable the Disk Performance
monitor.

If I do not have Veritas Volume Manager at all, then I do not see any
problem.

Can any one tell me the relationship between DefineDosDevie API & Disk
Performance monitor? Is this a non problem, or do I need to make changes
to my existing code.

-Upanshu Singhal

“Upanshu Singhal” wrote in message news:xxxxx@ntdev…
>
> I have a file system filter driver. I am defining a dos device using
> DefineDosDevice API followed by CreateFile to open the handle to the newly
> created Symbolic link. I get error “File not found” (error # 2) in few
> cases.

To what are you directing the dos device you define? In other words, can
you show us your DefineDosDevice?

Here is the code which I am using:

Assume pszVolume = C:

TCHAR tcVolumeDosDeviceName[MAX_PATH+1];
TCHAR tcDriverDosDeviceName[MAX_PATH+1];
TCHAR tcRepTargetPath[MAX_PATH+1];
TCHAR tcVolumeName[3];

ZeroMemory( tcVolumeName, sizeof(tcVolumeName) );
_tcsncpy( tcVolumeName, pszVolume, 2 ) ;

ZeroMemory( tcVolumeDosDeviceName, sizeof(tcVolumeDosDeviceName)
);
ZeroMemory( tcDriverDosDeviceName, sizeof(tcDriverDosDeviceName)
);

if (!QueryDosDevice( tcVolumeName, tcVolumeDosDeviceName,
MAX_PATH))
{
return 0;
}

TCHAR tcLinkVolumeDosDeviceName[MAX_PATH+1];
// This is a wrapper over NtSymbolicLink
if ( SL_QuerySymbolicLink(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName, MAX_PATH + 1 )
== ERROR_SUCCESS )
_tcscpy(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName);

//
// Remove ‘\’ from device name
//
TCHAR Buffer[MAX_PATH+1];
_tcscpy(Buffer, tcVolumeDosDeviceName);

PTCHAR pcBackSlash;
do
{
pcBackSlash = _tcschr(Buffer, _T(‘\’));
if( pcBackSlash )
*pcBackSlash = _T(‘x’);
}
while( pcBackSlash );

_stprintf( tcDriverDosDeviceName, _T(“Rep%s”), _tcsninc(Buffer,
8) );
_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),
_tcsninc(tcVolumeDosDeviceName, 8) );

if
(!DefineDosDevice(DDD_RAW_TARGET_PATH,tcDriverDosDeviceName,tcRepTargetP
ath))
{
return 0;
}
else
{
_tcscpy( m_tcSSDLink, tcDriverDosDeviceName );
}

if (m_tcSSDLink[0])
{
_stprintf( tcDriverDosDeviceName, _T(“\\.\%s”),
m_tcSSDLink );

m_hSnapShot = CreateFile( tcDriverDosDeviceName, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL
);

if (m_hSnapShot==INVALID_HANDLE_VALUE)
{
return 0;
}
}
return ERROR_SUCCESS;
}

-Upanshu
-----Original Message-----
From: Peter Viscarola [mailto:xxxxx@osr.com]
Sent: Friday, September 12, 2003 1:02 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem

“Upanshu Singhal” wrote in message
news:xxxxx@ntdev…
>
> I have a file system filter driver. I am defining a dos device using

> DefineDosDevice API followed by CreateFile to open the handle to the
> newly created Symbolic link. I get error “File not found” (error # 2)
> in few cases.

To what are you directing the dos device you define? In other words,
can you show us your DefineDosDevice?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@legato.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

How do you distinguish success and error? If you’re using standard win32
headers, your function is always returning zero:

#define ERROR_SUCCESS 0L

An advice: use traces (debug prints). In every error path add trace to
report what function failed and GetLastError() result. Also, print strings
you format to see if results are correct and expected. Add traces to your
driver to see if there were attempts to open your device. Use WinObj tool to
browse object manager object to see if you device is really available.

BTW, I haven’t fully read your code but here is probably a bug:

_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),

There is only single backslash after Device.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o.
[michal.vodicka@st.com, http:://www.st.com]


From: xxxxx@legato.com[SMTP:xxxxx@legato.com]
Reply To: xxxxx@lists.osr.com
Sent: Friday, September 12, 2003 10:08 PM
To: xxxxx@lists.osr.com
Cc: xxxxx@lists.osr.com
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem

Here is the code which I am using:

Assume pszVolume = C:

TCHAR tcVolumeDosDeviceName[MAX_PATH+1];
TCHAR tcDriverDosDeviceName[MAX_PATH+1];
TCHAR tcRepTargetPath[MAX_PATH+1];
TCHAR tcVolumeName[3];

ZeroMemory( tcVolumeName, sizeof(tcVolumeName) );
_tcsncpy( tcVolumeName, pszVolume, 2 ) ;

ZeroMemory( tcVolumeDosDeviceName, sizeof(tcVolumeDosDeviceName)
);
ZeroMemory( tcDriverDosDeviceName, sizeof(tcDriverDosDeviceName)
);

if (!QueryDosDevice( tcVolumeName, tcVolumeDosDeviceName,
MAX_PATH))
{
return 0;
}

TCHAR tcLinkVolumeDosDeviceName[MAX_PATH+1];
// This is a wrapper over NtSymbolicLink
if ( SL_QuerySymbolicLink(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName, MAX_PATH + 1 )
== ERROR_SUCCESS )
_tcscpy(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName);

//
// Remove ‘\’ from device name
//
TCHAR Buffer[MAX_PATH+1];
_tcscpy(Buffer, tcVolumeDosDeviceName);

PTCHAR pcBackSlash;
do
{
pcBackSlash = _tcschr(Buffer, _T(‘\’));
if( pcBackSlash )
*pcBackSlash = _T(‘x’);
}
while( pcBackSlash );

_stprintf( tcDriverDosDeviceName, _T(“Rep%s”), _tcsninc(Buffer,
8) );
_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),
_tcsninc(tcVolumeDosDeviceName, 8) );

if
(!DefineDosDevice(DDD_RAW_TARGET_PATH,tcDriverDosDeviceName,tcRepTargetP
ath))
{
return 0;
}
else
{
_tcscpy( m_tcSSDLink, tcDriverDosDeviceName );
}

if (m_tcSSDLink[0])
{
_stprintf( tcDriverDosDeviceName, _T(“\\.\%s”),
m_tcSSDLink );

m_hSnapShot = CreateFile( tcDriverDosDeviceName, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL
);

if (m_hSnapShot==INVALID_HANDLE_VALUE)
{
return 0;
}
}
return ERROR_SUCCESS;
}

-Upanshu
-----Original Message-----
From: Peter Viscarola [mailto:xxxxx@osr.com]
Sent: Friday, September 12, 2003 1:02 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem

“Upanshu Singhal” wrote in message
> news:xxxxx@ntdev…
> >
> > I have a file system filter driver. I am defining a dos device using
>
> > DefineDosDevice API followed by CreateFile to open the handle to the
> > newly created Symbolic link. I get error “File not found” (error # 2)
> > in few cases.
>
> To what are you directing the dos device you define? In other words,
> can you show us your DefineDosDevice?
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@legato.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: michal.vodicka@st.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Michal,
Before posting code to this list, I did some modifications to
the code as I do not want to publish the actual code. In my original
code I am taking care of error handling.

_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),

This code is fine in the actual code. Yes, I will use WinObj to check
wether my device created or not.

Thanks very much for your help.

-Upanshu

-----Original Message-----
From: Michal Vodicka [mailto:xxxxx@veridicom.cz.nospam]
Sent: Friday, September 12, 2003 1:30 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem

How do you distinguish success and error? If you’re using standard win32
headers, your function is always returning zero:

#define ERROR_SUCCESS 0L

An advice: use traces (debug prints). In every error path add trace to
report what function failed and GetLastError() result. Also, print
strings you format to see if results are correct and expected. Add
traces to your driver to see if there were attempts to open your device.
Use WinObj tool to browse object manager object to see if you device is
really available.

BTW, I haven’t fully read your code but here is probably a bug:

_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),

There is only single backslash after Device.

Best regards,

Michal Vodicka
STMicroelectronics Design and Application s.r.o. [michal.vodicka@st.com,
http:://www.st.com]


From: xxxxx@legato.com[SMTP:xxxxx@legato.com]
Reply To: xxxxx@lists.osr.com
Sent: Friday, September 12, 2003 10:08 PM
To: xxxxx@lists.osr.com
Cc: xxxxx@lists.osr.com
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem

Here is the code which I am using:

Assume pszVolume = C:

TCHAR tcVolumeDosDeviceName[MAX_PATH+1];
TCHAR tcDriverDosDeviceName[MAX_PATH+1];
TCHAR tcRepTargetPath[MAX_PATH+1];
TCHAR tcVolumeName[3];

ZeroMemory( tcVolumeName, sizeof(tcVolumeName) );
_tcsncpy( tcVolumeName, pszVolume, 2 ) ;

ZeroMemory( tcVolumeDosDeviceName, sizeof(tcVolumeDosDeviceName)
);
ZeroMemory( tcDriverDosDeviceName, sizeof(tcDriverDosDeviceName)
);

if (!QueryDosDevice( tcVolumeName, tcVolumeDosDeviceName,
MAX_PATH))
{
return 0;
}

TCHAR tcLinkVolumeDosDeviceName[MAX_PATH+1];
// This is a wrapper over NtSymbolicLink
if ( SL_QuerySymbolicLink(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName, MAX_PATH + 1 )
== ERROR_SUCCESS )
_tcscpy(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName);

//
// Remove ‘\’ from device name
//
TCHAR Buffer[MAX_PATH+1];
_tcscpy(Buffer, tcVolumeDosDeviceName);

PTCHAR pcBackSlash;
do
{
pcBackSlash = _tcschr(Buffer, _T(‘\’));
if( pcBackSlash )
*pcBackSlash = _T(‘x’);
}
while( pcBackSlash );

_stprintf( tcDriverDosDeviceName, _T(“Rep%s”), _tcsninc(Buffer,
8) );
_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),
_tcsninc(tcVolumeDosDeviceName, 8) );

if
(!DefineDosDevice(DDD_RAW_TARGET_PATH,tcDriverDosDeviceName,tcRepTarge
tP
ath))
{
return 0;
}
else
{
_tcscpy( m_tcSSDLink, tcDriverDosDeviceName );
}

if (m_tcSSDLink[0])
{
_stprintf( tcDriverDosDeviceName, _T(“\\.\%s”),
m_tcSSDLink );

m_hSnapShot = CreateFile( tcDriverDosDeviceName, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL
);

if (m_hSnapShot==INVALID_HANDLE_VALUE)
{
return 0;
}
}
return ERROR_SUCCESS;
}

-Upanshu
-----Original Message-----
From: Peter Viscarola [mailto:xxxxx@osr.com]
Sent: Friday, September 12, 2003 1:02 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: DefineDosDevice & DiskPerf problem

“Upanshu Singhal” wrote in message
> news:xxxxx@ntdev…
> >
> > I have a file system filter driver. I am defining a dos device
> > using
>
> > DefineDosDevice API followed by CreateFile to open the handle to the
> > newly created Symbolic link. I get error “File not found” (error #
2)
> > in few cases.
>
> To what are you directing the dos device you define? In other words,
> can you show us your DefineDosDevice?
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@legato.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: michal.vodicka@st.com To
> unsubscribe send a blank email to xxxxx@lists.osr.com
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@legato.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi,
I have a file system filter driver. I am defining a dos device using
DefineDosDevice API followed by CreateFile to open the handle to the
newly created Symbolic link. I get error “File not found” (error # 2) in
few cases.

If I disable Disk Performance monitor using “DiskPerf -NV” followed by
reboot, problem does not appear. This happen only after installation of
Veritas Volume Manager. Even if I uninstall Veritas Volume Manager,
problem still exists until & unless I disable the Disk Performance
monitor.

If I do not have Veritas Volume Manager at all, then I do not see any
problem.
Can any one tell me the relationship between DefineDosDevie API & Disk
Performance monitor? Is this a non problem, or do I need to make changes
to my existing code.

Here is the code which I am using:

Assume pszVolume = C:

TCHAR tcVolumeDosDeviceName[MAX_PATH+1];
TCHAR tcDriverDosDeviceName[MAX_PATH+1];
TCHAR tcRepTargetPath[MAX_PATH+1];
TCHAR tcVolumeName[3];
ZeroMemory( tcVolumeName, sizeof(tcVolumeName) );
_tcsncpy( tcVolumeName, pszVolume, 2 ) ;

ZeroMemory( tcVolumeDosDeviceName, sizeof(tcVolumeDosDeviceName) );
ZeroMemory( tcDriverDosDeviceName, sizeof(tcDriverDosDeviceName) );
if (!QueryDosDevice( tcVolumeName, tcVolumeDosDeviceName, MAX_PATH))
{
return -1;
}

TCHAR tcLinkVolumeDosDeviceName[MAX_PATH+1];
// This is a wrapper over NtSymbolicLink
if ( SL_QuerySymbolicLink(tcVolumeDosDeviceName,
tcLinkVolumeDosDeviceName, MAX_PATH + 1 )
== ERROR_SUCCESS )
_tcscpy(tcVolumeDosDeviceName, tcLinkVolumeDosDeviceName);
//
// Remove ‘\’ from device name
//
TCHAR Buffer[MAX_PATH+1];
_tcscpy(Buffer, tcVolumeDosDeviceName);
PTCHAR pcBackSlash;
do
{
pcBackSlash = _tcschr(Buffer, _T(‘\’));
if( pcBackSlash )
*pcBackSlash = _T(‘x’);
}
while( pcBackSlash );
_stprintf( tcDriverDosDeviceName, _T(“Rep%s”), _tcsninc(Buffer, 8) );
_stprintf( tcRepTargetPath, _T(“\Device\XYZ\%s”),
_tcsninc(tcVolumeDosDeviceName, 8) );
if
(!DefineDosDevice(DDD_RAW_TARGET_PATH,tcDriverDosDeviceName,tcRepTargetP
ath))
{
return -1;
}
else
{
_tcscpy( m_tcSSDLink, tcDriverDosDeviceName );
}
if (m_tcSSDLink[0])
{
_stprintf( tcDriverDosDeviceName, _T(“\\.\%s”), m_tcSSDLink );
m_hSnapShot = CreateFile( tcDriverDosDeviceName, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL );
if (m_hSnapShot==INVALID_HANDLE_VALUE)
{
return -1;
}
}
return ERROR_SUCCESS;
}

Please respond.

Thanks,
-Upanshu

xxxxx@legato.com



<425-653-7028 - Work>
<425-558-0622 - Home>