1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef FATBLOCK_H 18#define FATBLOCK_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include "fdpool.h" 24 25typedef uint64_t offset_t; 26 27typedef enum { 28 EXTENT_TYPE_BOOT, 29 EXTENT_TYPE_INFO, 30 EXTENT_TYPE_FAT, 31 EXTENT_TYPE_FILE, 32 EXTENT_TYPE_DIR 33} extent_type; 34 35struct extent { 36 offset_t start; 37 offset_t len; 38 extent_type type; 39 40 struct extent *next; 41}; 42 43struct file { 44 struct extent extent; 45 46 char *path; 47 uint32_t size; 48 49 dev_t dev; 50 ino_t ino; 51 time_t mtime; 52 53 struct pooled_fd pfd; 54}; 55 56struct dir { 57 struct extent extent; 58 59 char *path; 60 uint32_t size; 61 62 struct fat_dirent *entries; 63}; 64 65struct fs; 66 67int import_tree(struct fs *fs, char *path); 68int fs_read(struct fs *fs, char *buf, offset_t start, offset_t len); 69 70#define MALLOC_FAIL (-41) /* memory allocation failed somewhere. */ 71#define SKY_IS_FALLING (-42) /* One of the files changed out from under us. */ 72 73#endif 74