RAW File System - Read write from user space ??

Hi,
I have written this code to write on to a removable disk without a file
system on it.

void main(void)
{
HANDLE FileHandle;
BOOL Status = TRUE;
unsigned long BytesWritten = 0;
FileHandle = CreateFile(“\\.\f:”,
( GENERIC_READ | GENERIC_WRITE ),
( FILE_SHARE_READ | FILE_SHARE_WRITE ),
NULL,
OPEN_EXISTING,
0,
NULL
);
if (FileHandle == INVALID_HANDLE_VALUE)
{
printf(“error is %d \n”,GetLastError());
return ;
}

Status = WriteFile(FileHandle,“nwebuf”,6,&BytesWritten,NULL);

printf(“status is %d get last error is %d \n”,Status,GetLastError());

CloseHandle(FileHandle);

return ;

}

but writefile returns an error of 87 (Invalid parameter).
My question is can writefile be used to access the volume in this way?
If not, is there a way to do a write onto the raw disk from user space?

Thanks,
Chhavi

Chhavi£¬

When writing a volume, you must specify SECTOR_SIZE (512 bytes) aligned Offset and Count.

For you case, you wrote 6 bytes. The least count to be written is a SECTOR_SIZE.

Best wishes,

Matt
http://sys.xiloo.com

On 2002-08-02, you wrote:
= = = = = = = = = = = = = = = = = = = =

>Hi,
> I have written this code to write on to a removable disk without a file
>system on it.
>
>void main(void)
>{
> HANDLE FileHandle;
> BOOL Status = TRUE;
> unsigned long BytesWritten = 0;
> FileHandle = CreateFile(“\\.\f:”,
> ( GENERIC_READ | GENERIC_WRITE ),
> ( FILE_SHARE_READ | FILE_SHARE_WRITE ),
> NULL,
> OPEN_EXISTING,
> 0,
> NULL
> );
> if (FileHandle == INVALID_HANDLE_VALUE)
> {
> printf(“error is d \n”,GetLastError());
> return ;
> }
>
> Status = WriteFile(FileHandle,“nwebuf”,6,&BytesWritten,NULL);
>
> printf(“status is d get last error is d \n”,Status,GetLastError());
>
> CloseHandle(FileHandle);
>
> return ;
>
>
>
>}
>
>but writefile returns an error of 87 (Invalid parameter).
>My question is can writefile be used to access the volume in this way?
>If not, is there a way to do a write onto the raw disk from user space?
>
>Thanks,
>Chhavi
>
>
>—
>You are currently subscribed to ntfsd as: mattwu@163.com
>To unsubscribe send a blank email to %%email.unsub%%
>.

= = = = = = = = = = = = = = = = = = = =

When you do volume DASD access, every IO must be physical block aligned
(512, 2048 etc.).

Jing

xxxxx@lists.osr.com writes:

Hi,
I have written this code to write on to a removable disk without a file
system on it.

void main(void)
{
HANDLE FileHandle;
BOOL Status = TRUE;
unsigned long BytesWritten = 0;
FileHandle = CreateFile(“\\.\f:”,
( GENERIC_READ | GENERIC_WRITE ),
( FILE_SHARE_READ | FILE_SHARE_WRITE ),
NULL,
OPEN_EXISTING,
0,
NULL
);
if (FileHandle == INVALID_HANDLE_VALUE)
{
printf(“error is %d \n”,GetLastError());
return ;
}

Status = WriteFile(FileHandle,“nwebuf”,6,&BytesWritten,NULL);

printf(“status is %d get last error is %d \n”,Status,GetLastError());

CloseHandle(FileHandle);

return ;

}

but writefile returns an error of 87 (Invalid parameter).
My question is can writefile be used to access the volume in this way?
If not, is there a way to do a write onto the raw disk from user space?

Thanks,
Chhavi