Annotation of qemu/roms/openbios/fs/ext2/ext2_mount.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *
                      3:  * (c) 2008-2009 Laurent Vivier <[email protected]>
                      4:  *
                      5:  * This file has been copied from EMILE, http://emile.sf.net
                      6:  *
                      7:  */
                      8: 
                      9: #include "libext2.h"
                     10: #include "ext2.h"
                     11: #include "ext2_utils.h"
                     12: 
                     13: #define SB_OFFSET (2)
                     14: 
                     15: ext2_VOLUME* ext2_mount(int fd)
                     16: {
                     17:        ext2_VOLUME *volume;
                     18:        struct ext2_super_block *super;
                     19:        char *buffer;
                     20: 
                     21:        super = (struct ext2_super_block*)malloc(sizeof(struct ext2_super_block));
                     22:        if (super == NULL)
                     23:                return NULL;
                     24: 
                     25:        ext2_get_super(fd, super);
                     26:        if (super->s_magic != EXT2_SUPER_MAGIC) {
                     27:                free(super);
                     28:                return NULL;
                     29:        }
                     30: 
                     31:        buffer = (char*)malloc(EXT2_BLOCK_SIZE(super));
                     32:        if (buffer == NULL) {
                     33:                free(super);
                     34:                return NULL;
                     35:        }
                     36: 
                     37:        volume = (ext2_VOLUME*)malloc(sizeof(ext2_VOLUME));
                     38:        if (volume == NULL) {
                     39:                free(super);
                     40:                free(buffer);
                     41:                return NULL;
                     42:        }
                     43: 
                     44:        volume->buffer = buffer;
                     45:        volume->fd = fd;
                     46:        volume->super = super;
                     47: 
                     48:        volume->current = -1;
                     49:        ext2_read_block(volume, 0);
                     50: 
                     51:        return volume;
                     52: }
                     53: 
                     54: int ext2_umount(ext2_VOLUME* volume)
                     55: {
                     56:        if (volume == NULL)
                     57:                return -1;
                     58:        free(volume->super);
                     59:        free(volume->buffer);
                     60:        free(volume);
                     61:        return 0;
                     62: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.