URI: 
       tzeropart.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tzeropart.c (707B)
       ---
            1 #include "stdinc.h"
            2 #include "dat.h"
            3 #include "fns.h"
            4 
            5 void
            6 zeropart(Part *part, int blocksize)
            7 {
            8         ZBlock *b;
            9         u64int addr;
           10         int w;
           11 
           12         fprint(2, "clearing %s\n", part->name);
           13         b = alloczblock(MaxIoSize, 1, blocksize);
           14 
           15         w = 0;
           16         for(addr = PartBlank; addr + MaxIoSize <= part->size; addr += MaxIoSize){
           17                 if(writepart(part, addr, b->data, MaxIoSize) < 0)
           18                         sysfatal("can't initialize %s, writing block %d failed: %r", part->name, w);
           19                 w++;
           20         }
           21 
           22         for(; addr + blocksize <= part->size; addr += blocksize)
           23                 if(writepart(part, addr, b->data, blocksize) < 0)
           24                         sysfatal("can't initialize %s: %r", part->name);
           25 
           26         if(flushpart(part) < 0)
           27                 sysfatal("can't flush writes to %s: %r", part->name);
           28 
           29         freezblock(b);
           30 }