Пример #1
0
s32 FAT_Ioctl(s32 fd, u32 cmd, void *inbuf, u32 inlen, void *iobuf, u32 iolen)
{
	s32 ret = IPC_EINVAL;

	/* Invalidate cache */
	if (inbuf)
		os_sync_before_read(inbuf, inlen);

	/* Parse command */
	switch (cmd) {
	/** Get file stats **/
	case IOCTL_FAT_FILESTATS: {
		fstats *stats = (fstats *)iobuf;

		/* Get file stats */
		ret = FAT_GetFileStats(fd, stats);

		break;
	}

	default:
		break;
	}

	/* Flush cache */
	if (iobuf)
		os_sync_after_write(iobuf, iolen);

	return ret;
}
Пример #2
0
s32 __FAT_Ioctl(s32 fd, u32 cmd, void *inbuf, u32 inlen, void *iobuf, u32 iolen)
{
	s32 ret = IPC_EINVAL;

	/* Invalidate cache */
	if (inbuf)
		os_sync_before_read(inbuf, inlen);

	/* Parse command */
	switch (cmd) {
	/** Get file stats **/
	case IOCTL_FAT_FILESTATS: {
		void *stats = iobuf;
		dbg_printf("FAT: IOCTL_FAT_FILESTATS: fd = %d\n", fd);

		/* Get file stats */
		ret = FAT_GetFileStats(fd, stats);
		dbg_printf("FAT: IOCTL_FAT_FILESTATS: ret = %d, length = %d, pos = %d\n", ret, ((struct fstats *)stats)->length, ((struct fstats *)stats)->pos);

		break;
	}

	case IOCTL_FAT_SETNANDPATH: {
		char *path = inbuf;
		dbg_printf("FAT: IOCTL_FAT_SETNANDPATH: path = %d\n", path);
		ret = -4;
		if (path != NULL && ((u32)path & !31) == 0 && (inlen & !3) == 0) {
			u32 len = strnlen(path, 192);
			if (len < 192) {
				strcpy(emuNandPath, path);
				emuNandPathLen = len;
				if(emuNandPath[len] != '/') {
					emuNandPath[len]   = '/';
					emuNandPath[len+1] = '\0';
					emuNandPathLen++;
				}
				ret = 0;
			}
		}
		dbg_printf("FAT: IOCTL_FAT_SETNANDPATH: ret = %d\n", ret);
		break;
	}

	default:
		break;
	}

	/* Flush cache */
	if (iobuf)
		os_sync_after_write(iobuf, iolen);

	return ret;
}