PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/filesystems/unixfs/minixfs/itree_v1.c

http://macfuse.googlecode.com/
C | 69 lines | 47 code | 11 blank | 11 comment | 9 complexity | 107f82b119ab256fc26685cd34a2fe67 MD5 | raw file
 1/*
 2 * Minix File System Famiy for MacFUSE
 3 * Amit Singh
 4 * http://osxbook.com
 5 *
 6 * Most of the code in this file comes from the Linux kernel implementation
 7 * of the minix file system. See fs/minix/ in the Linux kernel source tree.
 8 *
 9 * The code is Copyright (c) its various authors. It is covered by the
10 * GNU GENERAL PUBLIC LICENSE Version 2.
11 */
12
13#include <linux/buffer_head.h>
14#include "minixfs.h"
15
16enum { DEPTH = 3, DIRECT = 7 };    /* Only double indirect */
17
18typedef u16 block_t;    /* 16 bit, host order */
19
20static inline unsigned long block_to_cpu(block_t n)
21{
22    return n;
23}
24
25static inline block_t cpu_to_block(unsigned long n)
26{
27    return n;
28}
29
30static inline block_t* i_data(struct inode* inode)
31{
32    return (block_t *)minix_i(inode)->u.i1_data;
33}
34
35static int block_to_path(struct inode* inode, long block, int offsets[DEPTH])
36{
37    int n = 0;
38
39    if (block < 0) {
40        printk("MINIX-fs: block_to_path: block %ld < 0\n", block);
41    } else if (block >= (minix_sb(inode->I_sb)->s_max_size/BLOCK_SIZE)) {
42        if (0)
43            printk("MINIX-fs: block_to_path: block %ld too bign", block);
44    } else if (block < 7) {
45        offsets[n++] = block;
46    } else if ((block -= 7) < 512) {
47        offsets[n++] = 7;
48        offsets[n++] = block;
49    } else {
50        block -= 512;
51        offsets[n++] = 8;
52        offsets[n++] = block >> 9;
53        offsets[n++] = block & 511;
54    }
55    return n;
56}
57
58#include "itree_common.c"
59
60int
61minix_get_block_v1(struct inode* inode, sector_t iblock, off_t* result)
62{
63    return get_block(inode, iblock, result);
64}
65
66unsigned V1_minix_blocks(loff_t size, struct super_block* sb)
67{
68    return nblocks(size, sb);
69}