if (num_empty >= num_entries) {
p_fs->hint_uentry.dir = CLUSTER_32(~0);
p_fs->hint_uentry.entry = -1;
-
- if (p_fs->vol_type == EXFAT)
- return dentry - (num_entries - 1);
- else
- return dentry;
+ return dentry - (num_entries - 1);
}
}
bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir)
{
- int i, count = 0;
+ int i;
s32 dentries_per_clu;
u32 type;
struct chain_t clu;
if (type == TYPE_UNUSED)
return true;
- if ((type != TYPE_FILE) && (type != TYPE_DIR))
- continue;
-
- if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */
- return false;
-
- if (p_fs->vol_type == EXFAT)
- return false;
- if ((p_dir->dir == p_fs->root_dir) || ((++count) > 2))
+ if ((type == TYPE_FILE) || (type == TYPE_DIR))
return false;
}
p_fs->num_clusters = GET32(p_bpb->clu_count) + 2;
/* because the cluster index starts with 2 */
- p_fs->vol_type = EXFAT;
p_fs->vol_id = GET32(p_bpb->vol_serial);
p_fs->root_dir = GET32(p_bpb->root_cluster);
clu.dir = CLUSTER_32(~0);
clu.size = 0;
- clu.flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ clu.flags = 0x03;
/* (1) allocate a cluster */
ret = exfat_alloc_cluster(sb, 1, &clu);
fid->entry = dentry;
fid->attr = ATTR_SUBDIR;
- fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ fid->flags = 0x03;
fid->size = size;
fid->start_clu = clu.dir;
s32 ret, dentry, num_entries;
struct dos_name_t dos_name;
struct super_block *sb = inode->i_sb;
- struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info);
ret = get_num_entries_and_dos_name(sb, p_dir, p_uniname, &num_entries,
&dos_name);
fid->entry = dentry;
fid->attr = ATTR_ARCHIVE | mode;
- fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ fid->flags = 0x03;
fid->size = 0;
fid->start_clu = CLUSTER_32(~0);
if (p_fs->used_clusters == UINT_MAX)
p_fs->used_clusters = exfat_count_used_clusters(sb);
- info->FatType = p_fs->vol_type;
+ info->FatType = EXFAT;
info->ClusterSize = p_fs->cluster_size;
info->NumClusters = p_fs->num_clusters - 2; /* clu 0 & 1 */
info->UsedClusters = p_fs->used_clusters;
fid->size = exfat_get_entry_size(ep2);
if ((fid->type == TYPE_FILE) && (fid->size == 0)) {
- fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ fid->flags = 0x03;
fid->start_clu = CLUSTER_32(~0);
} else {
fid->flags = exfat_get_entry_flag(ep2);
fid->size = new_size;
fid->attr |= ATTR_ARCHIVE;
if (new_size == 0) {
- fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ fid->flags = 0x03;
fid->start_clu = CLUSTER_32(~0);
}
dentry = fid->entry;
- /* check if the old file is "." or ".." */
- if (p_fs->vol_type != EXFAT) {
- if ((olddir.dir != p_fs->root_dir) && (dentry < 2)) {
- ret = -EPERM;
- goto out2;
- }
- }
-
ep = get_entry_in_dir(sb, &olddir, dentry, NULL);
if (!ep) {
ret = -ENOENT;
fid->size = 0;
fid->start_clu = CLUSTER_32(~0);
- fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ fid->flags = 0x03;
#ifndef CONFIG_STAGING_EXFAT_DELAYED_SYNC
fs_sync(sb, true);
dentry = fid->entry;
- /* check if the file is "." or ".." */
- if (p_fs->vol_type != EXFAT) {
- if ((dir.dir != p_fs->root_dir) && (dentry < 2))
- return -EPERM;
- }
-
/* acquire the lock for file system critical section */
mutex_lock(&p_fs->v_mutex);
fid->size = 0;
fid->start_clu = CLUSTER_32(~0);
- fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01;
+ fid->flags = 0x03;
#ifndef CONFIG_STAGING_EXFAT_DELAYED_SYNC
fs_sync(sb, true);
{
struct inode *inode = file_inode(filp);
struct super_block *sb = inode->i_sb;
- struct exfat_sb_info *sbi = EXFAT_SB(sb);
- struct fs_info_t *p_fs = &sbi->fs_info;
struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info);
struct dir_entry_t de;
unsigned long inum;
__lock_super(sb);
cpos = ctx->pos;
- /* Fake . and .. for the root directory. */
- if ((p_fs->vol_type == EXFAT) || (inode->i_ino == EXFAT_ROOT_INO)) {
- while (cpos < 2) {
- if (inode->i_ino == EXFAT_ROOT_INO)
- inum = EXFAT_ROOT_INO;
- else if (cpos == 0)
- inum = inode->i_ino;
- else /* (cpos == 1) */
- inum = parent_ino(filp->f_path.dentry);
-
- if (!dir_emit_dots(filp, ctx))
- goto out;
- cpos++;
- ctx->pos++;
- }
- if (cpos == 2)
- cpos = 0;
+ /* Fake . and .. for any directory. */
+ while (cpos < 2) {
+ if (inode->i_ino == EXFAT_ROOT_INO)
+ inum = EXFAT_ROOT_INO;
+ else if (cpos == 0)
+ inum = inode->i_ino;
+ else /* (cpos == 1) */
+ inum = parent_ino(filp->f_path.dentry);
+
+ if (!dir_emit_dots(filp, ctx))
+ goto out;
+ cpos++;
+ ctx->pos++;
}
+ if (cpos == 2)
+ cpos = 0;
if (cpos & (DENTRY_SIZE - 1)) {
err = -ENOENT;
goto out;
return -EIO;
} else {
- info.FatType = p_fs->vol_type;
+ info.FatType = EXFAT;
info.ClusterSize = p_fs->cluster_size;
info.NumClusters = p_fs->num_clusters - 2;
info.UsedClusters = p_fs->used_clusters;