⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comm.v1.c

📁 一个LINUX下一个框架文件系统,运行编译环境:RED HAT LINUX7.3
💻 C
字号:
#include "common.h"
#include "mytypes.h"

/*	This is the communication module of the simple NFS
	the communication implemented here is rather simple:
	TCP one-one diagram
	send the request to the server with a specially defined structure
	and then receive back a structure (also specified firstly)

   Important: Non-ReEnterable, single on single back!
*/

extern struct 	socket *		tcpsock;
extern struct	sockaddr_in	    tcpsin;

extern int tcp_create_socket();
extern int tcp_sendbuffer(struct socket *sock, const char *buffer,const size_t length);
extern int tcp_recvbuffer(struct socket *sock, char *buffer, const size_t buflen);

struct outmessage{
	int		type;		//loop up == 1
	char	dirname[200];
};

struct inmessage{
	int		type;
	struct myfs_meta meta;
};

int lookup_root( char* dirname, struct myfs_meta *pmeta )
{
	struct outmessage*	poutmes;
	struct inmessage	inmes;

	poutmes = kmalloc( sizeof( struct outmessage ), GFP_KERNEL );
	poutmes->type = 1;
	sprintf( poutmes->dirname, "%s", dirname );

	//ready to communcation
	tcp_create_socket();
	tcp_sendbuffer( tcpsock, (char*)poutmes, sizeof( struct outmessage ) );
	tcp_recvbuffer( tcpsock, (char*)&inmes, sizeof( struct inmessage ) );
	sock_release( tcpsock );

	if (inmes.type == 1){
		printk( "The Incomming message is valid!\n" );
		memcpy( pmeta, &inmes.meta, sizeof(struct myfs_meta) );
	}else{
		return -1;
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -