Changeset e272949 in mainline for uspace/lib/ext2/libext2_superblock.c


Ignore:
Timestamp:
2011-02-13T20:27:30Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
566c401
Parents:
36bca8eb
Message:

Refactor direct reading of superblock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext2/libext2_superblock.c

    r36bca8eb re272949  
    3535
    3636#include "libext2.h"
     37#include <errno.h>
     38#include <malloc.h>
     39#include <libblock.h>
    3740
    3841/**
     
    104107
    105108
     109/** Read a superblock directly from device (i.e. no libblock cache)
     110 *
     111 * @param devmap_handle Device handle of the block device.
     112 * @param superblock    Pointer where to store pointer to new superblock
     113 *
     114 * @return              EOK on success or negative error code on failure.
     115 */
     116int ext2_superblock_read_direct(devmap_handle_t devmap_handle,
     117    ext2_superblock_t **superblock)
     118{
     119        void *data;
     120        int rc;
     121       
     122        data = malloc(EXT2_SUPERBLOCK_SIZE);
     123        if (data == NULL) {
     124                return ENOMEM;
     125        }
     126       
     127        rc = block_read_bytes_direct(devmap_handle, EXT2_SUPERBLOCK_OFFSET,
     128            EXT2_SUPERBLOCK_SIZE, data);
     129        if (rc != EOK) {
     130                free(data);
     131                return rc;
     132        }
     133       
     134        (*superblock) = data;
     135        return EOK;
     136}
     137
     138
    106139/** @}
    107140 */
Note: See TracChangeset for help on using the changeset viewer.