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 FS_H
18#define FS_H
19
20#include "fatblock.h"
21#include "fat.h"
22
23struct fs {
24	uint16_t cluster_size;
25
26	cluster_t num_clusters;
27	cluster_t next_cluster;
28	struct extent *extents;
29
30	struct fat_boot_sector boot;
31	struct extent boot_extent;
32	struct extent backup_boot_extent;
33
34	struct fat_info_sector info;
35	struct extent info_extent;
36
37	struct extent fat_extent;
38	fat_entry_t *fat;
39	offset_t fat_size;
40
41	offset_t data_offset;
42};
43
44int fs_alloc_extent(struct fs *fs, struct extent *extent,
45                    offset_t len, int type, cluster_t *first_cluster_out);
46struct extent *fs_find_extent(struct fs *fs, offset_t start, offset_t len, struct extent *last,
47                              offset_t *r_start_out, offset_t *e_start_out, offset_t *len_out);
48int fs_init(struct fs *fs, uint16_t cluster_size, offset_t data_size, offset_t *total_size_out);
49void fs_set_rootdir_start(struct fs *fs, cluster_t rootdir_start);
50void fs_update_free_clusters(struct fs *fs);
51
52#endif
53