sharing violation accessing drive x:

sharing violation accessing drive x:

Post by Nuno Ventur » Wed, 06 Aug 2003 22:59:22



Hi.
I have a PC with MS-DOS 6.22 with basic network client TCP/IP (MS) maping a
drive o a XP PC.
My program writen in BorlandC appends data to a file on the shared drive.
That file is opened read-only by the XP machine and after that is deleted.
The program in the DOS PC makes somethink like this:

FILE *fplog;
...
fplog=fopen("d:\\mylog.txt","at"); //remote file on shared disk
if(fplog!=NULL)
    fprinf(fplog,"Some text");
else {
    fplog=fopen("c:\\mylog.txt","at");//local file
    if(fplog!=NULL)
        fprinf(fplog,"Some text");
    else
        //error message

Quote:}

fclose(fplog);

When I have a problem in the network it saves the local file, otherwise it
appends the network file if the file is closed or if is opened by the XP.
The problem must be when the xp deletes the file when the DOS tries to
append it.
The append its event drived, it writes the file whereever some event ocours
and the delete is time drived, that means every minute the program reads the
events, copy to database and delete the file.

The question is how do I trap the error from inside my C program ? If I can
get the error, I can write to my localfile, and I have the problem solved.
But know I get a OS error and the program crashes. The error is in
portuguese (Erro de viola??o de partilha acedendo a drive D:) but the
translation should be something like the subject.
Thanks
Nuno Ventura

 
 
 

sharing violation accessing drive x:

Post by Alex Russel » Thu, 07 Aug 2003 01:02:31



Quote:> Hi.
> I have a PC with MS-DOS 6.22 with basic network client TCP/IP (MS) maping
a
> drive o a XP PC.
> My program writen in BorlandC appends data to a file on the shared drive.
> That file is opened read-only by the XP machine and after that is deleted.
> The program in the DOS PC makes somethink like this:

> FILE *fplog;
> ...
> fplog=fopen("d:\\mylog.txt","at"); //remote file on shared disk
> if(fplog!=NULL)
>     fprinf(fplog,"Some text");
> else {
>     fplog=fopen("c:\\mylog.txt","at");//local file
>     if(fplog!=NULL)
>         fprinf(fplog,"Some text");
>     else
>         //error message
> }
> fclose(fplog);

> When I have a problem in the network it saves the local file, otherwise it
> appends the network file if the file is closed or if is opened by the XP.
> The problem must be when the xp deletes the file when the DOS tries to
> append it.
> The append its event drived, it writes the file whereever some event
ocours
> and the delete is time drived, that means every minute the program reads
the
> events, copy to database and delete the file.

> The question is how do I trap the error from inside my C program ? If I
can
> get the error, I can write to my localfile, and I have the problem solved.
> But know I get a OS error and the program crashes. The error is in
> portuguese (Erro de viola??o de partilha acedendo a drive D:) but the
> translation should be something like the subject.
> Thanks
> Nuno Ventura

You can trap the error using harderr() and hardresume(). These Borland RTL
functions wrapp around a int24x handler. int24x is the "critical error"
handler that generates the "abort, retry, fail" messages.

this is how the handler is installed:
harderr(thandler);

Here is a sample function (includes some calls to a dos text mode windoing
lib, eg twput)
You can make your function do whatever you like, BUT be careful. There are
strict limits on calling DOS functions inside the handler. Google for int24
for more info.

/* ----------------------- thandler() --------------------- April 12,1991 */
int thandler(int errval, int ax, int bp, int si)
{
   int di, drive, err_no, a, old_id, cx, cy;
   awindow_t *w1;
   char temp[90];
   static char *err_mess[]={
      "Write Protect",
      "Unkown unit",
      "Drive not ready",
      "Unkown command",
      "Data error (CRC)",
      "Bad request",
      "Seek error",
      "Unkown media type",
      "Sector not found",
      "Printer out of paper",
      "Write fault",
      "Read fault",
      "General failure",
      "na",
      "na",
      "Invalid disk change"
      };

   di=_DI;

   if ( ax < 0 )  /* not a disk error */
      {
      strcpy(temp, "Device error");
      }
   else  /* disk error */
      {
      drive=(ax & 0xff) + 'A';
      err_no=di & 0xff;
      sprintf(temp, "ERROR : drive %c: %s", drive, err_mess[err_no]);
      }

   cx=wherex();
   cy=wherey();
   _setcursortype(_NOCURSOR);
   old_id=gb_currt->id;
   a=strlen(temp)+4;
   if ( a < 30 )
      a=30;
   w1=create_awindow(a, 7, 0x0f, 1);
   push_twindow(w1, (80-a)>>1,5, TRUE, 25011);

   twput(-1, 2, 0x0f, temp);
   twput(-1, 4, 0x0f, "Press R)etry, A)bort to DOS");
   do
      {
      a=getk();
      a=toupper(a);
      }
   while ( !( a == 'A' || a == 'R' ) );
   pop_twindow();
   select_twindow(old_id);
   free(w1);

   a= a =='A' ? 2 : 1;
   _setcursortype(_NORMALCURSOR);
   gotoxy(cx,cy);
   hardresume(a);

   return(a);

Quote:}

--
Alex Russell


 
 
 

1. Sharing Violation Reading Drive C:

For the past few months I've been getting a lot of "Sharing Violation
Reading Drive C:" error messages.  It seems to be getting worse.

There is nothing special about my hardware.  It's a Gateway2000 486/33mhz,
250meg hard drive (whatever brand it normally is).  It's all one big
partition.  We do run some fairly disk intensive programs on it (accounting
software), but I rarely get a message using it.  It seems to always come
when I want to delete a file(s).  If I answer 'F'ail to the message the
command quits normally (does what it should have).

Once in awhile (when I'm having the problem), the disk really slows down.
I was also told by a support person (over the phone) that it seems like a
system this fast was installing their software very very slowly.

Following is a copy of the autoexec.bat & config.sys.  Any help you can give
me would be very appreciated.  If I can't get this solved, I'm gonna format
the drive and reinstall everything.  Hopefully that works.  Oh ya!  I'm using
MS-DOS 5.0.

Thanx!

Dave

[config.sys]
install=c:\dos\share.exe /f:4096 /l:750
buffers=4
device=c:\windows\himem.sys
dos=high
stacks=9,256
files=40
device=c:\dos\setver.exe

[autoexec.bat]
set temp=c:\temp
c:\dos\smartdrve c /q
c:\dos\fastopen c: 30
c:\vga\vgamode 72 60non-interlace
set fxconf88=c:\fx
set ofc_adv=c:\fastdata
break=on
set workstation=1
prompt $p$g
c:\msmouse\mouse
mirror c: /tc

That's it!

2. Vim6.0: Folding problem

3. Shared Violation on drive C: ERROR While installing CD in Windows

4. Tools for programming games

5. Sharing Violation Reading Drive C: ?

6. Money Express will not launch

7. sharing violation

8. WTB PalmPilot or Pilot

9. share violation using copy

10. interprocess synchronization and "Sharing violation"

11. Sharing violation reading myself

12. Share Violation Problems

13. Sharing Violation Error