[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

minix fs syncer



Hi all!

After several crashes of my working partition ;-( I decided to write this little
utility: it sends a 'SIGALRM' to the 'update' demon of minix fs, causing it to
sync tthe fs'.

SIGALRM was the natural choice, since Steven uses Talarm() to schedule fs
syncing.

P.s.: I crashed my fs' cause I write a SCSI driver, which fiddles with the
interrupt vectors. When this is done before a sync occured, Minix fs can't
write
on the partition at the next update(), so I loose...
I hope, Steven includes this one (or a similar one) in his releases, since a use
of this before doing anything possibly harmful (e.g. power off, reset button)
might well save your work ;-))

Here's the listing:
-----------------------------8<-------------------------------------------------
#include <mintbind.h>
#include <signal.h>

/* This is a simple minix-fs syncer. It sends SIGALRM to the
   'update' process. Since this signal is captured, it causes
   a sync on the fs'. */

const char update[]="U:\\proc\\update.*";

int main()
{
  int upid;
  _DTA dta;

  Fsetdta(&dta);
  if(!Fsfirst(update,0))
    {
      upid=atoi(&(dta.dta_name[strlen(dta.dta_name)-3]));       /* The
process ID is in the 3-byte extension */
      Pkill(upid,SIGALRM);
      printf("update demon notified. File systems are being synced.\n");
    }
  else printf("No update demon running. No sync performed.\n");
}
-----------------------8<-------------------------------------------------------
Greetings, Joe

    email: hessdorf@sun.ph-cip.uni-koeln.de
               
    snail mail:
       Joerg Hessdoerfer  | Remember: warranty void if seal is broken!
       Niehler Str. 332   | (broken seal)
       BRD 5000 Koeln 60
               
    Telephone: (Germany) 0221/714178 (home) or 02203/6013335 (office)