Skip to content

Commit

Permalink
Rationalize headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vasi committed May 31, 2014
1 parent 8c27514 commit c7045ac
Show file tree
Hide file tree
Showing 32 changed files with 213 additions and 211 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ libsquashfuse_la_SOURCES = swap.c cache.c table.c dir.c file.c fs.c \
nonstd-pread.c nonstd-stat.c \
squashfs_fs.h common.h nonstd-internal.h nonstd.h swap.h cache.h table.h \
dir.h file.h decompress.h xattr.h squashfuse.h hash.h stack.h traverse.h \
util.h
util.h fs.h
libsquashfuse_la_CPPFLAGS = $(ZLIB_CPPFLAGS) $(XZ_CPPFLAGS) $(LZO_CPPFLAGS) \
$(LZ4_CPPFLAGS)
libsquashfuse_la_LIBADD = $(ZLIB_LIBS) $(XZ_LIBS) $(LZO_LIBS) $(LZ4_LIBS)
Expand Down
2 changes: 1 addition & 1 deletion cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
#include "cache.h"

#include "squashfuse.h"
#include "fs.h"

#include <stdlib.h>

Expand Down
8 changes: 4 additions & 4 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@

#include "config.h"

#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>

#ifdef _WIN32
#include <win32.h>
#else
#include <sys/stat.h>
typedef mode_t sqfs_mode_t;
typedef uid_t sqfs_id_t;
typedef off_t sqfs_off_t;
typedef int sqfs_fd_t;
#endif

#include <stdint.h>
#include <sys/types.h>

typedef enum {
SQFS_OK,
SQFS_ERR,
Expand Down
2 changes: 1 addition & 1 deletion decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
#include "decompress.h"

#include "squashfuse.h"
#include "squashfs_fs.h"

#include <string.h>

Expand Down
5 changes: 3 additions & 2 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
*/
#include "dir.h"

#include "fs.h"
#include "swap.h"

#include <string.h>
#include <sys/stat.h>

#include "squashfuse.h"

/* Read some directory metadata, updating the dir structure as necessary */
static sqfs_err sqfs_dir_md_read(sqfs *fs, sqfs_dir *dir, void *buf,
size_t size);
Expand Down
2 changes: 0 additions & 2 deletions dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

#include "common.h"

#include <stdbool.h>

#include "squashfs_fs.h"

typedef struct {
Expand Down
10 changes: 5 additions & 5 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
*/
#include "file.h"

#include <stddef.h>
#include "fs.h"
#include "swap.h"
#include "table.h"

#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>

#include "squashfuse.h"

sqfs_err sqfs_frag_entry(sqfs *fs, struct squashfs_fragment_entry *frag,
uint32_t idx) {
Expand Down
3 changes: 1 addition & 2 deletions file.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@

#include "common.h"

#include <stdbool.h>
#include "squashfs_fs.h"

#include "cache.h"
#include "squashfs_fs.h"

sqfs_err sqfs_frag_entry(sqfs *fs, struct squashfs_fragment_entry *frag,
uint32_t idx);
Expand Down
8 changes: 5 additions & 3 deletions fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "squashfuse.h"
#include "fs.h"

#include "file.h"
#include "nonstd.h"
#include "swap.h"
#include "xattr.h"

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>


#define DATA_CACHED_BLKS 1
#define FRAG_CACHED_BLKS 3

Expand Down
134 changes: 134 additions & 0 deletions fs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2012 Dave Vasilevsky <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQFS_FS_H
#define SQFS_FS_H

#include "common.h"

#include "squashfs_fs.h"

#include "cache.h"
#include "decompress.h"
#include "table.h"

struct sqfs {
sqfs_fd_t fd;
struct squashfs_super_block sb;
sqfs_table id_table;
sqfs_table frag_table;
sqfs_table export_table;
sqfs_cache md_cache;
sqfs_cache data_cache;
sqfs_cache frag_cache;
sqfs_cache blockidx;
sqfs_decompressor decompressor;

struct squashfs_xattr_id_table xattr_info;
sqfs_table xattr_table;
};

typedef uint32_t sqfs_xattr_idx;
struct sqfs_inode {
struct squashfs_base_inode base;
int nlink;
sqfs_xattr_idx xattr;

sqfs_md_cursor next;

union {
struct {
int major, minor;
} dev;
size_t symlink_size;
struct {
uint64_t start_block;
uint64_t file_size;
uint32_t frag_idx;
uint32_t frag_off;
} reg;
struct {
uint32_t start_block;
uint16_t offset;
uint32_t dir_size;
uint16_t idx_count;
uint32_t parent_inode;
} dir;
} xtra;
};

void sqfs_version_supported(int *min_major, int *min_minor, int *max_major,
int *max_minor);

/* Number of groups of size 'group' required to hold size 'total' */
size_t sqfs_divceil(uint64_t total, size_t group);


sqfs_err sqfs_init(sqfs *fs, sqfs_fd_t fd);
void sqfs_destroy(sqfs *fs);

/* Ok to call these even on incompletely constructed filesystems */
void sqfs_version(sqfs *fs, int *major, int *minor);
sqfs_compression_type sqfs_compression(sqfs *fs);


void sqfs_md_header(uint16_t hdr, bool *compressed, uint16_t *size);
void sqfs_data_header(uint32_t hdr, bool *compressed, uint32_t *size);

sqfs_err sqfs_block_read(sqfs *fs, sqfs_off_t pos, bool compressed, uint32_t size,
size_t outsize, sqfs_block **block);
void sqfs_block_dispose(sqfs_block *block);

sqfs_err sqfs_md_block_read(sqfs *fs, sqfs_off_t pos, size_t *data_size,
sqfs_block **block);
sqfs_err sqfs_data_block_read(sqfs *fs, sqfs_off_t pos, uint32_t hdr,
sqfs_block **block);

/* Don't dispose after getting block, it's in the cache */
sqfs_err sqfs_md_cache(sqfs *fs, sqfs_off_t *pos, sqfs_block **block);
sqfs_err sqfs_data_cache(sqfs *fs, sqfs_cache *cache, sqfs_off_t pos,
uint32_t hdr, sqfs_block **block);

void sqfs_md_cursor_inode(sqfs_md_cursor *cur, sqfs_inode_id id, sqfs_off_t base);

sqfs_err sqfs_md_read(sqfs *fs, sqfs_md_cursor *cur, void *buf, size_t size);


sqfs_err sqfs_inode_get(sqfs *fs, sqfs_inode *inode, sqfs_inode_id id);

sqfs_mode_t sqfs_mode(int inode_type);
sqfs_err sqfs_id_get(sqfs *fs, uint16_t idx, sqfs_id_t *id);

/* Puts up to *size characters of the link name into buf. Always null-
* terminates the buffer. Pass null as buf to have the size returned. */
sqfs_err sqfs_readlink(sqfs *fs, sqfs_inode *inode, char *buf, size_t *size);

/* Find inode_id by inode_num */
int sqfs_export_ok(sqfs *fs);
sqfs_err sqfs_export_inode(sqfs *fs, sqfs_inode_num n, sqfs_inode_id *i);

/* Find the root inode */
sqfs_inode_id sqfs_inode_root(sqfs *fs);

#endif
7 changes: 1 addition & 6 deletions fuseprivate.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "fuseprivate.h"

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <fuse.h>

#include "fuseprivate.h"
#include "nonstd.h"

sqfs_err sqfs_stat(sqfs *fs, sqfs_inode *inode, struct stat *st) {
Expand Down
5 changes: 4 additions & 1 deletion fuseprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
#ifndef SQFS_FUSEPRIVATE_H
#define SQFS_FUSEPRIVATE_H

#include <sys/stat.h>
#include "squashfuse.h"

#include <fuse.h>

#include <sys/stat.h>

/* Common functions for FUSE high- and low-level clients */

/* Fill in a stat structure. Does not set st_ino */
Expand Down
1 change: 0 additions & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

static sqfs_err sqfs_hash_add_internal(sqfs_hash *h, int doubling,
sqfs_hash_key k, sqfs_hash_value v) {
Expand Down
15 changes: 4 additions & 11 deletions hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "squashfuse.h"
#include "fuseprivate.h"

#include "nonstd.h"

#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>

#include <fuse.h>
#include "fuseprivate.h"
#include "squashfuse.h"
#include "nonstd.h"
#include "util.h"

typedef struct sqfs_hl sqfs_hl;
struct sqfs_hl {
Expand Down
15 changes: 4 additions & 11 deletions ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,16 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ll.h"
#include "fuseprivate.h"

#include "nonstd.h"

#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>

#include "ll.h"
#include "squashfuse.h"
#include "nonstd.h"
#include "fuseprivate.h"
#include "util.h"

static const double SQFS_TIMEOUT = DBL_MAX;

Expand Down
5 changes: 2 additions & 3 deletions ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
#ifndef SQFS_LL_H
#define SQFS_LL_H

#include "config.h"
#include <fuse_lowlevel.h>

#include "squashfuse.h"

#include <fuse_lowlevel.h>

typedef struct sqfs_ll sqfs_ll;
struct sqfs_ll {
sqfs fs;
Expand Down
3 changes: 1 addition & 2 deletions ll_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ll.h"

#include "hash.h"
#include "nonstd.h"

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Expand Down
Loading

0 comments on commit c7045ac

Please sign in to comment.