/**
 * Get mode stored in the inode
 * 
 * @param inode pointer to inode
 */
uint32_t ext2_inode_get_mode(ext2_superblock_t *sb, ext2_inode_t *inode)
{
	if (ext2_superblock_get_os(sb) == EXT2_SUPERBLOCK_OS_HURD) {
		return ((uint32_t)uint16_t_le2host(inode->mode_high)) << 16 |
		    ((uint32_t)uint16_t_le2host(inode->mode));
	}
	return uint16_t_le2host(inode->mode);
}
/** Get mode of the i-node.
 *
 * @param sb    Superblock
 * @param inode I-node to load mode from
 *
 * @return Mode of the i-node
 *
 */
uint32_t ext4_inode_get_mode(ext4_superblock_t *sb, ext4_inode_t *inode)
{
	if (ext4_superblock_get_creator_os(sb) == EXT4_SUPERBLOCK_OS_HURD) {
		return ((uint32_t) uint16_t_le2host(inode->osd2.hurd2.mode_high)) << 16 |
		    ((uint32_t) uint16_t_le2host(inode->mode));
	}
	
	return uint16_t_le2host(inode->mode);
}
/**
 * Get uid this inode is belonging to
 * 
 * @param inode pointer to inode
 */
uint32_t ext2_inode_get_user_id(ext2_superblock_t *sb, ext2_inode_t *inode)
{
	uint32_t os = ext2_superblock_get_os(sb);
	if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) {
		return ((uint32_t)uint16_t_le2host(inode->user_id_high)) << 16 |
		    ((uint32_t)uint16_t_le2host(inode->user_id));
	}
	return uint16_t_le2host(inode->user_id);
}
Exemple #4
0
/** Get cluster from the first FAT.
 *
 * @param bs		Buffer holding the boot sector for the file system.
 * @param service_id	Service ID for the file system.
 * @param clst		Cluster which to get.
 * @param value		Output argument holding the value of the cluster.
 *
 * @return		EOK or a negative error code.
 */
static int
fat_get_cluster_fat12(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    fat_cluster_t clst, fat_cluster_t *value)
{
	block_t *b, *b1;
	uint16_t byte1, byte2;
	aoff64_t offset;
	int rc;

	offset = (clst + clst / 2);
	if (offset / BPS(bs) >= SF(bs))
		return ERANGE;

	rc = block_get(&b, service_id, RSCNT(bs) + SF(bs) * fatno +
	    offset / BPS(bs), BLOCK_FLAGS_NONE);
	if (rc != EOK)
		return rc;

	byte1 = ((uint8_t *) b->data)[offset % BPS(bs)];
	/* This cluster access spans a sector boundary. Check only for FAT12 */
	if ((offset % BPS(bs)) + 1 == BPS(bs)) {
		/* Is this the last sector of FAT? */
		if (offset / BPS(bs) < SF(bs)) {
			/* No, read the next sector */
			rc = block_get(&b1, service_id, 1 + RSCNT(bs) +
			    SF(bs) * fatno + offset / BPS(bs),
			    BLOCK_FLAGS_NONE);
			if (rc != EOK) {
				block_put(b);
				return rc;
			}
			/*
			* Combining value with last byte of current sector and
			* first byte of next sector
			*/
			byte2 = ((uint8_t*) b1->data)[0];

			rc = block_put(b1);
			if (rc != EOK) {
				block_put(b);
				return rc;
			}
		} else {
			/* Yes. This is the last sector of FAT */
			block_put(b);
			return ERANGE;
		}
	} else
		byte2 = ((uint8_t *) b->data)[(offset % BPS(bs)) + 1];

	*value = uint16_t_le2host(byte1 | (byte2 << 8));
	if (IS_ODD(clst))
		*value = (*value) >> 4;
	else
Exemple #5
0
/** Perform basic sanity checks on the file system.
 *
 * Verify if values of boot sector fields are sane. Also verify media
 * descriptor. This is used to rule out cases when a device obviously
 * does not contain a exfat file system.
 */
int exfat_sanity_check(exfat_bs_t *bs, service_id_t service_id)
{
	if (str_cmp((char const *)bs->oem_name, "EXFAT   "))
		return ENOTSUP;
	else if (uint16_t_le2host(bs->signature) != 0xAA55)
		return ENOTSUP;
	else if (uint32_t_le2host(bs->fat_sector_count) == 0)
		return ENOTSUP;
	else if (uint32_t_le2host(bs->data_clusters) == 0)
		return ENOTSUP;
	else if (bs->fat_count != 1)
		return ENOTSUP;
	else if ((bs->bytes_per_sector + bs->sec_per_cluster) > 25) {
		/* exFAT does not support cluster size > 32 Mb */
		return ENOTSUP;
	}
	return EOK;
}
Exemple #6
0
/** Get directory entry length.
 *
 * @param de Directory entry
 *
 * @return Entry length
 *
 */
uint16_t ext4_directory_entry_ll_get_entry_length(ext4_directory_entry_ll_t *de)
{
	return uint16_t_le2host(de->entry_length);
}
Exemple #7
0
uint16_t hda_reg16_read(uint16_t *r)
{
	return uint16_t_le2host(pio_read_16(r));
}
/**
 * Get usage count (i.e. hard link count)
 * A value of 1 is common, while 0 means that the inode should be freed
 * 
 * @param inode pointer to inode
 */
uint16_t ext2_inode_get_usage_count(ext2_inode_t *inode)
{
	return uint16_t_le2host(inode->usage_count);
}