[NCLUG] newbie::Write to superblocks

Sean Reifschneider jafo-nclug at tummy.com
Tue Jul 31 19:51:40 MDT 2001


On Tue, Jul 31, 2001 at 04:09:06PM -0600, Michael Dwyer wrote:
>> int fd = open(afile, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0644);
>> int n1, n2, n3;
>> ....
>> off64_t offset = (off64_t) (n1*n2*n3*sizeof(float)); 
>> if(lseek64(fd, offset, SEEK_SET) != offset) exit(-1);
>> write(fd, blablah...);
>
>Unless you run your programs as root, this should not 
>have destroyed superblocks.  lseek (and presumably lseek64)

To be precise, unless you ran it as root *AND* you specified the file
"/dev/hda" or the like...  Simply running as root and doing a large
negative seek on a file will just fail.

Sean
-- 
 The early bird may get the worm, but the second mouse gets the cheese.
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python



More information about the NCLUG mailing list