/* FsMountVol : mount the file system volume */ INT32 FsMountVol(struct super_block *sb) { INT32 err, drv; sm_P(&z_sem); for (drv = 0; drv < MAX_DRIVE; drv++) { if (!fs_struct[drv].mounted) break; } if (drv >= MAX_DRIVE) { err = FFS_ERROR; goto ret_unlock; } sm_P(&(fs_struct[drv].v_sem)); err = buf_init(sb); if (!err) { err = ffsMountVol(sb, drv); } sm_V(&(fs_struct[drv].v_sem)); if (!err) { fs_struct[drv].mounted = TRUE; fs_struct[drv].sb = sb; } else { buf_shutdown(sb); } ret_unlock: sm_V(&z_sem); return(err); } /* end of FsMountVol */
INT32 FsMountVol(struct super_block *sb) { INT32 err, drv; sm_P(&z_sem); for (drv = 0; drv < MAX_DRIVE; drv++) { if (!fs_struct[drv].mounted) break; } if (drv >= MAX_DRIVE) { /* * LGE_CHANGE_S * Date : 2015.03.05 * Author : [email protected] * Comment : Release semaphore (z_sem) in error condition. * In case of attaching storage more than MAX_DRIVE(2), * mount fails and no more access on exFAT. */ printk(KERN_ERR "%s: drv : %d, MAX_DRIVE : %d\n", __func__, drv, MAX_DRIVE); sm_V(&z_sem); return FFS_ERROR; } sm_P(&(fs_struct[drv].v_sem)); err = buf_init(sb); if (!err) { err = ffsMountVol(sb, drv); } sm_V(&(fs_struct[drv].v_sem)); if (!err) { fs_struct[drv].mounted = TRUE; fs_struct[drv].sb = sb; } else { buf_shutdown(sb); } sm_V(&z_sem); return(err); }
/* FsUmountVol : unmount the file system volume */ int FsUmountVol(struct super_block *sb) { int err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&z_sem); /* acquire the lock for file system critical section */ sm_P(&p_fs->v_sem); err = ffsUmountVol(sb); buf_shutdown(sb); /* release the lock for file system critical section */ sm_V(&p_fs->v_sem); sm_V(&z_sem); return err; } /* end of FsUmountVol */
INT32 FsUmountVol(struct super_block *sb) { INT32 err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&z_sem); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsUmountVol(sb); buf_shutdown(sb); sm_V(&(fs_struct[p_fs->drv].v_sem)); fs_struct[p_fs->drv].mounted = FALSE; fs_struct[p_fs->drv].sb = NULL; sm_V(&z_sem); return(err); }
INT32 FsSyncVol(struct super_block *sb, INT32 do_sync) { INT32 err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsSyncVol(sb, do_sync); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
INT32 FsReleaseCache(struct super_block *sb) { FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&(fs_struct[p_fs->drv].v_sem)); FAT_release_all(sb); buf_release_all(sb); sm_V(&(fs_struct[p_fs->drv].v_sem)); return 0; }
INT32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsGetStat(inode, info); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
INT32 FsSetAttr(struct inode *inode, UINT32 attr) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsSetAttr(inode, attr); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
/* FsUmountVol : unmount the file system volume */ INT32 FsUmountVol(struct super_block *sb) { INT32 err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&z_sem); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsUmountVol(sb); buf_shutdown(sb); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); fs_struct[p_fs->drv].mounted = FALSE; fs_struct[p_fs->drv].sb = NULL; sm_V(&z_sem); return(err); } /* end of FsUmountVol */
/* FsSyncVol : synchronize a file system volume */ int FsSyncVol(struct super_block *sb, int do_sync) { int err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ sm_P(&p_fs->v_sem); err = ffsSyncVol(sb, do_sync); /* release the lock for file system critical section */ sm_V(&p_fs->v_sem); return err; } /* end of FsSyncVol */
INT32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info) { INT32 err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if (info == NULL) return(FFS_ERROR); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsGetVolInfo(sb, info); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
/* FsReleaseCache: Release FAT & buf cache */ INT32 FsReleaseCache(struct super_block *sb) { FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); FAT_release_all(sb); buf_release_all(sb); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return 0; } /* FsReleaseCache */
/* FsSyncVol : synchronize a file system volume */ INT32 FsSyncVol(struct super_block *sb, INT32 do_sync) { INT32 err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsSyncVol(sb, do_sync); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsSyncVol */
INT32 FsMapCluster(struct inode *inode, INT32 clu_offset, UINT32 *clu) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if (clu == NULL) return(FFS_ERROR); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsMapCluster(inode, clu_offset, clu); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
INT32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry) { INT32 err; struct super_block *sb = old_parent_inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if (fid == NULL) return(FFS_INVALIDFID); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsMoveFile(old_parent_inode, fid, new_parent_inode, new_dentry); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
/* FsSetAttr : set the attribute of a given file */ int FsSetAttr(struct inode *inode, u32 attr) { int err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ sm_P(&p_fs->v_sem); err = ffsSetAttr(inode, attr); /* release the lock for file system critical section */ sm_V(&p_fs->v_sem); return err; } /* end of FsSetAttr */
INT32 FsRemoveEntry(struct inode *inode, FILE_ID_T *fid) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if (fid == NULL) return(FFS_INVALIDFID); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsRemoveEntry(inode, fid); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
/* FsReadStat : get the information of a given file */ INT32 FsReadStat(struct inode *inode, DIR_ENTRY_T *info) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsGetStat(inode, info); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsReadStat */
INT32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if (dir_entry == NULL) return(FFS_ERROR); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsReadDir(inode, dir_entry); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
/* FsSetAttr : set the attribute of a given file */ INT32 FsSetAttr(struct inode *inode, UINT32 attr) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsSetAttr(inode, attr); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsSetAttr */
/* FsMountVol : mount the file system volume */ int FsMountVol(struct super_block *sb) { int err; sm_P(&z_sem); err = buf_init(sb); if (!err) err = ffsMountVol(sb); else buf_shutdown(sb); sm_V(&z_sem); return err; } /* end of FsMountVol */
INT32 FsCreateDir(struct inode *inode, UINT8 *path, FILE_ID_T *fid) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if ((fid == NULL) || (path == NULL) || (STRLEN(path) == 0)) return(FFS_ERROR); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsCreateDir(inode, path, fid); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
INT32 FsWriteStat(struct inode *inode, DIR_ENTRY_T *info) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&(fs_struct[p_fs->drv].v_sem)); PRINTK("FsWriteStat entered (inode %p info %p\n", inode, info); err = ffsSetStat(inode, info); sm_V(&(fs_struct[p_fs->drv].v_sem)); PRINTK("FsWriteStat exited (%d)\n", err); return(err); }
/* FsGetVolInfo : get the information of a file system volume */ INT32 FsGetVolInfo(struct super_block *sb, VOL_INFO_T *info) { INT32 err; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* check the validity of pointer parameters */ if (info == NULL) return(FFS_ERROR); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsGetVolInfo(sb, info); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsGetVolInfo */
INT32 FsWriteFile(struct inode *inode, FILE_ID_T *fid, void *buffer, UINT64 count, UINT64 *wcount) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); if (fid == NULL) return(FFS_INVALIDFID); if (buffer == NULL) return(FFS_ERROR); sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsWriteFile(inode, fid, buffer, count, wcount); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
INT32 FsTruncateFile(struct inode *inode, UINT64 old_size, UINT64 new_size) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); sm_P(&(fs_struct[p_fs->drv].v_sem)); PRINTK("FsTruncateFile entered (inode %p size %llu)\n", inode, new_size); err = ffsTruncateFile(inode, old_size, new_size); PRINTK("FsTruncateFile exitted (%d)\n", err); sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); }
/* FsRemoveDir : remove a directory */ INT32 FsRemoveDir(struct inode *inode, FILE_ID_T *fid) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* check the validity of the given file id */ if (fid == NULL) return(FFS_INVALIDFID); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsRemoveDir(inode, fid); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsRemoveDir */
/* FsReadDir : read a directory entry from the opened directory */ INT32 FsReadDir(struct inode *inode, DIR_ENTRY_T *dir_entry) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* check the validity of pointer parameters */ if (dir_entry == NULL) return(FFS_ERROR); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsReadDir(inode, dir_entry); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsReadDir */
/* FsMapCluster : return the cluster number in the given cluster offset */ INT32 FsMapCluster(struct inode *inode, INT32 clu_offset, UINT32 *clu) { INT32 err; struct super_block *sb = inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* check the validity of pointer parameters */ if (clu == NULL) return(FFS_ERROR); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsMapCluster(inode, clu_offset, clu); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsMapCluster */
/* FsMoveFile : move(rename) a old file into a new file */ INT32 FsMoveFile(struct inode *old_parent_inode, FILE_ID_T *fid, struct inode *new_parent_inode, struct dentry *new_dentry) { INT32 err; struct super_block *sb = old_parent_inode->i_sb; FS_INFO_T *p_fs = &(EXFAT_SB(sb)->fs_info); /* check the validity of the given file id */ if (fid == NULL) return(FFS_INVALIDFID); /* acquire the lock for file system critical section */ sm_P(&(fs_struct[p_fs->drv].v_sem)); err = ffsMoveFile(old_parent_inode, fid, new_parent_inode, new_dentry); /* release the lock for file system critical section */ sm_V(&(fs_struct[p_fs->drv].v_sem)); return(err); } /* end of FsMoveFile */