示例#1
0
文件: nfsd.c 项目: netdebug/vxnfsd
diropres       *
nfsproc_create_2(createargs * createargp, struct svc_req * reqp)
{
	static diropres diropres;
	struct stat     stat_holder;
	char           *pathp;
	char            fullpath[PATH_MAX];
	vxfh_t         *vxfhp;
	int             fd;

	nfsd_debug("create\n");

	bzero(&diropres, sizeof(diropres));

	vxfhp = (vxfh_t *) & (createargp->where.dir);

	if ((pathp = fh2path(vxfhp)) == NULL) {
		diropres.status = NFSERR_NOENT;
		return (&diropres);
	}
	if (pathCat(pathp, createargp->where.name, fullpath) != OK) {
		diropres.status = errnoGet();
		return (&diropres);
	}
	if (stat(fullpath, &stat_holder) == OK) {
		diropres.status = NFSERR_EXIST;
		return (&diropres);
	}
	nfsd_debug("creat: mode %x uid %x gid %x sz %x atime %x mtime %x\n",
		   createargp->attributes.mode,
		   createargp->attributes.uid,
		   createargp->attributes.gid,
		   createargp->attributes.size,
		   createargp->attributes.atime,
		   createargp->attributes.mtime
		);

	if ((fd = open(fullpath, O_RDWR | O_CREAT | O_TRUNC,
		       createargp->attributes.mode)) < 0) {
		diropres.status = errnoGet();
		return (&diropres);
	}
	if (vxfhp->type == rt11FsDrvNum) {
		lseek(fd, rt11_create_size, SEEK_SET);
		write(fd, "$", 1);
	}
	close(fd);

	vxfhp = (vxfh_t *) & diropres.diropres_u.diropres.file;

	if (newfh(vxfhp, fullpath) == OK &&
	    get_attrstat(fullpath,
			 &diropres.diropres_u.diropres.attributes,
			 vxfhp) == OK) {
		diropres.status = NFS_OK;
		return (&diropres);
	}
	diropres.status = errnoGet();
	return (&diropres);
}
示例#2
0
文件: nfsd.c 项目: netdebug/vxnfsd
diropres       *
nfsproc_lookup_2(diropargs * diropargp, struct svc_req * reqp)
{
	static diropres diropres;
	char            fullpath[PATH_MAX + 1];
	char           *pathp;
	vxfh_t         *vxfhp;

	nfsd_debug("lookup\n");

	bzero(&diropres, sizeof(diropres));

	vxfhp = (vxfh_t *) & (diropargp->dir);

	if ((pathp = fh2path(vxfhp)) == NULL) {
		diropres.status = NFSERR_NOENT;
		return (&diropres);
	}
	vxfhp = (vxfh_t *) & diropres.diropres_u.diropres.file;

	if (pathCat(pathp, diropargp->name, fullpath) == OK &&
	    newfh(vxfhp, fullpath) == OK &&
	    get_attrstat(fullpath,
			 &diropres.diropres_u.diropres.attributes,
			 vxfhp) == OK) {
		diropres.status = NFS_OK;
		return (&diropres);
	}
	diropres.status = NFSERR_NOENT;
	return (&diropres);
}
示例#3
0
文件: nfsd.c 项目: netdebug/vxnfsd
nfsstat        *
nfsproc_rename_2(renameargs * renameargp, struct svc_req * reqp)
{
	static nfsstat  nfsstat;
	char           *pathp;
	char            from[PATH_MAX];
	char            to[PATH_MAX];
	vxfh_t         *vxfhp;

	nfsd_debug("rename\n");

	bzero(&nfsstat, sizeof(nfsstat));

	vxfhp = (vxfh_t *) & (renameargp->from);

	if ((pathp = fh2path(vxfhp)) == NULL) {
		nfsstat = NFSERR_NOENT;
		return (&nfsstat);
	}
	if (pathCat(pathp, renameargp->from.name, from) == ERROR) {
		nfsstat = NFSERR_IO;
		return (&nfsstat);
	}
	vxfhp = (vxfh_t *) & (renameargp->to);

	if ((pathp = fh2path(vxfhp)) == NULL) {
		nfsstat = NFSERR_NOENT;
		return (&nfsstat);
	}
	if (pathCat(pathp, renameargp->to.name, to) == ERROR) {
		nfsstat = NFSERR_IO;
		return (&nfsstat);
	}
	if (rename(from, to) == ERROR) {
		nfsstat = errnoGet();
		return (&nfsstat);
	}
	nfsstat = NFS_OK;

	return (&nfsstat);
}
示例#4
0
文件: nfsd.c 项目: netdebug/vxnfsd
diropres       *
nfsproc_mkdir_2(createargs * createargp, struct svc_req * reqp)
{
	static diropres diropres;
	vxfh_t         *vxfhp;
	char           *pathp;
	struct stat     stat_holder;
	char            fullpath[PATH_MAX];

	nfsd_debug("mkdir\n");

	bzero(&diropres, sizeof(diropres));

	vxfhp = (vxfh_t *) & (createargp->where.dir);

	if (vxfhp->type != dosFsDrvNum) {
		diropres.status = NFSERR_IO;	/* XXX bogus */
		return (&diropres);
	}
	if ((pathp = fh2path(vxfhp)) == NULL) {
		diropres.status = NFSERR_NOENT;
		return (&diropres);
	}
	if (pathCat(pathp, createargp->where.name, fullpath) != OK) {
		diropres.status = errnoGet();
		return (&diropres);
	}
	if (stat(fullpath, &stat_holder) == OK) {
		diropres.status = NFSERR_EXIST;
		return (&diropres);
	}
	nfsd_debug("mkdir: attrib.mode 0%o\n", createargp->attributes.mode);

	if (mkdir(fullpath) == ERROR) {
		diropres.status = errnoGet();
		return (&diropres);
	}
	if (newfh(vxfhp, fullpath) == OK &&
	    get_attrstat(fullpath,
			 &diropres.diropres_u.diropres.attributes,
			 vxfhp) == OK) {
		diropres.status = NFS_OK;
		return (&diropres);
	}
	diropres.status = errnoGet();
	return (&diropres);
}
示例#5
0
文件: nfsd.c 项目: netdebug/vxnfsd
nfsstat        *
nfsproc_rmdir_2(diropargs * diropargp, struct svc_req * reqp)
{
	static nfsstat  nfsstat;
	vxfh_t         *vxfhp;
	char           *pathp;
	char            fullpath[PATH_MAX + 1];

	nfsd_debug("rmdir\n");

	bzero(&nfsstat, sizeof(nfsstat));

	vxfhp = (vxfh_t *) & (diropargp->dir);

	if (vxfhp->type != dosFsDrvNum) {
		nfsstat = NFSERR_IO;	/* XXX bogus */
		return (&nfsstat);
	}
	if ((pathp = fh2path(vxfhp)) == NULL) {
		nfsstat = NFSERR_NOENT;
		return (&nfsstat);
	}
	if (pathCat(pathp, diropargp->name, fullpath) == ERROR) {
		nfsstat = NFSERR_IO;
		return (&nfsstat);
	}
	nfsd_debug("rmdir: path <%s>\n", fullpath);

	if (rmdir(fullpath) == ERROR) {
		nfsstat = NFSERR_NOENT;
		nfsd_debugno();
		return (&nfsstat);
	}
	nfsstat = NFS_OK;

	if (symRemove(nfsd_pathtab, fullpath,
		      (SYM_TYPE) NFSD_MSDOS_TYPE) != OK) {
		nfsstat = NFSERR_IO;	/* XXX bogus */
		nfsd_debugno();
		return (&nfsstat);
	}
	return (&nfsstat);
}
示例#6
0
int main(int argc, char *argv[]){
	glutInit(&argc, argv);
	GameDebugger* debugger = GameDebugger::GetInstance();
	assert(debugger->OpenDebugFile());
	debugger->WriteDebugMessageToConsole("Hello, World", 31);
	debugger->WriteToDebugFile("Wrote to file", 32);
	
	TaskQueue *taskManager = new TaskQueue(NUM_THREADS);
	ConsoleCreateRoom();

	GameRoom gr; 	

	if (argc > 1){
		string path = pathCat(GAME_DATA_ROOMS_FOLDER, argv[1]);
		GameRoom::LoadRoom(path.c_str(), gr);
	}

	//For testing purposes.  To make sure it reads debug.room
	char debugName[1000];
	strcpy(debugName, GAME_DATA_ROOMS_FOLDER);
	strcat(debugName, "debug.room");
	GameRoom debug;
	assert(GameRoom::LoadRoom(debugName, debug));
	vector<GameObject*> obs = debug.GetGameObjects();
	//map<string, GameWorldObject>::iterator wobs = debug.GetRoomWorldObjectsIterator();
	for(unsigned int w = 0; w<obs.size(); w++){
		//load starting meshes
		GameObject *gwo = obs[w];
		cout<<gwo->GetName()<<endl;
		MyMesh *tmp = new MyMesh();
		if (gwo->GetMeshFile()){
			string fname = pathCat(".", gwo->GetMeshFile()); 
			if (! MyMeshIO::LoadMesh(*tmp, fname)){
				cerr<<"couldn't load (" << gwo->GetMeshFile() << ") for " <<gwo -> GetName() <<endl;  
				gwo->SetMesh(NULL);
			}else{
				gwo->SetMesh(tmp);
				NavShot::room = tmp;
			}
		} 		
	}

	ComputeBoundingBoxesAndPhysicsConstants(obs);

	//cin.ignore(1);
	///////////////////////////////////////////////////
	
	//TODO: load from file	
	GameState *gs = GameState::GetInstance(); 
	Vector3f pos(0.0f, 0, -10.0f); 
	Vector3f up(0, 1.0f, 0); 
	Vector3f dir(0.0f, 0, 1.0f); 
	float radius =0, n = 0.1, f = 600, fovy = 80, aspect = ((float)16.0/9.0); 
	Camera cam(pos, dir, up, radius, n, f, fovy, aspect); 
	gs->SetRoom(&debug);
	gs->SetCamera(&cam);
	Vector3f enemyPos(0.0f, 3.0f, 10.0f);
	gs->AddActor(new MetaballEnemy(enemyPos, 2, 2.0f));
	Render::gameState = gs;
	Render::GlutInitialize();
	SCollision::gameState = gs;
	
	RegisterControls(); 
	Controller::Initialize(taskManager, gs); 	
	
	
	/////////////////////////////////////////////////
	// TO DO:
	// Pass GameRoom debug to Render module.  Render the 
	// room.
	/////////////////////////////////////////////////
	glutTimerFunc(0, Controller::GlutSync, 0);
	//glutMotionFunc(mouseMoveCB);
	//glutMouseFunc(mouseFunc);
	Sound::InitializeSounds();
	Music *music = new Music("sounds/run2.ogg", 0.3f);
	music->Loop();
	Sound *backgroundNoise = new Sound("sounds/metallic_roar.wav", 0.2f);
	backgroundNoise->Loop();
	glutMainLoop(); //this should only be called once, and AT THE END of the initialization routine.
	Sound::UninitializeSounds();
	assert(debugger->CloseDebugFile());
	return 0;
}