Krishna iResearch Intelligent Cloud Platform - VIRtual Generic Os - VIRGO - Linux kernel extensions for cloud
 All Classes
virgo_fs.h
1 /***************************************************************************************
2 VIRGO - a linux module extension with CPU and Memory pooling with cloud capabilities
3 
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 --------------------------------------------------------------------------------------------------
18 Copyright(C):
19 Srinivasan Kannan (alias) Ka.Shrinivaasan (alias) Shrinivas Kannan
20 Independent Open Source Developer, Researcher and Consultant
21 Ph: 9003082186, 9791165980
22 Open Source Products Profile(Krishna iResearch): http://sourceforge.net/users/ka_shrinivaasan, http://ohloh.net/accounts/ka_shrinivaasan
23 Personal website(research): https://sites.google.com/site/kuja27/
24 emails: ka.shrinivaasan@gmail.com, shrinivas.kannan@gmail.com, kashrinivaasan@live.com
25 --------------------------------------------------------------------------------------------------
26 
27 *****************************************************************************************/
28 
29 /*
30  VIRGO File System related datastructures and driver ops
31 */
32 
33 #ifndef _VIRGO_FS_H_
34 #define _VIRGO_FS_H_
35 
36 #include <linux/ioport.h>
37 #include <linux/kobject.h>
38 #include <linux/klist.h>
39 #include <linux/list.h>
40 #include <linux/lockdep.h>
41 #include <linux/compiler.h>
42 #include <linux/types.h>
43 #include <linux/mutex.h>
44 #include <linux/pm.h>
45 #include <linux/atomic.h>
46 #include <linux/ratelimit.h>
47 #include <asm/device.h>
48 #include <linux/time.h>
49 
50 #include <linux/kernel.h>
51 #include <linux/kthread.h>
52 #include <linux/sched.h>
53 #include <linux/module.h>
54 #include <linux/errno.h>
55 #include <linux/fcntl.h>
56 #include <linux/net.h>
57 #include <linux/in.h>
58 #include <linux/inet.h>
59 #include <linux/udp.h>
60 #include <linux/tcp.h>
61 #include <linux/string.h>
62 #include <linux/unistd.h>
63 #include <linux/slab.h>
64 #include <linux/netdevice.h>
65 #include <linux/skbuff.h>
66 #include <linux/file.h>
67 #include <linux/freezer.h>
68 #include <net/sock.h>
69 #include <net/checksum.h>
70 #include <net/ip.h>
71 #include <net/ipv6.h>
72 #include <net/tcp.h>
73 #include <net/tcp_states.h>
74 #include <asm/uaccess.h>
75 #include <asm/ioctls.h>
76 #include <trace/events/skb.h>
77 
78 #include <linux/module.h>
79 #include <linux/types.h>
80 #include <linux/uio.h>
81 #include <linux/unistd.h>
82 
83 #include <linux/sunrpc/types.h>
84 #include <linux/sunrpc/clnt.h>
85 #include <linux/sunrpc/xdr.h>
86 #include <linux/sunrpc/msg_prot.h>
87 #include <linux/sunrpc/svcsock.h>
88 #include <linux/sunrpc/stats.h>
89 #include <linux/sunrpc/xprt.h>
90 #include <linux/sunrpc/xprt.h>
91 
92 #define BUF_SIZE 500
93 
94 struct hostport
95 {
96  char* hostip;
97  int port;
98 };
99 
100 struct virgo_fs_args
101 {
102  char* fs_cmd;
103  char* fs_args[5];
104  char* fsFunction;
105  char* ptr;
106  char* data;
107 };
108 
109 
110 struct hostport* get_least_loaded_hostport_from_cloud_fs();
111 char* get_host_from_cloud_Loadtrack_fs();
112 char* get_host_from_cloud_PRG_fs();
113 char* int_to_str(int);
114 char* addr_to_str(char*);
115 char* str_to_addr(char*);
116 char* str_to_addr2(char* straddr);
117 
118 unsigned long addr_to_virgo_unique_id(struct virgo_address* vaddr);
119 struct virgo_address* virgo_unique_id_to_addr(unsigned long virgo_unique_id);
120 
121 typedef void* (*FPTR)(struct virgo_fs_args* args);
122 
123 void var_sscanf(char *str, const char* fmt, ...);
124 
125 struct mutex virgo_fs_mutex;
126 
127 FPTR toFuncPtr(char*);
128 struct virgo_fs_args* parse_virgofs_command(char* fsFunction);
129 
130 int virgocloudexec_fs_create(void);
131 void* virgocloudexec_fs_recvfrom(struct socket*);
132 int virgocloudexec_fs_sendto(struct socket*, void* virgo_fs_ret);
133 
134 int virgo_cloudexec_fs_service(void* args);
135 void do_virgocloudexec_init(void);
136 
137 extern void* virgo_cloud_open_kernelspace(struct virgo_fs_args* args);
138 extern void* virgo_cloud_close_kernelspace(struct virgo_fs_args* args);
139 extern void* virgo_cloud_read_kernelspace(struct virgo_fs_args* args);
140 extern void* virgo_cloud_write_kernelspace(struct virgo_fs_args* args);
141 extern char* toKernelAddress(const char* str);
142 
144  int (*virgo_fs_create)(void);
145  void* (*virgo_fs_recvfrom)(struct socket*);
146  int (*virgo_fs_sendto)(struct socket*,void* virgo_fs_ret);
147 };
148 
149 static struct virgo_fs_ops_t virgo_fs_ops = {
150  .virgo_fs_create = virgocloudexec_fs_create,
151  .virgo_fs_recvfrom = virgocloudexec_fs_recvfrom,
152  .virgo_fs_sendto = virgocloudexec_fs_sendto
153 };
154 
156  const char* m_virgo_name;
157  struct module* m_virgo_owner;
158  struct virgo_ops_t* m_virgo_ops;
159 };
160 
161 static struct virgo_fs_class_t virgo_fs_class = {
162  .m_virgo_name = "virgo_fs",
163  .m_virgo_owner = THIS_MODULE,
164  .m_virgo_ops = &virgo_fs_ops
165 };
166 
167 static struct socket *sock;
168 
169 int parameterIsExecutable=2;
170 struct file* file_stdout;
171 
172 void print_buffer(char*);
173 int tokenize_list_of_ip_addrs(char* buf);
174 void read_virgo_config();
175 int kernel_space_func(void* args);
176 char* strip_control_M(char*);
177 
178 int virgo_fs_client_thread(void* args);
179 
180 
181 extern int virgo_cloud_test_kernelspace(void* args);
182 
183 
184 /* File segment for virgo_fs syscalls serverside that invoke VFS kernel functions*/
185 mm_segment_t fs;
186 
187 /* Array to keep track of number of open files and generate unique VFS file descriptor for the client */
188 int no_of_openfiles=-1;
189 struct file* open_VFS_files[256];
190 
191 char* toVFSString(int* data);
192 
193 
194 #endif /* _VIRGO_FS_H_ */
195