summaryrefslogtreecommitdiff
path: root/fs/novfs/vfs.h
blob: ba2494d2386fd4cba95ae49fed005517f5be2418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
/*
 * Novell NCP Redirector for Linux
 * Author: James Turner
 *
 * Include file for novfs.
 *
 * Copyright (C) 2005 Novell, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 */
#ifndef __NOVFS_H
#define __NOVFS_H

#ifndef __STDC_VERSION__
#define __STDC_VERSION__ 0L
#endif

#include <linux/version.h>
#include <linux/namei.h>

#include "nwcapi.h"

typedef void *HANDLE;

typedef struct _SCHANDLE {
	HANDLE hTypeId;
	HANDLE hId;

} SCHANDLE, *PSCHANDLE;

typedef SCHANDLE scope_t;
typedef SCHANDLE session_t;

#include "commands.h"

#define SC_PRESENT(X)		((X.hTypeId != NULL) || (X.hId != NULL)) ? 1 : 0
#define SC_EQUAL(X, Y)		((X.hTypeId == Y.hTypeId) && (X.hId == Y.hId)) ? 1 : 0
#define SC_INITIALIZE(X)	{X.hTypeId = X.hId = NULL;}

#define UID_TO_SCHANDLE(hSC, uid)	\
		{ \
			hSC.hTypeId = NULL; \
			hSC.hId = (HANDLE)(unsigned long)(uid); \
		}



/*===[ Manifest constants ]===============================================*/
#define NOVFS_MAGIC		0x4e574653
#define MODULE_NAME		"novfs"

#define TREE_DIRECTORY_NAME	".Trees"
#define SERVER_DIRECTORY_NAME	".Servers"

#define PATH_LENGTH_BUFFER	PATH_MAX
#define NW_MAX_PATH_LENGTH	255

#define XA_BUFFER		(8 * 1024)

#define IOC_LOGIN		0x4a540000
#define IOC_LOGOUT		0x4a540001
#define IOC_XPLAT		0x4a540002
#define IOC_SESSION		0x4a540003
#define IOC_DEBUGPRINT		0x4a540004

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
#define D_CHILD d_u.d_child
#define AS_TREE_LOCK(l)   read_lock_irq(l)
#define AS_TREE_UNLOCK(l) read_unlock_irq(l)
#else
#define D_CHILD d_child
#define AS_TREE_LOCK(l)   spin_lock_irq(l)
#define AS_TREE_UNLOCK(l) spin_unlock_irq(l)
#endif

/*
 * NetWare file attributes
 */

#define NW_ATTRIBUTE_NORMAL		0x00
#define NW_ATTRIBUTE_READ_ONLY		0x01
#define NW_ATTRIBUTE_HIDDEN		0x02
#define NW_ATTRIBUTE_SYSTEM		0x04
#define NW_ATTRIBUTE_EXECUTE_ONLY	0x08
#define NW_ATTRIBUTE_DIRECTORY		0x10
#define NW_ATTRIBUTE_ARCHIVE		0x20
#define NW_ATTRIBUTE_EXECUTE		0x40
#define NW_ATTRIBUTE_SHAREABLE		0x80

/*
 * Define READ/WRITE flag for DATA_LIST
 */
#define DLREAD		0
#define DLWRITE		1

/*
 * Define list type
 */
#define USER_LIST	1
#define SERVER_LIST	2
#define VOLUME_LIST	3

/*
 * Define flags used in for inodes
 */
#define USER_INODE	1
#define UPDATE_INODE	2

/*
 * Define flags for directory cache flags
 */
#define ENTRY_VALID	0x00000001

#ifdef INTENT_MAGIC
#define NDOPENFLAGS intent.it_flags
#else
#define NDOPENFLAGS intent.open.flags
#endif

/*
 * daemon_command_t flags values
 */
#define INTERRUPTIBLE	1

#ifndef NOVFS_VFS_MAJOR
#define NOVFS_VFS_MAJOR		0
#endif

#ifndef NOVFS_VFS_MINOR
#define NOVFS_VFS_MINOR		0
#endif

#ifndef NOVFS_VFS_SUB
#define NOVFS_VFS_SUB		0
#endif

#ifndef NOVFS_VFS_RELEASE
#define NOVFS_VFS_RELEASE	0
#endif

#define VALUE_TO_STR( value ) #value
#define DEFINE_TO_STR(value) VALUE_TO_STR(value)

#define NOVFS_VERSION_STRING \
         DEFINE_TO_STR(NOVFS_VFS_MAJOR)"." \
         DEFINE_TO_STR(NOVFS_VFS_MINOR)"." \
         DEFINE_TO_STR(NOVFS_VFS_SUB)"-" \
         DEFINE_TO_STR(NOVFS_VFS_RELEASE) \
         "\0"

/*===[ Type definitions ]=================================================*/
typedef struct _ENTRY_INFO {
	int type;
	umode_t mode;
	uid_t uid;
	gid_t gid;
	loff_t size;
	struct timespec atime;
	struct timespec mtime;
	struct timespec ctime;
	int namelength;
	unsigned char name[1];
} ENTRY_INFO, *PENTRY_INFO;

struct novfs_string {
	int length;
	unsigned char *data;
};

typedef struct _LOGIN_ {
	struct novfs_string Server;
	struct novfs_string UserName;
	struct novfs_string Password;
} LOGIN, *PLOGIN;

typedef struct _LOGOUT_ {
	struct novfs_string Server;
} LOGOUT, *PLOGOUT;

typedef struct _DIR_CACHE_ {
	struct list_head list;
	int flags;
	u64 jiffies;
	ino_t ino;
	loff_t size;
	umode_t mode;
	struct timespec atime;
	struct timespec mtime;
	struct timespec ctime;
	unsigned long hash;
	int nameLen;
	char name[1];
} DIR_CACHE, *PDIR_CACHE;

typedef struct _INODE_DATA_ {
	void *Scope;
	unsigned long Flags;
	struct list_head IList;
	struct inode *Inode;
	unsigned long cntDC;
	struct list_head DirCache;
	struct semaphore DirCacheLock;
	HANDLE FileHandle;
	int CacheFlag;
	char Name[1];		/* Needs to be last entry */
} INODE_DATA, *PINODE_DATA;

typedef struct _DATA_LIST_ {
	void *page;
	void *offset;
	int len;
	int rwflag;
} DATA_LIST, *PDATA_LIST;


extern char *ctime_r(time_t * clock, char *buf);

static inline u32 HandletoUint32(HANDLE h)
/*
 *
 *  Arguments:   HANDLE h - handle value
 *
 *  Returns:     u32 - u32 value
 *
 *  Abstract:    Converts a HANDLE to a u32 type.
 *
 *  Notes:
 *
 *  Environment:
 *
 *========================================================================*/
{
	return (u32) ((unsigned long) h);
}

/*++======================================================================*/
static inline HANDLE Uint32toHandle(u32 ui32)
/*
 *
 *  Arguments:   u32 ui32
 *
 *  Returns:     HANDLE - Handle type.
 *
 *  Abstract:    Converts a u32 to a HANDLE type.
 *
 *  Notes:
 *
 *  Environment:
 *
 *========================================================================*/
{
	return ((HANDLE) (unsigned long) ui32);
}

/* Global variables */

extern int Novfs_Version_Major;
extern int Novfs_Version_Minor;
extern int Novfs_Version_Sub;
extern int Novfs_Version_Release;
extern struct dentry *Novfs_root;
extern struct proc_dir_entry *Novfs_Procfs_dir;
extern unsigned long File_update_timeout;
extern int PageCache;
extern char *Novfs_CurrentMount;
extern struct dentry_operations Novfs_dentry_operations;
extern int MaxIoSize;


/* Global functions */
extern int Novfs_Remove_from_Root(char *);
extern void Novfs_dump_inode(void *pf);

extern void mydump(int size, void *dumpptr);

extern int Queue_Daemon_Command(void *request, unsigned long reqlen, void *data,
				int dlen, void **reply, unsigned long * replen,
				int interruptible);
extern int do_login(NclString * Server, NclString * Username, NclString * Password, HANDLE * lgnId, session_t Session);

extern int Init_Procfs_Interface(void);
extern void Uninit_Procfs_Interface(void);

/*
 * daemon.c functions
 */
extern void Init_Daemon_Queue(void);
extern void Uninit_Daemon_Queue(void);
extern int do_logout(struct qstr *Server, session_t Session);
extern int Daemon_SetMountPoint(char *Path);
extern int Daemon_CreateSessionId(SCHANDLE * SessionId);
extern int Daemon_DestroySessionId(SCHANDLE SessionId);
extern int Daemon_getpwuid(uid_t uid, int unamelen, char *uname);
extern int Daemon_Get_UserSpace(SCHANDLE SessionId, uint64_t * TotalSize, uint64_t * TotalFree, uint64_t * TotalDirectoryEnties, uint64_t * FreeDirectoryEnties);
extern int Daemon_SendDebugCmd(char *Command);
extern ssize_t Daemon_Receive_Reply(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos);
extern ssize_t Daemon_Send_Command(struct file *file, char __user *buf, size_t len, loff_t *off);
extern int Daemon_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
extern int Daemon_Library_close(struct inode *inode, struct file *file);
extern int Daemon_Library_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
extern int Daemon_Library_open(struct inode *inode, struct file *file);
extern ssize_t Daemon_Library_write(struct file *file, const char __user *buf, size_t len, loff_t * off);
extern ssize_t Daemon_Library_read(struct file *file, char __user *buf, size_t len, loff_t * off);
extern loff_t Daemon_Library_llseek(struct file *file, loff_t offset, int origin);
extern int Daemon_Open_Control(struct inode *Inode, struct file *File);
extern int Daemon_Close_Control(struct inode *Inode, struct file *File);
extern int Daemon_getversion(char *Buf, int Length);


/*
 * file.c functions
 */
extern int Novfs_verify_file(struct qstr *Path, session_t SessionId);
extern int Novfs_get_alltrees(struct dentry *parent);
extern int Novfs_Get_Connected_Server_List(unsigned char **ServerList, session_t SessionId);
extern int Novfs_Get_Server_Volume_List(struct qstr *Server, unsigned char **VolumeList, session_t SessionId);
extern int Novfs_Verify_Server_Name(struct qstr *Server, session_t SessionId);
extern int Novfs_Get_File_Info(unsigned char *Path, PENTRY_INFO Info, session_t SessionId);
extern int Novfs_GetX_File_Info(char *Path, const char *Name, char *buffer, ssize_t buffer_size, ssize_t *dataLen, session_t SessionId);
extern int Novfs_ListX_File_Info(char *Path, char *buffer, ssize_t buffer_size, ssize_t * dataLen, session_t SessionId);
extern int Novfs_SetX_File_Info(char *Path, const char *Name, const void *Value,
				unsigned long valueLen,
				unsigned long *bytesWritten, int flags,
				session_t SessionId);

extern int Novfs_Get_Directory_List(unsigned char *Path, HANDLE * EnumHandle,
				    PENTRY_INFO Info, session_t SessionId);
extern int Novfs_Get_Directory_ListEx(unsigned char *Path, HANDLE * EnumHandle,
				      int *Count, PENTRY_INFO * Info,
				      session_t SessionId);
extern int Novfs_Open_File(unsigned char *Path, int Flags, PENTRY_INFO Info,
			   HANDLE * Handle, session_t SessionId);
extern int Novfs_Create(unsigned char *Path, int DirectoryFlag,
			session_t SessionId);
extern int Novfs_Close_File(HANDLE Handle, session_t SessionId);
extern int Novfs_Read_File(HANDLE Handle, unsigned char *Buffer, size_t * Bytes,
			   loff_t * Offset, session_t SessionId);
extern int Novfs_Read_Pages(HANDLE Handle, PDATA_LIST DList, int DList_Cnt,
			    size_t * Bytes, loff_t * Offset,
			    session_t SessionId);
extern int Novfs_Write_File(HANDLE Handle, unsigned char *Buffer,
			    size_t * Bytes, loff_t * Offset,
			    session_t SessionId);
extern int Novfs_Write_Page(HANDLE Handle, struct page *Page,
			    session_t SessionId);
extern int Novfs_Write_Pages(HANDLE Handle, PDATA_LIST DList, int DList_Cnt,
			     size_t Bytes, loff_t Offset, session_t SessionId);
extern int Novfs_Delete(unsigned char *Path, int DirectoryFlag,
			session_t SessionId);
extern int Novfs_Truncate_File(unsigned char *Path, int PathLen,
			       session_t SessionId);
extern int Novfs_Truncate_File_Ex(HANDLE Handle, loff_t Offset,
				  session_t SessionId);
extern int Novfs_Rename_File(int DirectoryFlag, unsigned char *OldName,
			     int OldLen, unsigned char *NewName, int NewLen,
			     session_t SessionId);
extern int Novfs_Set_Attr(unsigned char *Path, struct iattr *Attr,
			  session_t SessionId);
extern int Novfs_Get_File_Cache_Flag(unsigned char * Path, session_t SessionId);
extern int Novfs_Set_File_Lock(session_t SessionId, HANDLE fhandle,
			       unsigned char fl_type, loff_t fl_start,
			       loff_t len);

extern struct inode *Novfs_get_inode(struct super_block *sb, int mode, int dev, uid_t uid, ino_t ino, struct qstr *name);
extern int Novfs_Read_Stream(HANDLE ConnHandle, unsigned char * Handle,
			     unsigned char * Buffer, size_t * Bytes, loff_t * Offset,
			     int User, session_t SessionId);
extern int Novfs_Write_Stream(HANDLE ConnHandle, unsigned char * Handle,
			      unsigned char * Buffer, size_t * Bytes, loff_t * Offset,
			      session_t SessionId);
extern int Novfs_Close_Stream(HANDLE ConnHandle, unsigned char * Handle,
			      session_t SessionId);

extern int Novfs_Add_to_Root(char *);


/*
 * scope.c functions
 */
extern void Scope_Init(void);
extern void Scope_Uninit(void);
extern void *Scope_Lookup(void);
extern uid_t Scope_Get_Uid(void *);
extern session_t Scope_Get_SessionId(void *Scope);
//extern session_t Scope_Get_SessionId(PSCOPE_LIST Scope);
extern char *Scope_Get_ScopeUsers(void);
extern int Scope_Set_UserSpace(uint64_t * TotalSize, uint64_t * Free,
			       uint64_t * TotalEnties, uint64_t * FreeEnties);
extern int Scope_Get_UserSpace(uint64_t * TotalSize, uint64_t * Free,
			       uint64_t * TotalEnties, uint64_t * FreeEnties);
extern char *Scope_dget_path(struct dentry *Dentry, char *Buf,
			     unsigned int Buflen, int Flags);
extern char *Scope_Get_UserName(void);
extern void Scope_Cleanup(void);

/*
 * profile.c functions
 */
extern uint64_t get_nanosecond_time(void);
static inline void *Novfs_Malloc(size_t size, int flags) { return kmalloc(size, flags); }
extern int DbgPrint(char *Fmt, ...);
extern int init_profile(void);
extern void uninit_profile(void);

/*
 * nwcapi.c functions
 */
extern int NwAuthConnWithId(PXPLAT pdata, session_t Session);
extern int NwConnClose(PXPLAT pdata, HANDLE * Handle, session_t Session);
extern int NwGetConnInfo(PXPLAT pdata, session_t Session);
extern int NwSetConnInfo(PXPLAT pdata, session_t Session);
extern int NwGetDaemonVersion(PXPLAT pdata, session_t Session);
extern int NwGetIdentityInfo(PXPLAT pdata, session_t Session);
extern int NwLicenseConn(PXPLAT pdata, session_t Session);
extern int NwLoginIdentity(PXPLAT pdata, session_t Session);
extern int NwLogoutIdentity(PXPLAT pdata, session_t Session);
extern int NwOpenConnByAddr(PXPLAT pdata, HANDLE * Handle, session_t Session);
extern int NwOpenConnByName(PXPLAT pdata, HANDLE * Handle, session_t Session);
extern int NwOpenConnByRef(PXPLAT pdata, HANDLE * Handle, session_t Session);
extern int NwQueryFeature(PXPLAT pdata, session_t Session);
extern int NwRawSend(PXPLAT pdata, session_t Session);
extern int NwScanConnInfo(PXPLAT pdata, session_t Session);
extern int NwSysConnClose(PXPLAT pdata, unsigned long * Handle, session_t Session);
extern int NwUnAuthenticate(PXPLAT pdata, session_t Session);
extern int NwUnlicenseConn(PXPLAT pdata, session_t Session);
extern int NwcChangeAuthKey(PXPLAT pdata, session_t Session);
extern int NwcEnumIdentities(PXPLAT pdata, session_t Session);
extern int NwcGetDefaultNameCtx(PXPLAT pdata, session_t Session);
extern int NwcGetPreferredDSTree(PXPLAT pdata, session_t Session);
extern int NwcGetTreeMonitoredConn(PXPLAT pdata, session_t Session);
extern int NwcSetDefaultNameCtx(PXPLAT pdata, session_t Session);
extern int NwcSetPreferredDSTree(PXPLAT pdata, session_t Session);
extern int NwcSetPrimaryConn(PXPLAT pdata, session_t Session);
extern int NwcGetPrimaryConn(PXPLAT pdata, session_t Session);
extern int NwcSetMapDrive(PXPLAT pdata, session_t Session);
extern int NwcUnMapDrive(PXPLAT pdata, session_t Session);
extern int NwcEnumerateDrives(PXPLAT pdata, session_t Session);
extern int NwcGetBroadcastMessage(PXPLAT pdata, session_t Session);
extern int NwdSetKeyValue(PXPLAT pdata, session_t Session);
extern int NwdVerifyKeyValue(PXPLAT pdata, session_t Session);


#endif	/* __NOVFS_H */