Пример #1
0
int hddOpen(iop_file_t *f, const char *name, int flags, int mode)
{
	int			rv;
	apa_params_t	params;
	hdd_file_slot_t *fileSlot;

	if(f->unit >= 2 || hddDevices[f->unit].status!=0)
		return -ENODEV;

	if(!(f->mode & O_DIROPEN))
		if((rv=fioGetInput(name, &params)) < 0)
			return rv;

	WaitSema(fioSema);
	if((rv=getFileSlot(&params, &fileSlot))==0) {
		if(!(f->mode & O_DIROPEN)) {
			if((rv=apaOpen(f->unit, fileSlot, &params, flags))==0){
				fileSlot->f=f;
				f->privdata=fileSlot;
			}
		}
		else
		{
			fileSlot->f=f;
			f->privdata=fileSlot;
		}
	}
	SignalSema(fioSema);
	return rv;
}
Пример #2
0
/*	Originally, SONY provided no function for renaming partitions.
	Syntax:	rename <Old ID>,<fpwd> <New ID>,<fpwd>

	The full-access password (fpwd) is required.
	System partitions (__*) cannot be renamed.	*/
int hddReName(iop_file_t *f, const char *oldname, const char *newname)
{
	apa_params_t oldParams;
	apa_params_t newParams;
	int rv;

	if((rv=fioGetInput(oldname, &oldParams))<0)
		return rv;
	if((rv=fioGetInput(newname, &newParams))<0)
		return rv;

	WaitSema(fioSema);
	rv = apaRename(f->unit, &oldParams, &newParams);
	SignalSema(fioSema);

	return rv;
}
Пример #3
0
int hddRemove(iop_file_t *f, const char *name)
{
	int			rv;
	input_param	params;

	if((rv=fioGetInput(name, &params)) < 0)
		return rv;

	WaitSema(fioSema);
	apaRemove(f->unit, params.id);
	return SignalSema(fioSema);
}
Пример #4
0
int hddGetStat(iop_file_t *f, const char *name, iox_stat_t *stat)
{
	apa_cache_t	*clink;
	apa_params_t	params;
	int			rv;

	if((rv=fioGetInput(name, &params))<0)
		return rv;

	WaitSema(fioSema);
	if((clink=apaFindPartition(f->unit, params.id, &rv))){
		if((rv=apaPassCmp(clink->header->fpwd, params.fpwd))==0 || (rv=apaPassCmp(clink->header->rpwd, params.rpwd))==0)
				fioGetStatFiller(clink, stat);
		apaCacheFree(clink);
	}
	SignalSema(fioSema);
	return rv;
}
Пример #5
0
int hddGetStat(iop_file_t *f, const char *name, iox_stat_t *stat)
{
	apa_cache	*clink;
	input_param	params;
	int			rv;

	if((rv=fioGetInput(name, &params))<0)
		return rv;

	WaitSema(fioSema);
	if((clink=apaFindPartition(f->unit, params.id, &rv))){
		if((rv=passcmp(clink->header->rpwd, NULL))==0)
				fioGetStatFiller(clink, stat);
		cacheAdd(clink);
	}
	SignalSema(fioSema);
	return rv;
}
Пример #6
0
static int devctlSwapTemp(s32 device, char *argp)
{
	int			rv;
	apa_params_t	params;
	char		szBuf[APA_IDMAX];
	apa_cache_t	*partTemp;
	apa_cache_t	*partNew;


	if((rv=fioGetInput(argp, &params)) < 0)
		return rv;

	if(params.id[0] == '_' && params.id[1] == '_')// test for '__' system partition
		return -EINVAL;

	memset(szBuf, 0, APA_IDMAX);
	strcpy(szBuf, "_tmp");
	if(!(partTemp=apaFindPartition(device, szBuf, &rv)))
		return rv;

	if((partNew=apaFindPartition(device, params.id, &rv))) {
		if((rv=apaPassCmp(partNew->header->fpwd, params.fpwd))==0) {
			memcpy(partTemp->header->id, partNew->header->id, APA_IDMAX);
			memcpy(partTemp->header->rpwd, partNew->header->rpwd, APA_PASSMAX);
			memcpy(partTemp->header->fpwd, partNew->header->fpwd, APA_PASSMAX);
			//memset(partNew->header->id, 0, 8);// BUG! can make it so can not open!!
			memset(partNew->header->id, 0, APA_IDMAX);
			strcpy(partNew->header->id, "_tmp");
			memset(partNew->header->rpwd, 0, APA_PASSMAX);
			memset(partNew->header->fpwd, 0, APA_PASSMAX);
			partTemp->flags|=APA_CACHE_FLAG_DIRTY;
			partNew->flags|=APA_CACHE_FLAG_DIRTY;
			apaCacheFlushAllDirty(device);
		}
		apaCacheFree(partNew);
	}
	apaCacheFree(partTemp);
	return rv;
}
Пример #7
0
int devctlSwapTemp(u32 device, char *argp)
{
	int			rv;
	input_param	params;
	char		szBuf[APA_IDMAX];
	apa_cache	*partTemp;
	apa_cache	*partNew;


	if((rv=fioGetInput(argp, &params)) < 0)
		return rv;

	if(*(u16 *)(params.id)==(u16)0x5F5F)// test for '__' system partition
		return -EINVAL;

	memset(szBuf, 0, APA_IDMAX);
	strcpy(szBuf, "_tmp");
	if(!(partTemp=apaFindPartition(device, szBuf, &rv)))
		return rv;

	if((partNew=apaFindPartition(device, params.id, &rv))) {
		if((rv=passcmp(partNew->header->fpwd, NULL))==0) {
			memcpy(partTemp->header->id, partNew->header->id, APA_IDMAX);
			memcpy(partTemp->header->rpwd, partNew->header->rpwd, APA_PASSMAX);
			memcpy(partTemp->header->fpwd, partNew->header->fpwd, APA_PASSMAX);
			//memset(partNew->header->id, 0, 8);// BUG! can make it so can not open!!
			memset(partNew->header->id, 0, APA_IDMAX);
			strcpy(partNew->header->id, "_tmp");
			memset(partNew->header->rpwd, 0, APA_PASSMAX);
			memset(partNew->header->fpwd, 0, APA_PASSMAX);
			partTemp->flags|=CACHE_FLAG_DIRTY;
			partNew->flags|=CACHE_FLAG_DIRTY;
			cacheFlushAllDirty(device);
		}
		cacheAdd(partNew);
	}
	cacheAdd(partTemp);
	return rv;
}