kern

diff fstools/mkfs/mkfs.c @ 93:083849df660b

split the system call implementations out of fs.c into fs_sys.c
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 11 Dec 2011 10:17:58 +0200
parents 7ff2b4971216
children
line diff
     1.1 --- a/fstools/mkfs/mkfs.c	Fri Dec 09 15:29:54 2011 +0200
     1.2 +++ b/fstools/mkfs/mkfs.c	Sun Dec 11 10:17:58 2011 +0200
     1.3 @@ -47,10 +47,12 @@
     1.4  {
     1.5  	struct superblock *sb;
     1.6  
     1.7 -	if(!(sb = malloc(BLKSZ))) {
     1.8 -		perror("failed to allocate memory");
     1.9 -		return -1;
    1.10 -	}
    1.11 +	sb = malloc(BLKSZ);
    1.12 +	assert(sb);
    1.13 +
    1.14 +	sb->magic = MAGIC;
    1.15 +	sb->ver = 0;
    1.16 +	sb->num_blocks = nblocks;
    1.17  }
    1.18  
    1.19  uint32_t get_block_count(int fd, int blksize)
    1.20 @@ -84,23 +86,23 @@
    1.21  	return 0;
    1.22  }
    1.23  
    1.24 -int user_readblock(int dev, uint32_t blk, void *buf)
    1.25 +int blk_read(void*, uint32_t blk, int count, void *buf)
    1.26  {
    1.27  	if(lseek(fd, blk * BLKSZ, SEEK_SET) == -1) {
    1.28  		return -1;
    1.29  	}
    1.30 -	if(read(fd, buf, BLKSZ) < BLKSZ) {
    1.31 +	if(read(fd, buf, BLKSZ * count) < BLKSZ * count) {
    1.32  		return -1;
    1.33  	}
    1.34  	return 0;
    1.35  }
    1.36  
    1.37 -int user_writeblock(int dev, uint32_t blk, void *buf)
    1.38 +int blk_write(void*, uint32_t blk, int count, void *buf)
    1.39  {
    1.40  	if(lseek(fd, blk * BLKSZ, SEEK_SET) == -1) {
    1.41  		return -1;
    1.42  	}
    1.43 -	if(write(fd, buf, BLKSZ) < BLKSZ) {
    1.44 +	if(write(fd, buf, BLKSZ * count) < BLKSZ * count) {
    1.45  		return -1;
    1.46  	}
    1.47  	return 0;