Exemplo n.º 1
0
static void start(char *path, char *pathAlias)
{
	int i;
	CDatagramSocket DatagramSockets[SOCKET_NUM];
	CServerSocket ServerSockets[SOCKET_NUM];
	bool bSuccess;
	hostent *localHost;

	g_PortmapProg.Set(PROG_MOUNT, MOUNT_PORT);  //map port for mount
	g_PortmapProg.Set(PROG_NFS, NFS_PORT);  //map port for nfs
	g_NFSProg.SetUserID(g_nUID, g_nGID);  //set uid and gid of files
	g_MountProg.Export(path, pathAlias);  //export path for mount
	g_RPCServer.Set(PROG_PORTMAP, &g_PortmapProg);  //program for portmap
	g_RPCServer.Set(PROG_NFS, &g_NFSProg);  //program for nfs
	g_RPCServer.Set(PROG_MOUNT, &g_MountProg);  //program for mount
	g_RPCServer.SetLogOn(g_bLogOn);

	for (i = 0; i < SOCKET_NUM; i++)
	{
		DatagramSockets[i].SetListener(&g_RPCServer);
		ServerSockets[i].SetListener(&g_RPCServer);
	}

	bSuccess = false;
	if (ServerSockets[0].Open(PORTMAP_PORT, 3) && DatagramSockets[0].Open(PORTMAP_PORT))  //start portmap daemon
	{
		printf("Portmap daemon started\n");
		if (ServerSockets[1].Open(NFS_PORT, 10) && DatagramSockets[1].Open(NFS_PORT))  //start nfs daemon
		{
			printf("NFS daemon started\n");
			if (ServerSockets[2].Open(MOUNT_PORT, 3) && DatagramSockets[2].Open(MOUNT_PORT))  //start mount daemon
			{
				printf("Mount daemon started\n");
				bSuccess = true;  //all daemon started
			}
			else
				printf("Mount daemon starts failed.\n");
		}
		else
			printf("NFS daemon starts failed.\n");
	}
	else
		printf("Portmap daemon starts failed.\n");

	if (bSuccess)
	{
		localHost = gethostbyname("");
		printf("Local IP = %s\n", inet_ntoa (*(struct in_addr *)*localHost->h_addr_list));  //local address
		inputCommand();  //wait for commands
	}

	for (i = 0; i < SOCKET_NUM; i++)
	{
		DatagramSockets[i].Close();
		ServerSockets[i].Close();
	}
}
Exemplo n.º 2
0
static void mountPaths(std::vector<std::vector<std::string>> paths)
{
	int i;
	int numberOfElements = paths.size();

	for (i = 0; i < numberOfElements; i++) {
		char *pPath = (char*)paths[i][0].c_str();
		char *pPathAlias = (char*)paths[i][1].c_str();
		g_MountProg.Export(pPath, pPathAlias);  //export path for mount
	}
}