/* bfs.c - The Bee File System. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Based on the book "Practical File System Design by Dominic Giampaolo
with corrections and completitions based on Haiku code.
*/
GRUB_MOD_LICENSE ("GPLv3+");
#ifdef MODE_AFS
#else
#endif
#ifdef MODE_AFS
#else
#endif
#ifdef MODE_AFS
#else
#endif
struct grub_bfs_extent
{
} __attribute__ ((packed));
struct grub_bfs_superblock
{
} __attribute__ ((packed));
struct grub_bfs_inode
{
#ifdef MODE_AFS
#else
#endif
union
{
struct
{
} __attribute__ ((packed));
} __attribute__ ((packed));
} __attribute__ ((packed));
enum
{
};
{
} __attribute__ ((packed));
struct grub_bfs_btree_header
{
#ifdef MODE_AFS
#else
#endif
} __attribute__ ((packed));
struct grub_bfs_btree_node
{
#ifdef MODE_AFS
#else
#endif
} __attribute__ ((packed));
struct grub_bfs_data
{
};
static grub_err_t
const struct grub_bfs_superblock *sb,
const struct grub_bfs_extent *in,
{
#ifdef MODE_AFS
- GRUB_DISK_SECTOR_BITS))),
#else
#endif
}
#ifdef MODE_AFS
#else
#define RANGE_SHIFT 0
#endif
static grub_err_t
const struct grub_bfs_superblock *sb,
const struct grub_bfs_inode *ino,
unsigned offset,
unsigned length))
{
if (len == 0)
return GRUB_ERR_NONE;
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"attempt to read past the end of file");
{
unsigned i;
{
{
if (err)
return err;
if (len == 0)
return GRUB_ERR_NONE;
}
}
}
{
unsigned i;
<< RANGE_SHIFT);
if (!entries)
return grub_errno;
for (i = 0; i < nentries; i++)
{
{
if (err)
{
return err;
}
if (len == 0)
{
return GRUB_ERR_NONE;
}
}
}
}
{
if (!l1_entries)
return grub_errno;
nl2_entries = 0;
if (!l2_entries)
{
return grub_errno;
}
if (err)
{
return err;
}
while (len > 0)
{
+ DOUBLE_INDIRECT_SHIFT)) - 1));
+ DOUBLE_INDIRECT_SHIFT)) - 1));
l1n =
2 * DOUBLE_INDIRECT_SHIFT));
if (l1n > nl1_entries)
{
return grub_error (GRUB_ERR_BAD_FS,
"incorrect double-indirect block");
}
{
- LOG_EXTENT_SIZE));
if (err)
{
return err;
}
}
if (l2n > nl2_entries)
{
return grub_error (GRUB_ERR_BAD_FS,
"incorrect double-indirect block");
}
+ DOUBLE_INDIRECT_SHIFT)) - boff;
if (err)
{
return err;
}
}
return GRUB_ERR_NONE;
}
}
static int
const struct grub_bfs_superblock *sb,
const struct grub_bfs_inode *ino,
{
int level;
if (err)
return 0;
while (level--)
{
if (err)
return 0;
BTREE_ALIGN) +
sizeof (grub_uint16_t), &key_value,
sizeof (grub_uint64_t), 0);
if (err)
return 0;
}
while (1)
{
if (err)
return 0;
{
unsigned i;
err =
if (err)
return 0;
sizeof (grub_uint16_t), 0);
if (err)
return 0;
BTREE_ALIGN) +
sizeof (grub_uint16_t), key_values,
sizeof (grub_uint64_t), 0);
if (err)
return 0;
{
char c;
return 1;
}
if (node_off == POINTER_INVALID)
return 0;
}
}
}
static grub_err_t
const struct grub_bfs_superblock *sb,
grub_uint64_t * res)
{
int level;
if (err)
return err;
while (1)
{
if (err)
return err;
if (node.count_keys == 0)
name);
{
unsigned i;
err =
if (err)
return err;
+
sizeof (grub_uint16_t), 0);
if (err)
return err;
BTREE_ALIGN) +
sizeof (grub_uint16_t), key_values,
sizeof (grub_uint64_t), 0);
if (err)
return err;
{
int cmp;
char c;
{
return GRUB_ERR_NONE;
}
{
break;
}
}
{
level--;
continue;
}
{
/* This level-- isn't specified but is needed. */
level--;
continue;
}
name);
}
}
}
static grub_err_t
const struct grub_bfs_superblock *sb,
{
if (err)
return err;
- GRUB_DISK_SECTOR_BITS), 0,
}
static grub_err_t
{
union
{
} old_ino;
if (err)
return err;
while (1)
{
while (*ptr == '/')
ptr++;
if (*ptr == 0)
{
return GRUB_ERR_NONE;
}
if (ptr2)
{
}
else
if (err)
return err;
{
if (--symlinks_max == 0)
{
return grub_error (GRUB_ERR_SYMLINK_LOOP,
"too deep nesting of symlinks");
}
#ifndef MODE_AFS
#endif
{
+ symsize + 1);
if (!alloc)
{
return grub_errno;
}
if (err)
{
return err;
}
}
#ifndef MODE_AFS
else
{
if (!alloc)
{
return grub_errno;
}
sizeof (ino->inplace_link));
}
#endif
if (alloc[0] == '/')
{
if (err)
{
return err;
}
}
else
if (ptr2)
*ptr = 0;
continue;
}
if (!ptr2)
{
return GRUB_ERR_NONE;
}
}
}
static grub_err_t
{
if (err == GRUB_ERR_OUT_OF_RANGE)
return grub_error (GRUB_ERR_BAD_FS,
#ifdef MODE_AFS
"not an AFS filesystem"
#else
"not a BFS filesystem"
#endif
);
if (err)
return err;
return grub_error (GRUB_ERR_BAD_FS,
#ifdef MODE_AFS
"not an AFS filesystem"
#else
"not a BFS filesystem"
#endif
);
return GRUB_ERR_NONE;
}
static grub_err_t
const struct grub_dirhook_info * info))
{
{
union
{
} ino;
- GRUB_DISK_SECTOR_BITS), 0,
if (err2)
{
grub_print_error ();
return 0;
}
#ifdef MODE_AFS
#else
#endif
}
if (err)
return err;
{
union
{
} ino;
if (err)
return err;
}
return grub_errno;
}
static grub_err_t
{
if (err)
return err;
{
union
{
} ino;
if (err)
return err;
if (!data)
return grub_errno;
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
return GRUB_ERR_NONE;
}
static grub_ssize_t
{
if (err)
return -1;
return len;
}
static grub_err_t
{
*label = 0;
if (err)
return err;
return GRUB_ERR_NONE;
}
#ifndef MODE_AFS
static grub_ssize_t
const struct grub_bfs_superblock *sb,
const struct grub_bfs_inode *ino,
{
{
char *el_name;
break;
{
return copy;
}
}
{
union
{
} ino2;
if (err)
return -1;
if (err)
return -1;
- GRUB_DISK_SECTOR_BITS), 0,
if (err)
return -1;
return read;
}
return -1;
}
static grub_err_t
{
*uuid = 0;
if (err)
return err;
{
union
{
} ino;
if (err)
return err;
*uuid =
}
return GRUB_ERR_NONE;
}
#endif
#ifdef MODE_AFS
.name = "afs",
#else
.name = "bfs",
#endif
.dir = grub_bfs_dir,
.open = grub_bfs_open,
.read = grub_bfs_read,
.close = grub_bfs_close,
.label = grub_bfs_label,
#ifndef MODE_AFS
.uuid = grub_bfs_uuid,
#endif
#ifdef GRUB_UTIL
.reserved_first_sector = 1,
#endif
};
#ifdef MODE_AFS
#else
#endif
{
sizeof (struct grub_bfs_extent));
}
#ifdef MODE_AFS
#else
#endif
{
}