コード例 #1
0
ファイル: fat_access.c プロジェクト: fdomig/ottos
//-----------------------------------------------------------------------------
// fatfs_show_details: Show the details about the filesystem
//-----------------------------------------------------------------------------
void fatfs_show_details(struct fatfs *fs) {
  FAT_PRINTF(("\r\nCurrent Disc FAT details\r\n------------------------\r\nRoot Dir First Cluster = "));
  FAT_PRINTF(("0x%x",fs->rootdir_first_cluster));
  FAT_PRINTF(("\r\nFAT Begin LBA = "));
  FAT_PRINTF(("0x%x",fs->fat_begin_lba));
  FAT_PRINTF(("\r\nCluster Begin LBA = "));
  FAT_PRINTF(("0x%x",fs->cluster_begin_lba));
  FAT_PRINTF(("\r\nSectors Per Cluster = "));
  FAT_PRINTF(("%d",fs->sectors_per_cluster));
  FAT_PRINTF(("\r\n\r\nFormula for conversion from Cluster num to LBA is;"));
  FAT_PRINTF(("\r\nLBA = (cluster_begin_lba + ((Cluster_Number-2)*sectors_per_cluster)))\r\n"));
}
コード例 #2
0
ファイル: ffs_fs.c プロジェクト: Aresthu/ucore_plus
/* cleanup of filesystem
 * i.e. sync the filesystem
 */
static int ffs_cleanup(struct fs *fs)
{
	FAT_PRINTF("[ffs_cleanup]");
	int i, ret;
	//just try 32 times
	for (i = 0; i < 32; i++) {
		if ((ret = fsop_sync(fs)) == 0) {
			break;
		}
	}
	if (ret != 0) {
		warn("ffs: sync error: %e.\n", ret);
	}
}
コード例 #3
0
ファイル: ffs_fs.c プロジェクト: Aresthu/ucore_plus
/* attempt unmount of filesystem */
static int ffs_unmount(struct fs *fs)
{
	//TODO
	FAT_PRINTF("[ffs_unmount]\n");
	struct ffs_fs *ffs = fsop_info(fs, ffs);
	if (ffs->inode_list->next != NULL) {
		return -E_BUSY;
	}
	kfree(ffs->fatfs);
	kfree(ffs->inode_list);
	kfree(ffs);

	return 0;
}
コード例 #4
0
ファイル: ffs_fs.c プロジェクト: Aresthu/ucore_plus
/* 
 * flush all dirty buffers to disk
 * return 0 if sync successful
 */
static int ffs_sync(struct fs *fs)
{
	//TODO
	return 0;
	FAT_PRINTF("[ffs_sync]\n");
	struct ffs_fs *ffs = fsop_info(fs, ffs);
	struct ffs_inode_list *inode_list = ffs->inode_list;
	while (inode_list->next != NULL) {
		inode_list = inode_list->next;
		vop_fsync(info2node(inode_list->f_inode, ffs_inode));
	}

	return 0;
}
コード例 #5
0
ファイル: fat_access.c プロジェクト: Jokymon/fat_io_lib
//-----------------------------------------------------------------------------
// fatfs_show_details: Show the details about the filesystem
//-----------------------------------------------------------------------------
void fatfs_show_details(struct fatfs *fs)
{
    FAT_PRINTF(("FAT details:\r\n"));
    FAT_PRINTF((" Type =%s", (fs->fat_type == FAT_TYPE_32) ? "FAT32": "FAT16"));
    FAT_PRINTF((" Root Dir First Cluster = %x\r\n", fs->rootdir_first_cluster));
    FAT_PRINTF((" FAT Begin LBA = 0x%x\r\n",fs->fat_begin_lba));
    FAT_PRINTF((" Cluster Begin LBA = 0x%x\r\n",fs->cluster_begin_lba));
    FAT_PRINTF((" Sectors Per Cluster = %d\r\n", fs->sectors_per_cluster));
}
コード例 #6
0
ファイル: ffs_fs.c プロジェクト: Aresthu/ucore_plus
static int ffs_do_mount(struct device *dev, struct fs **fs_store)
{
	static_assert(FFS_BLKSIZE >= sizeof(struct ffs_disk_inode));

	if (dev->d_blocksize != FFS_BLKSIZE) {
		return -E_NA_DEV;
	}

	/* allocate fs structure */
	struct fs *fs;

	//alloc_fs(type) will distribute the memory and set the type to "type"
	if ((fs = alloc_fs(ffs)) == NULL) {
		return -E_NO_MEM;
	}
	struct ffs_fs *ffs = fsop_info(fs, ffs);

	FRESULT result;
	struct FATFS *fatfs = kmalloc(FFS_BLKSIZE);
	if ((result = f_mount(0, fatfs)) != FR_OK) {
		FAT_PRINTF("[ffs_do_mount], failed = %d\n", result);
		goto failed_cleanup_ffs;
	}
	ffs->fatfs = fatfs;

	/***********************/
	/* read dir test */
	/*
	   DIR dirobject;
	   FILINFO fno;

	   if ((result = f_opendir(&dirobject, "0:")) != 0) {
	   FAT_PRINTF("ls: opendir failed, %d.\n", result);
	   goto label_out;
	   }
	   while (1) {
	   if (f_readdir(&dirobject, &fno) != 0) {
	   FAT_PRINTF("ls: readdir failed.\n");
	   break;
	   }
	   if (strlen(fno.fname) < 1) break;
	   FAT_PRINTF("%s ", fno.fname);
	   }
	   label_out:
	   FAT_PRINTF("\n");
	 */
	/***********************/
	/* read file test */
	/*
	   struct FIL* fp;
	   fp = kmalloc(sizeof(struct FIL));
	   if ((result = f_open(fp, "ctest", FA_READ)) != FR_OK) {
	   FAT_PRINTF("[ffs_do_mount], f_open, %d\n", result);

	   } else {
	   FAT_PRINTF("f_open successful\n");
	   BYTE s[4096];
	   UINT rc = 0;
	   fp->fptr = 0;
	   if ((result = f_read(fp, s, 4096, &rc)) != FR_OK) {
	   FAT_PRINTF("!!!!!!!!!!!!!!!, result = %d\n", result);
	   }
	   else {
	   FAT_PRINTF("s = %s\n", s);
	   FAT_PRINTF("rc = %d", rc);
	   }
	   FAT_PRINTF("\n");
	   }
	   kfree(fp);
	 */
	/***********************/

	/* alloc and initialize inode_list */
	struct ffs_inode_list *head;
	if ((ffs->inode_list = head = kmalloc(FFS_BLKSIZE)) == NULL) {
		goto failed_cleanup_ffs;
	}
	ffs->inode_list->next = ffs->inode_list->prev = NULL;
	ffs->inocnt = 0;

	FAT_PRINTF("ffs_do_mount done\n");
	fs->fs_sync = ffs_sync;
	fs->fs_get_root = ffs_get_root;
	fs->fs_unmount = ffs_unmount;
	fs->fs_cleanup = ffs_cleanup;
	*fs_store = fs;
	return 0;

failed_cleanup_ffs:
	kfree(fatfs);
	kfree(fs);
	return -E_NO_MEM;
}
コード例 #7
0
ファイル: diskio.c プロジェクト: PungiZhang/ucore_plus-next
DSTATUS disk_initialize (BYTE drive){
#if PRINTFSINFO
	FAT_PRINTF("[FATFS], disk_init on drive%d\n", drive);
#endif
	return 0;
}
コード例 #8
0
ファイル: diskio.c プロジェクト: PungiZhang/ucore_plus-next
int assign_drives (int st, int ed){
#if PRINTFSINFO
	FAT_PRINTF("[FATFS], assign %d to %d\n", st, ed);
#endif
	return 1;
}