Пример #1
0
void AsyncFio::remove(const char *path) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioRemove(path);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
}
Пример #2
0
int AsyncFio::mount(const char *mountpoint, const char *mountstring, int flag) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioMount(mountpoint, mountstring, flag);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #3
0
int AsyncFio::seek(int fd, int offset, int whence) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioLseek(fd, offset, whence);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #4
0
int AsyncFio::umount(const char *mountpoint) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioUmount(mountpoint);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #5
0
int AsyncFio::open(const char *name, int ioMode) {
	WaitSema(_ioSema);
	checkSync();
	int res;
	fileXioOpen(name, ioMode, DEFAULT_MODE);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #6
0
void AsyncFio::dclose(int fd) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioDclose(fd);
	fileXioWaitAsync(FXIO_WAIT, &res);
	assert(res == 0);
	SignalSema(_ioSema);
}
Пример #7
0
int AsyncFio::dread(int fd, iox_dirent_t *dest) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioDread(fd, dest);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #8
0
int AsyncFio::dopen(const char *name) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioDopen(name);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #9
0
int AsyncFio::mkdir(const char *name) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioMkdir(name, DEFAULT_MODE);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	return res;
}
Пример #10
0
int AsyncFio::dopen(const char *name) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioDopen(name);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	dbg_printf("FIO: dopen(%s) => %d\n", name, res);
	return res;
}
Пример #11
0
int AsyncFio::open(const char *name, int ioMode, int mode) {
	WaitSema(_ioSema);
	checkSync();
	int res;
	fileXioOpen(name, ioMode, mode);
	fileXioWaitAsync(FXIO_WAIT, &res);
	SignalSema(_ioSema);
	// dbg_printf("FIO: open ext(%s, %d, %d) => %d", name, ioMode, mode, res);
    return res;
}
Пример #12
0
void AsyncFio::close(int handle) {
	WaitSema(_ioSema);
	checkSync();
	fileXioClose(handle);
	int res;
	fileXioWaitAsync(FXIO_WAIT, &res);
	if (res != 0)
		sioprintf("ERROR: fileXioClose failed, EC %d", res);
	_ioSlots[handle] = 0;
	SignalSema(_ioSema);
}
Пример #13
0
void AsyncFio::dclose(int fd) {
	int res;
	WaitSema(_ioSema);
	checkSync();
	fileXioDclose(fd);
	fileXioWaitAsync(FXIO_WAIT, &res);
	//assert(res == 0);
	dbg_printf("FIO: dclose(%d) => %d\n", fd, res);
	if (res != 0)
		sioprintf("ERROR: fileXioDclose failed, EC %d\n", res);
	SignalSema(_ioSema);
}
Пример #14
0
bool AsyncFio::fioAvail(void) {
	bool retVal = false;
	if (PollSema(_ioSema) > 0) {
		if (_runningOp) {
			if (fileXioWaitAsync(FXIO_NOWAIT, (int *)_runningOp) == FXIO_COMPLETE) {
				_runningOp = NULL;
				retVal = true;
			} else
				retVal = false;
		} else
			retVal = true;
		SignalSema(_ioSema);
	}
	return retVal;
}
Пример #15
0
bool AsyncFio::poll(int fd) {
	bool retVal = false;
	if (PollSema(_ioSema) >= 0) {
		if (_runningOp == _ioSlots + fd) {
			if (fileXioWaitAsync(FXIO_NOWAIT, (int *)_runningOp) == FXIO_COMPLETE) {
				_runningOp = NULL;
				retVal = true;
			} else
				retVal = false;
		} else
			retVal = true;
		SignalSema(_ioSema);
	}
	return retVal;
}
Пример #16
0
void Ps2FilesystemNode::doverify(void) {
	PS2Device medium;
	int fd;

	if (_verified)
		return;

	_verified = true;

	dbg_printf(" verify: %s -> ", _path.c_str());

#if 0
	if (_path.empty()) {
		dbg_printf("PlayStation 2 Root !\n");
		_verified = true;
		return;
	}

	if (_path.lastChar() == ':') {
		dbg_printf("Dev: %s\n", _path.c_str());
		_verified = true;
		return;
	}
#endif

	if (_path[3] != ':' && _path[4] != ':') {
		dbg_printf("relative path !\n");
		_isHere = false;
		_isDirectory = false;
		return;
	}

	medium = _getDev(_path);
	if (medium == ERR_DEV) {
		_isHere = false;
		_isDirectory = false;
		return;
	}

	switch (medium) {
#if 0
	case HD_DEV: /*stat*/
	case USB_DEV:
		iox_stat_t stat;

		fileXioGetStat(_path.c_str(), &stat);
		fileXioWaitAsync(FXIO_WAIT, &fd);

		if (!fd) {
			dbg_printf("  yes [stat]\n");
			return true;
		}
	break;
#endif

	case CD_DEV: /*no stat*/
	case HD_DEV:
	case USB_DEV:
	case HOST_DEV:
	case MC_DEV:
#if 1
	fd = fio.open(_path.c_str(), O_RDONLY);

	dbg_printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd);

	if (fd >=0) {
		fio.close(fd);
		dbg_printf("  yes [open]\n");
		_isHere = true;
		if (medium==MC_DEV && _path.lastChar()=='/')
			_isDirectory = true;
		else
			_isDirectory = false;
		return;
	}

	fd = fio.dopen(_path.c_str());
	if (fd >=0) {
		fio.dclose(fd);
		dbg_printf("  yes [dopen]\n");
		_isHere = true;
		_isDirectory = true;
		return;
	}

#else
	fileXioOpen(_path.c_str(), O_RDONLY, DEFAULT_MODE);
	fileXioWaitAsync(FXIO_WAIT, &fd);
	if (fd>=0) {
		fileXioClose(fd);
		fileXioWaitAsync(FXIO_WAIT, &fd);
		return true;
	}

	fileXioDopen(_path.c_str());
	fileXioWaitAsync(FXIO_WAIT, &fd);
	if (fd>=0) {
		fileXioDclose(fd);
		fileXioWaitAsync(FXIO_WAIT, &fd);
		return true;
	}
#endif
	break;
	case ERR_DEV:
		_isHere = false;
		_isDirectory = false;
	break;
	}

	_isHere = false;
	_isDirectory = false;

	dbg_printf("  no\n");
	return;
}
Пример #17
0
void AsyncFio::checkSync(void) {
	if (_runningOp) {
		fileXioWaitAsync(FXIO_WAIT, (int *)_runningOp);
		_runningOp = NULL;
	}
}