Пример #1
0
static int fat_node_sync(fat_node_t *node)
{
	block_t *b;
	fat_bs_t *bs;
	fat_dentry_t *d;
	int rc;

	assert(node->dirty);

	bs = block_bb_get(node->idx->service_id);

	/* Read the block that contains the dentry of interest. */
	rc = _fat_block_get(&b, bs, node->idx->service_id, node->idx->pfc,
	    NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
	    BLOCK_FLAGS_NONE);
	if (rc != EOK)
		return rc;

	d = ((fat_dentry_t *)b->data) + (node->idx->pdi % DPS(bs));

	d->firstc = host2uint16_t_le(node->firstc);
	if (node->type == FAT_FILE) {
		d->size = host2uint32_t_le(node->size);
	} else if (node->type == FAT_DIRECTORY) {
		d->attr = FAT_ATTR_SUBDIR;
	}

	/* TODO: update other fields? (e.g time fields) */

	b->dirty = true;		/* need to sync block */
	rc = block_put(b);
	return rc;
}
Пример #2
0
/** Construct boot sector with the given parameters. */
static void fat_bootsec_create(struct fat_cfg const *cfg, struct fat_bs *bs)
{
	memset(bs, 0, sizeof(*bs));

	bs->ji[0] = 0xEB;
	bs->ji[1] = 0x3C;
	bs->ji[2] = 0x90;

	memcpy(bs->oem_name, "HELENOS ", 8);

	/* BIOS Parameter Block */
	bs->bps = host2uint16_t_le(cfg->sector_size);
	bs->spc = cfg->sectors_per_cluster;
	bs->rscnt = host2uint16_t_le(cfg->reserved_sectors);
	bs->fatcnt = cfg->fat_count;
	bs->root_ent_max = host2uint16_t_le(cfg->root_ent_max);

	if (cfg->total_sectors < 0x10000) {
		bs->totsec16 = host2uint16_t_le(cfg->total_sectors);
		bs->totsec32 = 0;
	} else {
		bs->totsec16 = 0;
		bs->totsec32 = host2uint32_t_le(cfg->total_sectors);
	}

	bs->mdesc = default_media_descriptor;
	bs->sec_per_track = host2uint16_t_le(63);
	bs->signature = host2uint16_t_be(0x55AA);
	bs->headcnt = host2uint16_t_le(6);
	bs->hidden_sec = host2uint32_t_le(0);

	if (cfg->fat_type == FAT32) {
		bs->sec_per_fat = 0;
		bs->fat32.sectors_per_fat = host2uint32_t_le(cfg->fat_sectors);

		bs->fat32.pdn = 0x80;
		bs->fat32.ebs = 0x29;
		bs->fat32.id = host2uint32_t_be(0x12345678);
		bs->fat32.root_cluster = 2;

		memcpy(bs->fat32.label, "HELENOS_NEW", 11);
		memcpy(bs->fat32.type, "FAT32   ", 8);
	} else {
		bs->sec_per_fat = host2uint16_t_le(cfg->fat_sectors);
		bs->pdn = 0x80;
		bs->ebs = 0x29;
		bs->id = host2uint32_t_be(0x12345678);

		memcpy(bs->label, "HELENOS_NEW", 11);
		memcpy(bs->type, "FAT   ", 8);
	}
}
Пример #3
0
/** Set directory entry length.
 *
 * @param de     Directory entry
 * @param length Entry length
 *
 */
void ext4_directory_entry_ll_set_entry_length(ext4_directory_entry_ll_t *de,
    uint16_t length)
{
	de->entry_length = host2uint16_t_le(length);
}
Пример #4
0
void hda_reg16_write(uint16_t *r, uint16_t val)
{
	pio_write_16(r, host2uint16_t_le(val));
}