Import ncpfs 2.0.10

This commit is contained in:
ncpfs archive import
2026-04-28 20:39:58 +02:00
parent f88460b2e6
commit 1a5653d403
61 changed files with 2859 additions and 2704 deletions

View File

@@ -18,28 +18,30 @@
#define NCP_REQUEST (0x2222)
#define NCP_DEALLOC_SLOT_REQUEST (0x5555)
struct ncp_request_header {
__u16 type __attribute__ ((packed));
__u8 sequence __attribute__ ((packed));
__u8 conn_low __attribute__ ((packed));
__u8 task __attribute__ ((packed));
__u8 conn_high __attribute__ ((packed));
__u8 function __attribute__ ((packed));
__u8 data[0] __attribute__ ((packed));
struct ncp_request_header
{
__u16 type __attribute__((packed));
__u8 sequence __attribute__((packed));
__u8 conn_low __attribute__((packed));
__u8 task __attribute__((packed));
__u8 conn_high __attribute__((packed));
__u8 function __attribute__((packed));
__u8 data[0] __attribute__((packed));
};
#define NCP_REPLY (0x3333)
#define NCP_POSITIVE_ACK (0x9999)
struct ncp_reply_header {
__u16 type __attribute__ ((packed));
__u8 sequence __attribute__ ((packed));
__u8 conn_low __attribute__ ((packed));
__u8 task __attribute__ ((packed));
__u8 conn_high __attribute__ ((packed));
__u8 completion_code __attribute__ ((packed));
__u8 connection_state __attribute__ ((packed));
__u8 data[0] __attribute__ ((packed));
struct ncp_reply_header
{
__u16 type __attribute__((packed));
__u8 sequence __attribute__((packed));
__u8 conn_low __attribute__((packed));
__u8 task __attribute__((packed));
__u8 conn_high __attribute__((packed));
__u8 completion_code __attribute__((packed));
__u8 connection_state __attribute__((packed));
__u8 data[0] __attribute__((packed));
};
@@ -48,45 +50,50 @@ struct ncp_reply_header {
#define NCP_BINDERY_PQUEUE (0x0003)
#define NCP_BINDERY_FSERVER (0x0004)
#define NCP_BINDERY_NAME_LEN (48)
struct ncp_bindery_object {
__u32 object_id;
__u16 object_type;
__u8 object_name[NCP_BINDERY_NAME_LEN];
__u8 object_flags;
__u8 object_security;
__u8 object_has_prop;
struct ncp_bindery_object
{
__u32 object_id;
__u16 object_type;
__u8 object_name[NCP_BINDERY_NAME_LEN];
__u8 object_flags;
__u8 object_security;
__u8 object_has_prop;
};
struct nw_property {
__u8 value[128];
__u8 more_flag;
__u8 property_flag;
struct nw_property
{
__u8 value[128];
__u8 more_flag;
__u8 property_flag;
};
struct prop_net_address {
__u32 network __attribute__ ((packed));
__u8 node[IPX_NODE_LEN] __attribute__ ((packed));
__u16 port __attribute__ ((packed));
struct prop_net_address
{
__u32 network __attribute__((packed));
__u8 node[IPX_NODE_LEN] __attribute__((packed));
__u16 port __attribute__((packed));
};
#define NCP_VOLNAME_LEN (16)
#define NCP_NUMBER_OF_VOLUMES (64)
struct ncp_volume_info {
__u32 total_blocks;
__u32 free_blocks;
__u32 purgeable_blocks;
__u32 not_yet_purgeable_blocks;
__u32 total_dir_entries;
__u32 available_dir_entries;
__u8 sectors_per_block;
char volume_name[NCP_VOLNAME_LEN+1];
struct ncp_volume_info
{
__u32 total_blocks;
__u32 free_blocks;
__u32 purgeable_blocks;
__u32 not_yet_purgeable_blocks;
__u32 total_dir_entries;
__u32 available_dir_entries;
__u8 sectors_per_block;
char volume_name[NCP_VOLNAME_LEN + 1];
};
struct ncp_filesearch_info {
__u8 volume_number;
__u16 directory_id;
__u16 sequence_no;
__u8 access_rights;
struct ncp_filesearch_info
{
__u8 volume_number;
__u16 directory_id;
__u16 sequence_no;
__u8 access_rights;
};
#define NCP_MAX_FILENAME 14
@@ -104,16 +111,17 @@ struct ncp_filesearch_info {
#define AR_EXCLUSIVE (0x20)
#define NCP_FILE_ID_LEN 6
struct ncp_file_info {
__u8 file_id[NCP_FILE_ID_LEN];
char file_name[NCP_MAX_FILENAME+1];
__u8 file_attributes;
__u8 file_mode;
__u32 file_length;
__u16 creation_date;
__u16 access_date;
__u16 update_date;
__u16 update_time;
struct ncp_file_info
{
__u8 file_id[NCP_FILE_ID_LEN];
char file_name[NCP_MAX_FILENAME + 1];
__u8 file_attributes;
__u8 file_mode;
__u32 file_length;
__u16 creation_date;
__u16 access_date;
__u16 update_date;
__u16 update_time;
};
/* Defines for Name Spaces */
@@ -165,32 +173,32 @@ struct ncp_file_info {
struct nw_info_struct
{
__u32 spaceAlloc __attribute__ ((packed));
__u32 attributes __attribute__ ((packed));
__u16 flags __attribute__ ((packed));
__u32 dataStreamSize __attribute__ ((packed));
__u32 totalStreamSize __attribute__ ((packed));
__u16 numberOfStreams __attribute__ ((packed));
__u16 creationTime __attribute__ ((packed));
__u16 creationDate __attribute__ ((packed));
__u32 creatorID __attribute__ ((packed));
__u16 modifyTime __attribute__ ((packed));
__u16 modifyDate __attribute__ ((packed));
__u32 modifierID __attribute__ ((packed));
__u16 lastAccessDate __attribute__ ((packed));
__u16 archiveTime __attribute__ ((packed));
__u16 archiveDate __attribute__ ((packed));
__u32 archiverID __attribute__ ((packed));
__u16 inheritedRightsMask __attribute__ ((packed));
__u32 dirEntNum __attribute__ ((packed));
__u32 DosDirNum __attribute__ ((packed));
__u32 volNumber __attribute__ ((packed));
__u32 EADataSize __attribute__ ((packed));
__u32 EAKeyCount __attribute__ ((packed));
__u32 EAKeySize __attribute__ ((packed));
__u32 NSCreator __attribute__ ((packed));
__u8 nameLen __attribute__ ((packed));
__u8 entryName[256] __attribute__ ((packed));
__u32 spaceAlloc __attribute__((packed));
__u32 attributes __attribute__((packed));
__u16 flags __attribute__((packed));
__u32 dataStreamSize __attribute__((packed));
__u32 totalStreamSize __attribute__((packed));
__u16 numberOfStreams __attribute__((packed));
__u16 creationTime __attribute__((packed));
__u16 creationDate __attribute__((packed));
__u32 creatorID __attribute__((packed));
__u16 modifyTime __attribute__((packed));
__u16 modifyDate __attribute__((packed));
__u32 modifierID __attribute__((packed));
__u16 lastAccessDate __attribute__((packed));
__u16 archiveTime __attribute__((packed));
__u16 archiveDate __attribute__((packed));
__u32 archiverID __attribute__((packed));
__u16 inheritedRightsMask __attribute__((packed));
__u32 dirEntNum __attribute__((packed));
__u32 DosDirNum __attribute__((packed));
__u32 volNumber __attribute__((packed));
__u32 EADataSize __attribute__((packed));
__u32 EAKeyCount __attribute__((packed));
__u32 EAKeySize __attribute__((packed));
__u32 NSCreator __attribute__((packed));
__u8 nameLen __attribute__((packed));
__u8 entryName[256] __attribute__((packed));
};
/* modify mask - use with MODIFY_DOS_INFO structure */
@@ -210,62 +218,66 @@ struct nw_info_struct
struct nw_modify_dos_info
{
__u32 attributes __attribute__ ((packed));
__u16 creationDate __attribute__ ((packed));
__u16 creationTime __attribute__ ((packed));
__u32 creatorID __attribute__ ((packed));
__u16 modifyDate __attribute__ ((packed));
__u16 modifyTime __attribute__ ((packed));
__u32 modifierID __attribute__ ((packed));
__u16 archiveDate __attribute__ ((packed));
__u16 archiveTime __attribute__ ((packed));
__u32 archiverID __attribute__ ((packed));
__u16 lastAccessDate __attribute__ ((packed));
__u16 inheritanceGrantMask __attribute__ ((packed));
__u16 inheritanceRevokeMask __attribute__ ((packed));
__u32 maximumSpace __attribute__ ((packed));
__u32 attributes __attribute__((packed));
__u16 creationDate __attribute__((packed));
__u16 creationTime __attribute__((packed));
__u32 creatorID __attribute__((packed));
__u16 modifyDate __attribute__((packed));
__u16 modifyTime __attribute__((packed));
__u32 modifierID __attribute__((packed));
__u16 archiveDate __attribute__((packed));
__u16 archiveTime __attribute__((packed));
__u32 archiverID __attribute__((packed));
__u16 lastAccessDate __attribute__((packed));
__u16 inheritanceGrantMask __attribute__((packed));
__u16 inheritanceRevokeMask __attribute__((packed));
__u32 maximumSpace __attribute__((packed));
};
struct nw_file_info {
struct nw_file_info
{
struct nw_info_struct i;
int opened;
int access;
__u32 server_file_handle __attribute__ ((packed));
__u8 open_create_action __attribute__ ((packed));
__u8 file_handle[6] __attribute__ ((packed));
int opened;
int access;
__u32 server_file_handle __attribute__((packed));
__u8 open_create_action __attribute__((packed));
__u8 file_handle[6] __attribute__((packed));
};
struct nw_search_sequence {
__u8 volNumber __attribute__ ((packed));
__u32 dirBase __attribute__ ((packed));
__u32 sequence __attribute__ ((packed));
struct nw_search_sequence
{
__u8 volNumber __attribute__((packed));
__u32 dirBase __attribute__((packed));
__u32 sequence __attribute__((packed));
};
struct nw_queue_job_entry {
__u16 InUse __attribute__ ((packed));
__u32 prev __attribute__ ((packed));
__u32 next __attribute__ ((packed));
__u32 ClientStation __attribute__ ((packed));
__u32 ClientTask __attribute__ ((packed));
__u32 ClientObjectID __attribute__ ((packed));
__u32 TargetServerID __attribute__ ((packed));
__u8 TargetExecTime[6] __attribute__ ((packed));
__u8 JobEntryTime[6] __attribute__ ((packed));
__u32 JobNumber __attribute__ ((packed));
__u16 JobType __attribute__ ((packed));
__u16 JobPosition __attribute__ ((packed));
__u16 JobControlFlags __attribute__ ((packed));
__u8 FileNameLen __attribute__ ((packed));
char JobFileName[13] __attribute__ ((packed));
__u32 JobFileHandle __attribute__ ((packed));
__u32 ServerStation __attribute__ ((packed));
__u32 ServerTaskNumber __attribute__ ((packed));
__u32 ServerObjectID __attribute__ ((packed));
char JobTextDescription[50] __attribute__ ((packed));
char ClientRecordArea[152] __attribute__ ((packed));
struct nw_queue_job_entry
{
__u16 InUse __attribute__((packed));
__u32 prev __attribute__((packed));
__u32 next __attribute__((packed));
__u32 ClientStation __attribute__((packed));
__u32 ClientTask __attribute__((packed));
__u32 ClientObjectID __attribute__((packed));
__u32 TargetServerID __attribute__((packed));
__u8 TargetExecTime[6] __attribute__((packed));
__u8 JobEntryTime[6] __attribute__((packed));
__u32 JobNumber __attribute__((packed));
__u16 JobType __attribute__((packed));
__u16 JobPosition __attribute__((packed));
__u16 JobControlFlags __attribute__((packed));
__u8 FileNameLen __attribute__((packed));
char JobFileName[13] __attribute__((packed));
__u32 JobFileHandle __attribute__((packed));
__u32 ServerStation __attribute__((packed));
__u32 ServerTaskNumber __attribute__((packed));
__u32 ServerObjectID __attribute__((packed));
char JobTextDescription[50] __attribute__((packed));
char ClientRecordArea[152] __attribute__((packed));
};
struct queue_job {
struct queue_job
{
struct nw_queue_job_entry j;
__u8 file_handle[6];
};
@@ -285,20 +297,21 @@ struct queue_job {
#define EXPAND_TABS 0x4000
#define PRINT_BANNER 0x8000
struct print_job_record {
__u8 Version __attribute__ ((packed));
__u8 TabSize __attribute__ ((packed));
__u16 Copies __attribute__ ((packed));
__u16 CtrlFlags __attribute__ ((packed));
__u16 Lines __attribute__ ((packed));
__u16 Rows __attribute__ ((packed));
char FormName[16] __attribute__ ((packed));
__u8 Reserved[6] __attribute__ ((packed));
char BannerName[13] __attribute__ ((packed));
char FnameBanner[13] __attribute__ ((packed));
char FnameHeader[14] __attribute__ ((packed));
char Path[80] __attribute__ ((packed));
struct print_job_record
{
__u8 Version __attribute__((packed));
__u8 TabSize __attribute__((packed));
__u16 Copies __attribute__((packed));
__u16 CtrlFlags __attribute__((packed));
__u16 Lines __attribute__((packed));
__u16 Rows __attribute__((packed));
char FormName[16] __attribute__((packed));
__u8 Reserved[6] __attribute__((packed));
char BannerName[13] __attribute__((packed));
char FnameBanner[13] __attribute__((packed));
char FnameHeader[14] __attribute__((packed));
char Path[80] __attribute__((packed));
};
#endif /* _LINUX_NCP_H */
#endif /* _LINUX_NCP_H */

View File

@@ -20,23 +20,25 @@
* ioctl commands
*/
struct ncp_ioctl_request {
unsigned int function;
unsigned int size;
char *data;
struct ncp_ioctl_request
{
unsigned int function;
unsigned int size;
char *data;
};
struct ncp_fs_info {
int version;
struct ncp_fs_info
{
int version;
struct sockaddr_ipx addr;
uid_t mounted_uid;
int connection; /* Connection number the server assigned us */
int buffer_size; /* The negotiated buffer size, to be
uid_t mounted_uid;
int connection; /* Connection number the server assigned us */
int buffer_size; /* The negotiated buffer size, to be
used for read/write requests! */
int volume_number;
__u32 directory_id;
};
int volume_number;
__u32 directory_id;
};
#define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
#define NCP_IOC_GETMOUNTUID _IOW('n', 2, uid_t)
@@ -84,24 +86,24 @@ extern int ncp_current_malloced;
static inline void *
ncp_kmalloc(unsigned int size, int priority)
{
ncp_malloced += 1;
ncp_current_malloced += 1;
return kmalloc(size, priority);
ncp_malloced += 1;
ncp_current_malloced += 1;
return kmalloc(size, priority);
}
static inline void
ncp_kfree_s(void *obj, int size)
{
ncp_current_malloced -= 1;
kfree_s(obj, size);
ncp_current_malloced -= 1;
kfree_s(obj, size);
}
#else /* DEBUG_NCP_MALLOC */
#else /* DEBUG_NCP_MALLOC */
#define ncp_kmalloc(s,p) kmalloc(s,p)
#define ncp_kfree_s(o,s) kfree_s(o,s)
#endif /* DEBUG_NCP_MALLOC */
#endif /* DEBUG_NCP_MALLOC */
#if DEBUG_NCP > 0
#define DPRINTK(format, args...) printk(format , ## args)
@@ -125,25 +127,25 @@ extern struct inode_operations ncp_dir_inode_operations;
void ncp_free_inode_info(struct ncp_inode_info *i);
void ncp_free_all_inodes(struct ncp_server *server);
void ncp_init_root(struct ncp_server *server);
int ncp_conn_logged_in(struct ncp_server *server);
int ncp_stat_root(struct ncp_server *server);
int ncp_conn_logged_in(struct ncp_server *server);
int ncp_stat_root(struct ncp_server *server);
void ncp_init_dir_cache(void);
void ncp_invalid_dir_cache(struct inode *ino);
struct ncp_inode_info *ncp_find_inode(struct inode *inode);
ino_t ncp_info_ino(struct ncp_server *server, struct ncp_inode_info *info);
void ncp_invalidate_all_inodes(struct ncp_server *server);
void ncp_free_dir_cache(void);
int ncp_date_dos2unix(__u16 time, __u16 date);
void ncp_date_unix2dos(int unix_date, __u16 *time, __u16 *date);
int ncp_date_dos2unix(__u16 time, __u16 date);
void ncp_date_unix2dos(int unix_date, __u16 * time, __u16 * date);
/* linux/fs/ncpfs/ioctl.c */
int ncp_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg);
int ncp_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
/* linux/fs/ncpfs/inode.c */
struct super_block *ncp_read_super(struct super_block *sb,
void *raw_data, int silent);
void *raw_data, int silent);
void ncp_invalidate_connection(struct ncp_server *server);
int ncp_conn_is_valid(struct ncp_server *server);
@@ -157,8 +159,8 @@ void ncp_lock_server(struct ncp_server *server);
void ncp_unlock_server(struct ncp_server *server);
/* linux/fs/ncpfs/mmap.c */
int ncp_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma);
int ncp_mmap(struct inode *inode, struct file *file, struct vm_area_struct *vma);
#endif /* __KERNEL__ */
#endif /* __KERNEL__ */
#endif /* _LINUX_NCP_FS_H */
#endif /* _LINUX_NCP_FS_H */

View File

@@ -12,22 +12,24 @@
#ifdef __KERNEL__
enum ncp_inode_state {
NCP_INODE_VALID = 19, /* Inode currently in use */
NCP_INODE_LOOKED_UP, /* directly before iget */
NCP_INODE_CACHED, /* in a path to an inode which is in use */
NCP_INODE_INVALID
enum ncp_inode_state
{
NCP_INODE_VALID = 19, /* Inode currently in use */
NCP_INODE_LOOKED_UP, /* directly before iget */
NCP_INODE_CACHED, /* in a path to an inode which is in use */
NCP_INODE_INVALID
};
/*
* ncp fs inode data (in memory only)
*/
struct ncp_inode_info {
enum ncp_inode_state state;
int nused; /* for directories:
number of references in memory */
struct ncp_inode_info *dir;
struct ncp_inode_info *next, *prev;
struct ncp_inode_info
{
enum ncp_inode_state state;
int nused; /* for directories:
number of references in memory */
struct ncp_inode_info *dir;
struct ncp_inode_info *next, *prev;
struct inode *inode;
struct nw_file_info finfo;
};

View File

@@ -15,11 +15,12 @@
#define NCP_DEFAULT_BUFSIZE 1024
struct ncp_server {
struct ncp_server
{
struct ncp_mount_data m; /* Nearly all of the mount data is of
interest for us later, so we store
it completely. */
struct ncp_mount_data m; /* Nearly all of the mount data is of
interest for us later, so we store
it completely. */
__u8 name_space[NCP_NUMBER_OF_VOLUMES];
@@ -30,32 +31,32 @@ struct ncp_server {
old one for checking purposes and
to reset it on unmounting. */
u8 sequence;
u8 task;
u16 connection; /* Remote connection number */
u8 sequence;
u8 task;
u16 connection; /* Remote connection number */
u8 completion; /* Status message from server */
u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
u8 completion; /* Status message from server */
u8 conn_status; /* Bit 4 = 1 ==> Server going down, no
requests allowed anymore.
Bit 0 = 1 ==> Server is down. */
int buffer_size; /* Negotiated bufsize */
int buffer_size; /* Negotiated bufsize */
int reply_size; /* Size of last reply */
int reply_size; /* Size of last reply */
int packet_size;
int packet_size;
unsigned char *packet; /* Here we prepare requests and
receive replies */
int lock; /* To prevent mismatch in protocols. */
int lock; /* To prevent mismatch in protocols. */
struct wait_queue *wait;
int current_size; /* for packet preparation */
int has_subfunction;
int ncp_reply_size;
int current_size; /* for packet preparation */
int has_subfunction;
int ncp_reply_size;
struct ncp_inode_info root;
char root_path; /* '\0' */
struct ncp_inode_info root;
char root_path; /* '\0' */
};
static inline int
@@ -70,6 +71,6 @@ ncp_invalidate_conn(struct ncp_server *server)
server->conn_status |= 0x01;
}
#endif /* __KERNEL__ */
#endif /* __KERNEL__ */
#endif

View File

@@ -22,28 +22,29 @@
#define NCP_MOUNT_SOFT 0x0001
#define NCP_MOUNT_INTR 0x0002
struct ncp_mount_data {
struct ncp_mount_data
{
int version;
unsigned int ncp_fd; /* The socket to the ncp port */
unsigned int wdog_fd; /* Watchdog packets come here */
unsigned int message_fd; /* Message notifications come here */
uid_t mounted_uid; /* Who may umount() this filesystem? */
unsigned int message_fd; /* Message notifications come here */
uid_t mounted_uid; /* Who may umount() this filesystem? */
struct sockaddr_ipx serv_addr;
unsigned char server_name[NCP_BINDERY_NAME_LEN];
unsigned char mount_point[PATH_MAX+1];
unsigned char mounted_vol[NCP_VOLNAME_LEN+1];
unsigned char mount_point[PATH_MAX + 1];
unsigned char mounted_vol[NCP_VOLNAME_LEN + 1];
unsigned int time_out; /* How long should I wait after
sending a NCP request? */
unsigned int retry_count; /* And how often should I retry? */
unsigned int retry_count; /* And how often should I retry? */
unsigned int flags;
uid_t uid;
gid_t gid;
mode_t file_mode;
mode_t dir_mode;
uid_t uid;
gid_t gid;
mode_t file_mode;
mode_t dir_mode;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -25,12 +25,13 @@
#include "ncplib_kernel.h"
#include <linux/malloc.h>
static inline int min(int a, int b)
static inline int
min(int a, int b)
{
return a<b ? a : b;
return a < b ? a : b;
}
static int
static int
ncp_fsync(struct inode *inode, struct file *file)
{
return 0;
@@ -39,23 +40,22 @@ ncp_fsync(struct inode *inode, struct file *file)
int
ncp_make_open(struct inode *i, int right)
{
struct nw_file_info *finfo;
struct nw_file_info *finfo;
if (i == NULL)
if (i == NULL)
{
printk("ncp_make_open: got NULL inode\n");
return -EINVAL;
}
printk("ncp_make_open: got NULL inode\n");
return -EINVAL;
}
finfo = NCP_FINFO(i);
finfo = NCP_FINFO(i);
DPRINTK("ncp_make_open: dirent->opened = %d\n", finfo->opened);
DPRINTK("ncp_make_open: dirent->opened = %d\n", finfo->opened);
lock_super(i->i_sb);
if (finfo->opened == 0)
if (finfo->opened == 0)
{
finfo->access = -1;
/* tries max. rights */
/* tries max. rights */
if (ncp_open_create_file_or_subdir(NCP_SERVER(i),
NULL, NULL,
OC_MODE_OPEN, 0,
@@ -63,38 +63,36 @@ ncp_make_open(struct inode *i, int right)
finfo) == 0)
{
finfo->access = O_RDWR;
}
else if (ncp_open_create_file_or_subdir(NCP_SERVER(i),
NULL, NULL,
OC_MODE_OPEN, 0,
AR_READ,
finfo) == 0)
} else if (ncp_open_create_file_or_subdir(NCP_SERVER(i),
NULL, NULL,
OC_MODE_OPEN, 0,
AR_READ,
finfo) == 0)
{
finfo->access = O_RDONLY;
}
}
}
unlock_super(i->i_sb);
if ( ((right == O_RDONLY) && ( (finfo->access == O_RDONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_WRONLY) && ( (finfo->access == O_WRONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_RDWR) && (finfo->access == O_RDWR)))
return 0;
if (((right == O_RDONLY) && ((finfo->access == O_RDONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_WRONLY) && ((finfo->access == O_WRONLY)
|| (finfo->access == O_RDWR)))
|| ((right == O_RDWR) && (finfo->access == O_RDWR)))
return 0;
return -EACCES;
return -EACCES;
}
static int
static int
ncp_file_read(struct inode *inode, struct file *file, char *buf, int count)
{
int bufsize, already_read;
off_t pos;
int errno;
int errno;
DPRINTK("ncp_file_read: enter %s\n", NCP_ISTRUCT(inode)->entryName);
DPRINTK("ncp_file_read: enter %s\n", NCP_ISTRUCT(inode)->entryName);
if (inode == NULL)
{
DPRINTK("ncp_file_read: inode = NULL\n");
@@ -104,37 +102,32 @@ ncp_file_read(struct inode *inode, struct file *file, char *buf, int count)
{
return -EIO;
}
if (!S_ISREG(inode->i_mode))
{
DPRINTK("ncp_file_read: read from non-file, mode %07o\n",
inode->i_mode);
inode->i_mode);
return -EINVAL;
}
pos = file->f_pos;
if (pos + count > inode->i_size)
{
count = inode->i_size - pos;
}
if (count <= 0)
{
return 0;
}
if ((errno = ncp_make_open(inode, O_RDONLY)) != 0)
if ((errno = ncp_make_open(inode, O_RDONLY)) != 0)
{
return errno;
return errno;
}
bufsize = NCP_SERVER(inode)->buffer_size;
already_read = 0;
already_read = 0;
/* First read in as much as possible for each bufsize. */
while (already_read < count)
while (already_read < count)
{
int read_this_time;
int to_read = min(bufsize - (pos % bufsize),
@@ -143,41 +136,39 @@ ncp_file_read(struct inode *inode, struct file *file, char *buf, int count)
if (ncp_read(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,
pos, to_read, buf, &read_this_time) != 0)
{
return -EIO; /* This is not exact, i know.. */
return -EIO; /* This is not exact, i know.. */
}
pos += read_this_time;
buf += read_this_time;
already_read += read_this_time;
already_read += read_this_time;
if (read_this_time < to_read)
{
break;
break;
}
}
file->f_pos = pos;
file->f_pos = pos;
if (!IS_RDONLY(inode))
{
inode->i_atime = CURRENT_TIME;
}
inode->i_dirt = 1;
DPRINTK("ncp_file_read: exit %s\n", NCP_ISTRUCT(inode)->entryName);
DPRINTK("ncp_file_read: exit %s\n", NCP_ISTRUCT(inode)->entryName);
return already_read;
return already_read;
}
static int
static int
ncp_file_write(struct inode *inode, struct file *file, char *buf,
int count)
{
int bufsize, already_written;
off_t pos;
int errno;
off_t pos;
int errno;
if (inode == NULL)
{
DPRINTK("ncp_file_write: inode = NULL\n");
@@ -187,38 +178,33 @@ ncp_file_write(struct inode *inode, struct file *file, char *buf,
{
return -EIO;
}
if (!S_ISREG(inode->i_mode))
{
DPRINTK("ncp_file_write: write to non-file, mode %07o\n",
inode->i_mode);
inode->i_mode);
return -EINVAL;
}
DPRINTK("ncp_file_write: enter %s\n", NCP_ISTRUCT(inode)->entryName);
DPRINTK("ncp_file_write: enter %s\n", NCP_ISTRUCT(inode)->entryName);
if (count <= 0)
{
return 0;
}
if ((errno = ncp_make_open(inode, O_RDWR)) != 0)
if ((errno = ncp_make_open(inode, O_RDWR)) != 0)
{
return errno;
return errno;
}
pos = file->f_pos;
if (file->f_flags & O_APPEND)
{
pos = inode->i_size;
}
bufsize = NCP_SERVER(inode)->buffer_size;
already_written = 0;
already_written = 0;
while (already_written < count)
while (already_written < count)
{
int written_this_time;
int to_write = min(bufsize - (pos % bufsize),
@@ -228,8 +214,7 @@ ncp_file_write(struct inode *inode, struct file *file, char *buf,
pos, to_write, buf, &written_this_time) != 0)
{
return -EIO;
}
}
pos += written_this_time;
buf += written_this_time;
already_written += written_this_time;
@@ -245,18 +230,18 @@ ncp_file_write(struct inode *inode, struct file *file, char *buf,
file->f_pos = pos;
if (pos > inode->i_size)
if (pos > inode->i_size)
{
inode->i_size = pos;
inode->i_size = pos;
ncp_invalid_dir_cache(NCP_INOP(inode)->dir->inode);
}
DPRINTK("ncp_file_write: exit %s\n", NCP_ISTRUCT(inode)->entryName);
}
DPRINTK("ncp_file_write: exit %s\n", NCP_ISTRUCT(inode)->entryName);
return already_written;
}
static struct file_operations ncp_file_operations = {
static struct file_operations ncp_file_operations =
{
NULL, /* lseek - default */
ncp_file_read, /* read */
ncp_file_write, /* write */
@@ -264,12 +249,13 @@ static struct file_operations ncp_file_operations = {
NULL, /* select - default */
ncp_ioctl, /* ioctl */
ncp_mmap, /* mmap */
NULL, /* open */
NULL, /* release */
NULL, /* open */
NULL, /* release */
ncp_fsync, /* fsync */
};
struct inode_operations ncp_file_inode_operations = {
struct inode_operations ncp_file_inode_operations =
{
&ncp_file_operations, /* default file operations */
NULL, /* create */
NULL, /* lookup */

View File

@@ -37,8 +37,9 @@ static void ncp_put_super(struct super_block *);
static void ncp_statfs(struct super_block *sb, struct statfs *stat);
static int ncp_notify_change(struct inode *inode, struct iattr *attr);
static struct super_operations ncp_sops = {
ncp_read_inode, /* read inode */
static struct super_operations ncp_sops =
{
ncp_read_inode, /* read inode */
ncp_notify_change, /* notify change */
NULL, /* write inode */
ncp_put_inode, /* put inode */
@@ -55,13 +56,13 @@ static struct super_operations ncp_sops = {
static void
ncp_read_inode(struct inode *inode)
{
/* Our task should be extremely simple here. We only have to
look up the infomation somebody else (ncp_iget) put into
the inode tree. The address of this information is the
inode->i_ino. Just to make sure everything went well, we
check it's there. */
/* Our task should be extremely simple here. We only have to
look up the infomation somebody else (ncp_iget) put into
the inode tree. The address of this information is the
inode->i_ino. Just to make sure everything went well, we
check it's there. */
struct ncp_inode_info *inode_info = ncp_find_inode(inode);
struct ncp_inode_info *inode_info = ncp_find_inode(inode);
if (inode_info == NULL)
{
@@ -70,41 +71,38 @@ ncp_read_inode(struct inode *inode)
printk("ncp_read_inode: inode info not found\n");
return;
}
inode_info->state = NCP_INODE_VALID;
inode_info->state = NCP_INODE_VALID;
NCP_INOP(inode) = inode_info;
NCP_INOP(inode) = inode_info;
inode_info->inode = inode;
if (NCP_ISTRUCT(inode)->attributes & aDIR)
if (NCP_ISTRUCT(inode)->attributes & aDIR)
{
inode->i_mode = NCP_SERVER(inode)->m.dir_mode;
inode->i_mode = NCP_SERVER(inode)->m.dir_mode;
/* for directories dataStreamSize seems to be some
Object ID ??? */
inode->i_size = 512;
}
else
} else
{
inode->i_mode = NCP_SERVER(inode)->m.file_mode;
inode->i_mode = NCP_SERVER(inode)->m.file_mode;
inode->i_size = NCP_ISTRUCT(inode)->dataStreamSize;
}
DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode);
DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode);
inode->i_nlink = 1;
inode->i_uid = NCP_SERVER(inode)->m.uid;
inode->i_gid = NCP_SERVER(inode)->m.gid;
inode->i_blksize = 512;
inode->i_rdev = 0;
inode->i_nlink = 1;
inode->i_uid = NCP_SERVER(inode)->m.uid;
inode->i_gid = NCP_SERVER(inode)->m.gid;
inode->i_blksize = 512;
inode->i_rdev = 0;
if ((inode->i_blksize != 0) && (inode->i_size != 0))
if ((inode->i_blksize != 0) && (inode->i_size != 0))
{
inode->i_blocks =
(inode->i_size - 1) / inode->i_blksize + 1;
}
else
inode->i_blocks =
(inode->i_size - 1) / inode->i_blksize + 1;
} else
{
inode->i_blocks = 0;
inode->i_blocks = 0;
}
inode->i_mtime = ncp_date_dos2unix(NCP_ISTRUCT(inode)->modifyTime,
@@ -114,48 +112,44 @@ ncp_read_inode(struct inode *inode)
inode->i_atime = ncp_date_dos2unix(0,
NCP_ISTRUCT(inode)->lastAccessDate);
if (S_ISREG(inode->i_mode))
if (S_ISREG(inode->i_mode))
{
inode->i_op = &ncp_file_inode_operations;
}
else if (S_ISDIR(inode->i_mode))
inode->i_op = &ncp_file_inode_operations;
} else if (S_ISDIR(inode->i_mode))
{
inode->i_op = &ncp_dir_inode_operations;
}
else
inode->i_op = &ncp_dir_inode_operations;
} else
{
inode->i_op = NULL;
inode->i_op = NULL;
}
}
static void
ncp_put_inode(struct inode *inode)
{
struct nw_file_info *finfo = NCP_FINFO(inode);
struct nw_file_info *finfo = NCP_FINFO(inode);
struct super_block *sb = inode->i_sb;
lock_super(sb);
if (finfo->opened != 0)
if (finfo->opened != 0)
{
if (ncp_close_file(NCP_SERVER(inode), finfo->file_handle)!=0)
if (ncp_close_file(NCP_SERVER(inode), finfo->file_handle) != 0)
{
/* We can't do anything but complain. */
printk("ncp_put_inode: could not close\n");
}
}
/* We can't do anything but complain. */
printk("ncp_put_inode: could not close\n");
}
}
DDPRINTK("ncp_put_inode: put %s\n",
finfo->i.entryName);
finfo->i.entryName);
ncp_free_inode_info(NCP_INOP(inode));
ncp_free_inode_info(NCP_INOP(inode));
if (S_ISDIR(inode->i_mode))
if (S_ISDIR(inode->i_mode))
{
DDPRINTK("ncp_put_inode: put directory %ld\n",
DDPRINTK("ncp_put_inode: put directory %ld\n",
inode->i_ino);
ncp_invalid_dir_cache(inode);
}
ncp_invalid_dir_cache(inode);
}
clear_inode(inode);
unlock_super(sb);
}
@@ -164,7 +158,7 @@ struct super_block *
ncp_read_super(struct super_block *sb, void *raw_data, int silent)
{
struct ncp_mount_data *data = (struct ncp_mount_data *) raw_data;
struct ncp_server *server;
struct ncp_server *server;
struct file *ncp_filp;
struct file *wdog_filp;
dev_t dev = sb->s_dev;
@@ -176,17 +170,15 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
sb->s_dev = 0;
return NULL;
}
if (data->version != NCP_MOUNT_VERSION)
{
printk("ncp warning: mount version %s than kernel\n",
(data->version < NCP_MOUNT_VERSION) ?
"older" : "newer");
"older" : "newer");
sb->s_dev = 0;
return NULL;
}
if ( (data->ncp_fd >= NR_OPEN)
if ((data->ncp_fd >= NR_OPEN)
|| ((ncp_filp = current->files->fd[data->ncp_fd]) == NULL)
|| (!S_ISSOCK(ncp_filp->f_inode->i_mode)))
{
@@ -194,8 +186,7 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
sb->s_dev = 0;
return NULL;
}
if ( (data->wdog_fd >= NR_OPEN)
if ((data->wdog_fd >= NR_OPEN)
|| ((wdog_filp = current->files->fd[data->wdog_fd]) == NULL)
|| (!S_ISSOCK(wdog_filp->f_inode->i_mode)))
{
@@ -203,46 +194,44 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
sb->s_dev = 0;
return NULL;
}
/* We must malloc our own super-block info */
server = (struct ncp_server *) ncp_kmalloc(sizeof(struct ncp_server),
GFP_KERNEL);
/* We must malloc our own super-block info */
server = (struct ncp_server *)ncp_kmalloc(sizeof(struct ncp_server),
GFP_KERNEL);
if (server == NULL)
if (server == NULL)
{
printk("ncp_read_super: could not alloc ncp_server\n");
return NULL;
}
printk("ncp_read_super: could not alloc ncp_server\n");
return NULL;
}
ncp_filp->f_count += 1;
wdog_filp->f_count += 1;
lock_super(sb);
NCP_SBP(sb) = server;
sb->s_blocksize = 1024; /* Eh... Is this correct? */
NCP_SBP(sb) = server;
sb->s_blocksize = 1024; /* Eh... Is this correct? */
sb->s_blocksize_bits = 10;
sb->s_magic = NCP_SUPER_MAGIC;
sb->s_dev = dev;
sb->s_op = &ncp_sops;
server->ncp_filp = ncp_filp;
server->wdog_filp = wdog_filp;
server->lock = 0;
server->wait = NULL;
server->packet = NULL;
server->ncp_filp = ncp_filp;
server->wdog_filp = wdog_filp;
server->lock = 0;
server->wait = NULL;
server->packet = NULL;
server->buffer_size = 0;
server->conn_status = 0;
server->m = *data;
server->m = *data;
server->m.file_mode = (server->m.file_mode &
(S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFREG;
server->m.dir_mode = (server->m.dir_mode &
(S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFDIR;
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFREG;
server->m.dir_mode = (server->m.dir_mode &
(S_IRWXU | S_IRWXG | S_IRWXO)) | S_IFDIR;
server->packet_size = NCP_PACKET_SIZE;
server->packet = ncp_kmalloc(NCP_PACKET_SIZE, GFP_KERNEL);
server->packet = ncp_kmalloc(NCP_PACKET_SIZE, GFP_KERNEL);
if (server->packet == NULL)
{
@@ -251,12 +240,11 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
unlock_super(sb);
goto fail;
}
ncp_init_root(server);
ncp_init_root(server);
/*
* Make the connection to the server
*/
/*
* Make the connection to the server
*/
if (ncp_catch_watchdog(server) != 0)
{
@@ -265,7 +253,6 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
unlock_super(sb);
goto fail;
}
ncp_lock_server(server);
error = ncp_connect(server);
ncp_unlock_server(server);
@@ -275,21 +262,19 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
{
sb->s_dev = 0;
printk("ncp_read_super: Failed connection, bailing out "
"(error = %d).\n", -error);
ncp_kfree_s(server->packet, server->packet_size);
"(error = %d).\n", -error);
ncp_kfree_s(server->packet, server->packet_size);
ncp_dont_catch_watchdog(server);
goto fail;
goto fail;
}
DPRINTK("ncp_read_super: NCP_SBP(sb) = %x\n", (int)NCP_SBP(sb));
DPRINTK("ncp_read_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb));
if (!(sb->s_mounted = iget(sb, ncp_info_ino(server, &(server->root)))))
{
sb->s_dev = 0;
printk("ncp_read_super: get root inode failed\n");
goto disconnect;
goto disconnect;
}
if (ncp_negotiate_buffersize(server, NCP_DEFAULT_BUFSIZE,
&(server->buffer_size)) != 0)
{
@@ -297,34 +282,33 @@ ncp_read_super(struct super_block *sb, void *raw_data, int silent)
printk("ncp_read_super: could not get bufsize\n");
goto disconnect;
}
DPRINTK("ncpfs: bufsize = %d\n", server->buffer_size);
MOD_INC_USE_COUNT;
MOD_INC_USE_COUNT;
return sb;
disconnect:
disconnect:
ncp_lock_server(server);
ncp_disconnect(server);
ncp_unlock_server(server);
ncp_kfree_s(server->packet, server->packet_size);
ncp_dont_catch_watchdog(server);
fail:
fail:
ncp_filp->f_count -= 1;
wdog_filp->f_count -= 1;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
return NULL;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
return NULL;
}
static void
ncp_put_super(struct super_block *sb)
{
struct ncp_server *server = NCP_SBP(sb);
struct ncp_server *server = NCP_SBP(sb);
lock_super(sb);
ncp_lock_server(server);
ncp_disconnect(server);
ncp_disconnect(server);
ncp_unlock_server(server);
close_fp(server->ncp_filp);
@@ -332,29 +316,29 @@ ncp_put_super(struct super_block *sb)
ncp_dont_catch_watchdog(server);
close_fp(server->wdog_filp);
ncp_free_all_inodes(server);
ncp_free_all_inodes(server);
ncp_kfree_s(server->packet, server->packet_size);
ncp_kfree_s(server->packet, server->packet_size);
sb->s_dev = 0;
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
ncp_kfree_s(NCP_SBP(sb), sizeof(struct ncp_server));
NCP_SBP(sb) = NULL;
unlock_super(sb);
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
}
static void
static void
ncp_statfs(struct super_block *sb, struct statfs *stat)
{
struct statfs tmp;
/* We cannot say how much disk space is left on a mounted
NetWare Server, because free space is distributed over
volumes, and the current user might have disk quotas. So
free space is not that simple to determine. Our decision
here is to err conservatively. */
NetWare Server, because free space is distributed over
volumes, and the current user might have disk quotas. So
free space is not that simple to determine. Our decision
here is to err conservatively. */
tmp.f_type = NCP_SUPER_MAGIC;
tmp.f_bsize = 512;
@@ -378,17 +362,16 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
{
return -EIO;
}
if ((result = inode_change_ok(inode, attr)) < 0)
return result;
if (((attr->ia_valid & ATTR_UID) &&
if (((attr->ia_valid & ATTR_UID) &&
(attr->ia_uid != NCP_SERVER(inode)->m.uid)))
return -EPERM;
if (((attr->ia_valid & ATTR_GID) &&
if (((attr->ia_valid & ATTR_GID) &&
(attr->ia_uid != NCP_SERVER(inode)->m.gid)))
return -EPERM;
return -EPERM;
if (((attr->ia_valid & ATTR_MODE) &&
(attr->ia_mode &
@@ -400,18 +383,16 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
if ((attr->ia_valid & ATTR_CTIME) != 0)
{
info_mask |= (DM_CREATE_TIME|DM_CREATE_DATE);
info_mask |= (DM_CREATE_TIME | DM_CREATE_DATE);
ncp_date_unix2dos(attr->ia_ctime,
&(info.creationTime), &(info.creationDate));
}
if ((attr->ia_valid & ATTR_MTIME) != 0)
{
info_mask |= (DM_MODIFY_TIME|DM_MODIFY_DATE);
info_mask |= (DM_MODIFY_TIME | DM_MODIFY_DATE);
ncp_date_unix2dos(attr->ia_mtime,
&(info.modifyTime), &(info.modifyDate));
}
if ((attr->ia_valid & ATTR_ATIME) != 0)
{
__u16 dummy;
@@ -419,7 +400,6 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
ncp_date_unix2dos(attr->ia_ctime,
&(dummy), &(info.lastAccessDate));
}
if (info_mask != 0)
{
if ((result =
@@ -430,19 +410,18 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
{
result = -EACCES;
if (info_mask == (DM_CREATE_TIME|DM_CREATE_DATE))
if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE))
{
/* NetWare seems not to allow this. I
do not know why. So, just tell the
user everything went fine. This is
a terrible hack, but I do not know
how to do this correctly. */
do not know why. So, just tell the
user everything went fine. This is
a terrible hack, but I do not know
how to do this correctly. */
result = 0;
}
}
}
if ((attr->ia_valid & ATTR_SIZE) != 0)
if ((attr->ia_valid & ATTR_SIZE) != 0)
{
int written;
@@ -453,7 +432,6 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
{
return -EACCES;
}
ncp_write(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,
attr->ia_size, 0, "", &written);
@@ -465,12 +443,11 @@ ncp_notify_change(struct inode *inode, struct iattr *attr)
result = 0;
}
ncp_invalid_dir_cache(NCP_INOP(inode)->dir->inode);
ncp_invalid_dir_cache(NCP_INOP(inode)->dir->inode);
return result;
}
#ifdef DEBUG_NCP_MALLOC
int ncp_malloced;
int ncp_current_malloced;
@@ -480,35 +457,36 @@ int ncp_current_malloced;
char kernel_version[] = UTS_RELEASE;
static struct file_system_type ncp_fs_type = {
ncp_read_super, "ncpfs", 0, NULL
};
static struct file_system_type ncp_fs_type =
{
ncp_read_super, "ncpfs", 0, NULL
};
int
init_module( void)
init_module(void)
{
DPRINTK("ncpfs: init_module called\n");
DPRINTK("ncpfs: init_module called\n");
#ifdef DEBUG_NCP_MALLOC
ncp_malloced = 0;
ncp_current_malloced = 0;
ncp_malloced = 0;
ncp_current_malloced = 0;
#endif
ncp_init_dir_cache();
register_filesystem(&ncp_fs_type);
ncp_init_dir_cache();
register_filesystem(&ncp_fs_type);
printk("ncpfs version %s loaded\n", NCPFS_VERSION);
return 0;
return 0;
}
void
cleanup_module(void)
{
DPRINTK("ncpfs: cleanup_module called\n");
ncp_free_dir_cache();
unregister_filesystem(&ncp_fs_type);
DPRINTK("ncpfs: cleanup_module called\n");
ncp_free_dir_cache();
unregister_filesystem(&ncp_fs_type);
#ifdef DEBUG_NCP_MALLOC
printk("ncp_malloced: %d\n", ncp_malloced);
printk("ncp_current_malloced: %d\n", ncp_current_malloced);
printk("ncp_malloced: %d\n", ncp_malloced);
printk("ncp_current_malloced: %d\n", ncp_current_malloced);
#endif
}

View File

@@ -21,8 +21,8 @@
#include <linux/ncp.h>
int
ncp_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg)
ncp_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
int result;
struct ncp_ioctl_request request;
@@ -34,56 +34,54 @@ ncp_ioctl (struct inode * inode, struct file * filp,
* Take this out in 2.1.0 development series.
* <mec@duracef.shout.net> 12 Mar 1996
*/
switch(cmd) {
case _IOR('n', 1, unsigned char *):
cmd = NCP_IOC_NCPREQUEST;
break;
switch (cmd)
{
case _IOR('n', 1, unsigned char *):
cmd = NCP_IOC_NCPREQUEST;
break;
case _IOR('u', 1, uid_t):
cmd = NCP_IOC_GETMOUNTUID;
break;
cmd = NCP_IOC_GETMOUNTUID;
break;
case _IO('l', 1):
cmd = NCP_IOC_CONN_LOGGED_IN;
break;
case _IOWR('i', 1, unsigned char *):
cmd = NCP_IOC_GET_FS_INFO;
break;
cmd = NCP_IOC_CONN_LOGGED_IN;
break;
case _IOWR('i', 1, unsigned char *):
cmd = NCP_IOC_GET_FS_INFO;
break;
}
switch(cmd) {
switch (cmd)
{
case NCP_IOC_NCPREQUEST:
if ( (permission(inode, MAY_WRITE) != 0)
if ((permission(inode, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
if ((result = verify_area(VERIFY_READ, (char *)arg,
if ((result = verify_area(VERIFY_READ, (char *) arg,
sizeof(request))) != 0)
{
return result;
}
memcpy_fromfs(&request, (struct ncp_ioctl_request *)arg,
memcpy_fromfs(&request, (struct ncp_ioctl_request *) arg,
sizeof(request));
if ( (request.function > 255)
if ((request.function > 255)
|| (request.size >
NCP_PACKET_SIZE - sizeof(struct ncp_request_header)))
{
return -EINVAL;
}
if ((result = verify_area(VERIFY_WRITE, (char *)request.data,
if ((result = verify_area(VERIFY_WRITE, (char *) request.data,
NCP_PACKET_SIZE)) != 0)
{
return result;
}
ncp_lock_server(server);
/* FIXME: We hack around in the server's structures
here to be able to use ncp_request */
here to be able to use ncp_request */
server->has_subfunction = 0;
server->current_size = request.size;
@@ -101,29 +99,26 @@ ncp_ioctl (struct inode * inode, struct file * filp,
case NCP_IOC_CONN_LOGGED_IN:
if ( (permission(inode, MAY_WRITE) != 0)
if ((permission(inode, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
return ncp_conn_logged_in(server);
case NCP_IOC_GET_FS_INFO:
if ( (permission(inode, MAY_WRITE) != 0)
if ((permission(inode, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
if ((result = verify_area(VERIFY_WRITE, (char *)arg,
if ((result = verify_area(VERIFY_WRITE, (char *) arg,
sizeof(info))) != 0)
{
return result;
}
memcpy_fromfs(&info, (struct ncp_fs_info *)arg,
memcpy_fromfs(&info, (struct ncp_fs_info *) arg,
sizeof(info));
if (info.version != NCP_GET_FS_INFO_VERSION)
@@ -131,36 +126,34 @@ ncp_ioctl (struct inode * inode, struct file * filp,
DPRINTK("info.version invalid: %d\n", info.version);
return -EINVAL;
}
info.addr = server->m.serv_addr;
info.addr = server->m.serv_addr;
info.mounted_uid = server->m.mounted_uid;
info.connection = server->connection;
info.connection = server->connection;
info.buffer_size = server->buffer_size;
info.volume_number = NCP_ISTRUCT(inode)->volNumber;
info.directory_id = NCP_ISTRUCT(inode)->DosDirNum;
info.directory_id = NCP_ISTRUCT(inode)->DosDirNum;
memcpy_tofs((struct ncp_fs_info *)arg, &info, sizeof(info));
return 0;
memcpy_tofs((struct ncp_fs_info *) arg, &info, sizeof(info));
return 0;
case NCP_IOC_GETMOUNTUID:
case NCP_IOC_GETMOUNTUID:
if ( (permission(inode, MAY_READ) != 0)
if ((permission(inode, MAY_READ) != 0)
&& (current->uid != server->m.mounted_uid))
{
return -EACCES;
}
if ((result = verify_area(VERIFY_WRITE, (uid_t*) arg,
sizeof(uid_t))) != 0)
if ((result = verify_area(VERIFY_WRITE, (uid_t *) arg,
sizeof(uid_t))) != 0)
{
return result;
}
put_fs_word(server->m.mounted_uid, (uid_t*) arg);
return 0;
return result;
}
put_fs_word(server->m.mounted_uid, (uid_t *) arg);
return 0;
default:
return -EINVAL;
}
return -EINVAL;
}

View File

@@ -27,19 +27,20 @@
#include <asm/segment.h>
#include <asm/system.h>
static inline int min(int a, int b)
static inline int
min(int a, int b)
{
return a<b ? a : b;
return a < b ? a : b;
}
/*
* Fill in the supplied page for mmap
*/
static unsigned long
ncp_file_mmap_nopage(struct vm_area_struct * area,
static unsigned long
ncp_file_mmap_nopage(struct vm_area_struct *area,
unsigned long address, unsigned long page, int no_share)
{
struct inode * inode = area->vm_inode;
struct inode *inode = area->vm_inode;
unsigned int clear;
unsigned long tmp;
int bufsize;
@@ -54,19 +55,17 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
{
clear = address + PAGE_SIZE - area->vm_end;
}
/* what we can read in one go */
/* what we can read in one go */
bufsize = NCP_SERVER(inode)->buffer_size;
fs = get_fs();
set_fs(get_ds());
if (ncp_make_open(inode, O_RDONLY) < 0)
if (ncp_make_open(inode, O_RDONLY) < 0)
{
clear = PAGE_SIZE;
} else
{
clear = PAGE_SIZE;
}
else
{
int already_read = 0;
int count = PAGE_SIZE - clear;
int to_read;
@@ -78,8 +77,7 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
if ((pos % bufsize) != 0)
{
to_read = bufsize - (pos % bufsize);
}
else
} else
{
to_read = bufsize;
}
@@ -89,12 +87,11 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
if (ncp_read(NCP_SERVER(inode),
NCP_FINFO(inode)->file_handle,
pos, to_read,
(char *)(page + already_read),
(char *) (page + already_read),
&read_this_time) != 0)
{
read_this_time = 0;
read_this_time = 0;
}
pos += read_this_time;
already_read += read_this_time;
@@ -104,18 +101,20 @@ ncp_file_mmap_nopage(struct vm_area_struct * area,
}
}
}
}
set_fs(fs);
tmp = page + PAGE_SIZE;
while (clear--) {
*(char *)--tmp = 0;
while (clear--)
{
*(char *) --tmp = 0;
}
return page;
}
struct vm_operations_struct ncp_file_mmap = {
struct vm_operations_struct ncp_file_mmap =
{
NULL, /* open */
NULL, /* close */
NULL, /* unmap */
@@ -131,25 +130,24 @@ struct vm_operations_struct ncp_file_mmap = {
/* This is used for a general mmap of a ncp file */
int
ncp_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
ncp_mmap(struct inode *inode, struct file *file, struct vm_area_struct *vma)
{
DPRINTK("ncp_mmap: called\n");
DPRINTK("ncp_mmap: called\n");
if (!ncp_conn_valid(NCP_SERVER(inode)))
{
return -EIO;
}
/* only PAGE_COW or read-only supported now */
if (vma->vm_flags & VM_SHARED)
/* only PAGE_COW or read-only supported now */
if (vma->vm_flags & VM_SHARED)
return -EINVAL;
if (!inode->i_sb || !S_ISREG(inode->i_mode))
return -EACCES;
if (!IS_RDONLY(inode)) {
if (!IS_RDONLY(inode))
{
inode->i_atime = CURRENT_TIME;
inode->i_dirt = 1;
}
vma->vm_inode = inode;
inode->i_count++;
vma->vm_ops = &ncp_file_mmap;

View File

@@ -1,3 +1,4 @@
#include <linux/config.h>
#ifdef MODULE
#include <linux/module.h>
@@ -6,13 +7,14 @@
#include "ncplib_kernel.h"
typedef __u8 byte;
typedef __u8 byte;
typedef __u16 word;
typedef __u32 dword;
static inline int min(int a, int b)
static inline int
min(int a, int b)
{
return a<b ? a : b;
return a < b ? a : b;
}
static void
@@ -28,7 +30,7 @@ static void
ncp_add_byte(struct ncp_server *server, byte x)
{
assert_server_locked(server);
*(byte *)(&(server->packet[server->current_size])) = x;
*(byte *) (&(server->packet[server->current_size])) = x;
server->current_size += 1;
return;
}
@@ -37,7 +39,7 @@ static void
ncp_add_word(struct ncp_server *server, word x)
{
assert_server_locked(server);
*(word *)(&(server->packet[server->current_size])) = x;
*(word *) (&(server->packet[server->current_size])) = x;
server->current_size += 2;
return;
}
@@ -46,7 +48,7 @@ static void
ncp_add_dword(struct ncp_server *server, dword x)
{
assert_server_locked(server);
*(dword *)(&(server->packet[server->current_size])) = x;
*(dword *) (&(server->packet[server->current_size])) = x;
server->current_size += 4;
return;
}
@@ -97,7 +99,7 @@ static void
ncp_init_request_s(struct ncp_server *server, int subfunction)
{
ncp_init_request(server);
ncp_add_word(server, 0); /* preliminary size */
ncp_add_word(server, 0); /* preliminary size */
ncp_add_byte(server, subfunction);
@@ -113,19 +115,19 @@ ncp_reply_data(struct ncp_server *server, int offset)
static byte
ncp_reply_byte(struct ncp_server *server, int offset)
{
return *(byte *)(ncp_reply_data(server, offset));
return *(byte *) (ncp_reply_data(server, offset));
}
static word
ncp_reply_word(struct ncp_server *server, int offset)
{
return *(word *)(ncp_reply_data(server, offset));
return *(word *) (ncp_reply_data(server, offset));
}
static dword
ncp_reply_dword(struct ncp_server *server, int offset)
{
return *(dword *)(ncp_reply_data(server, offset));
return *(dword *) (ncp_reply_data(server, offset));
}
int
@@ -136,14 +138,13 @@ ncp_negotiate_buffersize(struct ncp_server *server,
ncp_init_request(server);
ncp_add_word(server, htons(size));
if ((result = ncp_request(server, 33)) != 0)
{
ncp_unlock_server(server);
return result;
}
*target =min(ntohs(ncp_reply_word(server, 0)), size);
*target = min(ntohs(ncp_reply_word(server, 0)), size);
ncp_unlock_server(server);
return 0;
@@ -164,9 +165,8 @@ ncp_get_volume_info_with_number(struct ncp_server *server, int n,
ncp_unlock_server(server);
return result;
}
target->total_blocks = ncp_reply_dword(server, 0);
target->free_blocks = ncp_reply_dword(server, 4);
target->free_blocks = ncp_reply_dword(server, 4);
target->purgeable_blocks = ncp_reply_dword(server, 8);
target->not_yet_purgeable_blocks = ncp_reply_dword(server, 12);
target->total_dir_entries = ncp_reply_dword(server, 16);
@@ -182,7 +182,6 @@ ncp_get_volume_info_with_number(struct ncp_server *server, int n,
ncp_unlock_server(server);
return -EIO;
}
memcpy(&(target->volume_name), ncp_reply_data(server, 30), len);
ncp_unlock_server(server);
return 0;
@@ -202,7 +201,6 @@ ncp_close_file(struct ncp_server *server, const char *file_id)
ncp_unlock_server(server);
return result;
}
ncp_unlock_server(server);
return 0;
}
@@ -217,18 +215,16 @@ ncp_add_handle_path(struct ncp_server *server,
ncp_add_dword(server, dir_base);
if (have_dir_base != 0)
{
ncp_add_byte(server, 1); /* dir_base */
}
else
ncp_add_byte(server, 1); /* dir_base */
} else
{
ncp_add_byte(server, 0xff); /* no handle */
ncp_add_byte(server, 0xff); /* no handle */
}
if (path != NULL)
{
ncp_add_byte(server, 1); /* 1 component */
ncp_add_byte(server, 1); /* 1 component */
ncp_add_pstring(server, path);
}
else
} else
{
ncp_add_byte(server, 0);
}
@@ -243,7 +239,7 @@ ncp_extract_file_info(void *structure, struct nw_info_struct *target)
memcpy(target, structure, info_struct_size);
name_len = structure + info_struct_size;
target->nameLen = *name_len;
strncpy(target->entryName, name_len+1, *name_len);
strncpy(target->entryName, name_len + 1, *name_len);
target->entryName[*name_len] = '\0';
return;
}
@@ -251,7 +247,7 @@ ncp_extract_file_info(void *structure, struct nw_info_struct *target)
int
ncp_obtain_info(struct ncp_server *server,
__u8 vol_num, __u32 dir_base,
char *path, /* At most 1 component */
char *path, /* At most 1 component */
struct nw_info_struct *target)
{
int result;
@@ -260,12 +256,11 @@ ncp_obtain_info(struct ncp_server *server,
{
return -EINVAL;
}
ncp_init_request(server);
ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, 6); /* subfunction */
ncp_add_byte(server, server->name_space[vol_num]);
ncp_add_byte(server, server->name_space[vol_num]);
ncp_add_word(server, 0xff); /* get all */
ncp_add_word(server, 0xff); /* get all */
ncp_add_dword(server, RIM_ALL);
ncp_add_handle_path(server, vol_num, dir_base, 1, path);
@@ -274,7 +269,6 @@ ncp_obtain_info(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
ncp_extract_file_info(ncp_reply_data(server, 0), target);
ncp_unlock_server(server);
return 0;
@@ -288,7 +282,7 @@ ncp_has_os2_namespace(struct ncp_server *server, __u8 volume)
__u16 no_namespaces;
ncp_init_request(server);
ncp_add_byte(server, 24); /* Subfunction: Get Name Spaces Loaded */
ncp_add_byte(server, 24); /* Subfunction: Get Name Spaces Loaded */
ncp_add_word(server, 0);
ncp_add_byte(server, volume);
@@ -297,13 +291,12 @@ ncp_has_os2_namespace(struct ncp_server *server, __u8 volume)
ncp_unlock_server(server);
return 0;
}
no_namespaces = ncp_reply_word(server, 0);
namespace = ncp_reply_data(server, 2);
while (no_namespaces > 0)
{
DPRINTK("get_namespaces: found %d on %d\n", *namespace,volume);
DPRINTK("get_namespaces: found %d on %d\n", *namespace, volume);
if (*namespace == 4)
{
@@ -329,16 +322,16 @@ ncp_lookup_volume(struct ncp_server *server,
DPRINTK("ncp_lookup_volume: looking up vol %s\n", volname);
ncp_init_request(server);
ncp_add_byte(server, 22); /* Subfunction: Generate dir handle */
ncp_add_byte(server, 0); /* DOS namespace */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 22); /* Subfunction: Generate dir handle */
ncp_add_byte(server, 0); /* DOS namespace */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* faked volume number */
ncp_add_dword(server, 0); /* faked dir_base */
ncp_add_byte(server, 0xff); /* Don't have a dir_base */
ncp_add_byte(server, 1); /* 1 path component */
ncp_add_byte(server, 0); /* faked volume number */
ncp_add_dword(server, 0); /* faked dir_base */
ncp_add_byte(server, 0xff); /* Don't have a dir_base */
ncp_add_byte(server, 1); /* 1 path component */
ncp_add_pstring(server, volname);
if ((result = ncp_request(server, 87)) != 0)
@@ -346,13 +339,12 @@ ncp_lookup_volume(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
memset(target, 0, sizeof(*target));
target->DosDirNum = target->dirEntNum = ncp_reply_dword(server, 4);
target->volNumber = volnum = ncp_reply_byte(server, 8);
ncp_unlock_server(server);
server->name_space[volnum] = ncp_has_os2_namespace(server,volnum)?4:0;
server->name_space[volnum] = ncp_has_os2_namespace(server, volnum) ? 4 : 0;
DPRINTK("lookup_vol: namespace[%d] = %d\n",
volnum, server->name_space[volnum]);
@@ -372,10 +364,10 @@ ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 7); /* subfunction */
ncp_add_byte(server, 7); /* subfunction */
ncp_add_byte(server, server->name_space[file->volNumber]);
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_dword(server, info_mask);
ncp_add_mem(server, info, sizeof(*info));
@@ -387,7 +379,6 @@ ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
ncp_unlock_server(server);
return 0;
}
@@ -399,30 +390,29 @@ ncp_del_file_or_subdir(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 8); /* subfunction */
ncp_add_byte(server, 8); /* subfunction */
ncp_add_byte(server, server->name_space[dir->volNumber]);
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_byte(server, 0); /* reserved */
ncp_add_word(server, 0x8006); /* search attribs: all */
ncp_add_handle_path(server, dir->volNumber,
dir->dirEntNum, 1, name);
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
ncp_unlock_server(server);
return 0;
}
static inline void
ConvertToNWfromDWORD ( __u32 sfd , __u8 ret[6] )
ConvertToNWfromDWORD(__u32 sfd, __u8 ret[6])
{
__u16 *dest = (__u16 *) ret;
memcpy(&(dest[1]), &sfd, 4);
dest[0] = dest[1] + 1;
return;
__u16 *dest = (__u16 *) ret;
memcpy(&(dest[1]), &sfd, 4);
dest[0] = dest[1] + 1;
return;
}
/* If both dir and name are NULL, then in target there's already a
@@ -441,11 +431,10 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
if ((create_attributes & aDIR) != 0)
{
search_attribs |= 0x8000;
}
search_attribs |= 0x8000;
}
ncp_init_request(server);
ncp_add_byte(server, 1); /* subfunction */
ncp_add_byte(server, 1); /* subfunction */
ncp_add_byte(server, server->name_space[volume]);
ncp_add_byte(server, open_create_mode);
ncp_add_word(server, search_attribs);
@@ -458,19 +447,17 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
if (dir != NULL)
{
ncp_add_handle_path(server, volume, dir->dirEntNum, 1, name);
}
else
} else
{
ncp_add_handle_path(server, volume, target->i.dirEntNum,
1, NULL);
}
}
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
target->opened = 1;
target->server_file_handle = ncp_reply_dword(server, 0);
target->open_create_action = ncp_reply_byte(server, 4);
@@ -480,13 +467,12 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
/* in target there's a new finfo to fill */
ncp_extract_file_info(ncp_reply_data(server, 5), &(target->i));
}
ConvertToNWfromDWORD(target->server_file_handle, target->file_handle);
ncp_unlock_server(server);
return 0;
}
int
ncp_initialize_search(struct ncp_server *server,
@@ -496,23 +482,22 @@ ncp_initialize_search(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 2); /* subfunction */
ncp_add_byte(server, 2); /* subfunction */
ncp_add_byte(server, server->name_space[dir->volNumber]);
ncp_add_byte(server, 0); /* reserved */
ncp_add_byte(server, 0); /* reserved */
ncp_add_handle_path(server, dir->volNumber, dir->dirEntNum, 1, NULL);
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
memcpy(target, ncp_reply_data(server, 0), sizeof(*target));
ncp_unlock_server(server);
return 0;
}
/* Search for everything */
int
ncp_search_for_file_or_subdir(struct ncp_server *server,
@@ -522,22 +507,21 @@ ncp_search_for_file_or_subdir(struct ncp_server *server,
int result;
ncp_init_request(server);
ncp_add_byte(server, 3); /* subfunction */
ncp_add_byte(server, 3); /* subfunction */
ncp_add_byte(server, server->name_space[seq->volNumber]);
ncp_add_byte(server, 0); /* data stream (???) */
ncp_add_word(server, 0xffff); /* Search attribs */
ncp_add_dword(server, RIM_ALL); /* return info mask */
ncp_add_byte(server, 0); /* data stream (???) */
ncp_add_word(server, 0xffff); /* Search attribs */
ncp_add_dword(server, RIM_ALL); /* return info mask */
ncp_add_mem(server, seq, 9);
ncp_add_byte(server, 2); /* 2 byte pattern */
ncp_add_byte(server, 0xff); /* following is a wildcard */
ncp_add_byte(server, 2); /* 2 byte pattern */
ncp_add_byte(server, 0xff); /* following is a wildcard */
ncp_add_byte(server, '*');
if ((result = ncp_request(server, 87)) != 0)
{
ncp_unlock_server(server);
return result;
}
memcpy(seq, ncp_reply_data(server, 0), sizeof(*seq));
ncp_extract_file_info(ncp_reply_data(server, 10), target);
@@ -552,27 +536,27 @@ ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
{
int result;
if ( (old_dir == NULL) || (old_name == NULL)
if ((old_dir == NULL) || (old_name == NULL)
|| (new_dir == NULL) || (new_name == NULL))
return -EINVAL;
ncp_init_request(server);
ncp_add_byte(server, 4); /* subfunction */
ncp_add_byte(server, 4); /* subfunction */
ncp_add_byte(server, server->name_space[old_dir->volNumber]);
ncp_add_byte(server, 1); /* rename flag */
ncp_add_word(server, 0x8006); /* search attributes */
ncp_add_byte(server, 1); /* rename flag */
ncp_add_word(server, 0x8006); /* search attributes */
/* source Handle Path */
ncp_add_byte(server, old_dir->volNumber);
ncp_add_dword(server, old_dir->dirEntNum);
ncp_add_byte(server, 1);
ncp_add_byte(server, 1); /* 1 source component */
ncp_add_byte(server, 1); /* 1 source component */
/* dest Handle Path */
ncp_add_byte(server, new_dir->volNumber);
ncp_add_dword(server, new_dir->dirEntNum);
ncp_add_byte(server, 1);
ncp_add_byte(server, 1); /* 1 destination component */
ncp_add_byte(server, 1); /* 1 destination component */
/* source path string */
ncp_add_pstring(server, old_name);
@@ -583,7 +567,7 @@ ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
ncp_unlock_server(server);
return result;
}
/* We have to transfer to/from user space */
int
@@ -604,10 +588,9 @@ ncp_read(struct ncp_server *server, const char *file_id,
ncp_unlock_server(server);
return result;
}
*bytes_read = ntohs(ncp_reply_word(server, 0));
memcpy_tofs(target, ncp_reply_data(server, 2+(offset&1)), *bytes_read);
memcpy_tofs(target, ncp_reply_data(server, 2 + (offset & 1)), *bytes_read);
ncp_unlock_server(server);
return 0;
@@ -632,10 +615,8 @@ ncp_write(struct ncp_server *server, const char *file_id,
ncp_unlock_server(server);
return result;
}
*bytes_written = to_write;
ncp_unlock_server(server);
return 0;
}

View File

@@ -1,3 +1,4 @@
#ifndef _NCPLIB_H
#define _NCPLIB_H
@@ -16,147 +17,147 @@
#include <linux/ncp.h>
int
ncp_negotiate_buffersize(struct ncp_server *server, int size,
int *target);
ncp_negotiate_buffersize(struct ncp_server *server, int size,
int *target);
int
ncp_get_encryption_key(struct ncp_server *server,
char *target);
ncp_get_encryption_key(struct ncp_server *server,
char *target);
int
ncp_get_bindery_object_id(struct ncp_server *server,
int object_type, char *object_name,
struct ncp_bindery_object *target);
ncp_get_bindery_object_id(struct ncp_server *server,
int object_type, char *object_name,
struct ncp_bindery_object *target);
int
ncp_login_encrypted(struct ncp_server *server,
struct ncp_bindery_object *object,
unsigned char *key,
unsigned char *passwd);
ncp_login_encrypted(struct ncp_server *server,
struct ncp_bindery_object *object,
unsigned char *key,
unsigned char *passwd);
int
ncp_login_user(struct ncp_server *server,
unsigned char *username,
unsigned char *password);
ncp_login_user(struct ncp_server *server,
unsigned char *username,
unsigned char *password);
int
ncp_get_volume_info_with_number(struct ncp_server *server, int n,
struct ncp_volume_info *target);
ncp_get_volume_info_with_number(struct ncp_server *server, int n,
struct ncp_volume_info *target);
int
ncp_get_volume_number(struct ncp_server *server, const char *name,
int *target);
ncp_get_volume_number(struct ncp_server *server, const char *name,
int *target);
int
ncp_file_search_init(struct ncp_server *server,
int dir_handle, const char *path,
struct ncp_filesearch_info *target);
ncp_file_search_init(struct ncp_server *server,
int dir_handle, const char *path,
struct ncp_filesearch_info *target);
int
ncp_file_search_continue(struct ncp_server *server,
struct ncp_filesearch_info *fsinfo,
int attributes, const char *path,
struct ncp_file_info *target);
ncp_file_search_continue(struct ncp_server *server,
struct ncp_filesearch_info *fsinfo,
int attributes, const char *path,
struct ncp_file_info *target);
int
ncp_get_finfo(struct ncp_server *server,
int dir_handle, const char *path, const char *name,
struct ncp_file_info *target);
ncp_get_finfo(struct ncp_server *server,
int dir_handle, const char *path, const char *name,
struct ncp_file_info *target);
int
ncp_open_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr, int access,
struct ncp_file_info *target);
int
ncp_close_file(struct ncp_server *server, const char *file_id);
int
ncp_create_newfile(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_create_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_erase_file(struct ncp_server *server,
ncp_open_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr);
int attr, int access,
struct ncp_file_info *target);
int
ncp_close_file(struct ncp_server *server, const char *file_id);
int
ncp_rename_file(struct ncp_server *server,
int old_handle, const char *old_path,
int attr,
int new_handle, const char *new_path);
ncp_create_newfile(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_create_directory(struct ncp_server *server,
int dir_handle, const char *path,
int inherit_mask);
ncp_create_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr,
struct ncp_file_info *target);
int
ncp_delete_directory(struct ncp_server *server,
int dir_handle, const char *path);
ncp_erase_file(struct ncp_server *server,
int dir_handle, const char *path,
int attr);
int
ncp_rename_directory(struct ncp_server *server,
int dir_handle,
const char *old_path, const char *new_path);
ncp_rename_file(struct ncp_server *server,
int old_handle, const char *old_path,
int attr,
int new_handle, const char *new_path);
int
ncp_read(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_read,
char *target, int *bytes_read);
ncp_create_directory(struct ncp_server *server,
int dir_handle, const char *path,
int inherit_mask);
int
ncp_write(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_write,
const char *source, int *bytes_written);
ncp_delete_directory(struct ncp_server *server,
int dir_handle, const char *path);
int
ncp_obtain_info(struct ncp_server *server,
__u8 vol_num, __u32 dir_base,
char *path, /* At most 1 component */
struct nw_info_struct *target);
ncp_rename_directory(struct ncp_server *server,
int dir_handle,
const char *old_path, const char *new_path);
int
ncp_lookup_volume(struct ncp_server *server,
char *volname,
struct nw_info_struct *target);
ncp_read(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_read,
char *target, int *bytes_read);
int
ncp_write(struct ncp_server *server, const char *file_id,
__u32 offset, __u16 to_write,
const char *source, int *bytes_written);
int
ncp_obtain_info(struct ncp_server *server,
__u8 vol_num, __u32 dir_base,
char *path, /* At most 1 component */
struct nw_info_struct *target);
int
ncp_lookup_volume(struct ncp_server *server,
char *volname,
struct nw_info_struct *target);
int
ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
struct nw_info_struct *file,
__u32 info_mask,
struct nw_modify_dos_info *info);
ncp_modify_file_or_subdir_dos_info(struct ncp_server *server,
struct nw_info_struct *file,
__u32 info_mask,
struct nw_modify_dos_info *info);
int
ncp_del_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name);
ncp_del_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name);
int
ncp_open_create_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name,
int open_create_mode,
__u32 create_attributes,
int desired_acc_rights,
struct nw_file_info *target);
ncp_open_create_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *dir, char *name,
int open_create_mode,
__u32 create_attributes,
int desired_acc_rights,
struct nw_file_info *target);
int
ncp_initialize_search(struct ncp_server *server,
struct nw_info_struct *dir,
struct nw_search_sequence *target);
ncp_initialize_search(struct ncp_server *server,
struct nw_info_struct *dir,
struct nw_search_sequence *target);
int
ncp_search_for_file_or_subdir(struct ncp_server *server,
struct nw_search_sequence *seq,
struct nw_info_struct *target);
ncp_search_for_file_or_subdir(struct ncp_server *server,
struct nw_search_sequence *seq,
struct nw_info_struct *target);
int
ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *old_dir, char *old_name,
struct nw_info_struct *new_dir, char *new_name);
ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
struct nw_info_struct *old_dir, char *old_name,
struct nw_info_struct *new_dir, char *new_name);
#endif /* _NCPLIB_H */
#endif /* _NCPLIB_H */

View File

@@ -49,41 +49,40 @@ ncp_wdog_data_ready(struct sock *sk, int len)
fs = get_fs();
set_fs(get_ds());
result = sock->ops->recvfrom(sock, (void *)packet_buf, 2, 1, 0,
(struct sockaddr *)&sender,
result = sock->ops->recvfrom(sock, (void *) packet_buf, 2, 1, 0,
(struct sockaddr *) &sender,
&addr_len);
if ( (result != 2)
if ((result != 2)
|| (packet_buf[1] != '?')
/* How to check connection number here? */
/* How to check connection number here? */
)
{
/* Error, throw away the complete packet */
sock->ops->recvfrom(sock, (void *)packet_buf, 2, 1, 0,
(struct sockaddr *)&sender,
sock->ops->recvfrom(sock, (void *) packet_buf, 2, 1, 0,
(struct sockaddr *) &sender,
&addr_len);
printk("ncpfs: got strange packet on watchdog "
"socket\n");
}
else
} else
{
int result;
DDPRINTK("ncpfs: got watchdog from:\n");
DDPRINTK("ncpfs: %08lX:%02X%02X%02X%02X%02X%02X:%04X,"
" conn:%02X,type:%c\n",
htonl(sender.sipx_network),
sender.sipx_node[0], sender.sipx_node[1],
sender.sipx_node[2], sender.sipx_node[3],
sender.sipx_node[4], sender.sipx_node[5],
ntohs(sender.sipx_port),
packet_buf[0], packet_buf[1]);
" conn:%02X,type:%c\n",
htonl(sender.sipx_network),
sender.sipx_node[0], sender.sipx_node[1],
sender.sipx_node[2], sender.sipx_node[3],
sender.sipx_node[4], sender.sipx_node[5],
ntohs(sender.sipx_port),
packet_buf[0], packet_buf[1]);
packet_buf[1] = 'Y';
result = sock->ops->sendto(sock, (void *)packet_buf,
result = sock->ops->sendto(sock, (void *) packet_buf,
2, 1, 0,
(struct sockaddr *)&sender,
(struct sockaddr *) &sender,
sizeof(sender));
DDPRINTK("send result: %d\n", result);
}
@@ -95,109 +94,100 @@ ncp_wdog_data_ready(struct sock *sk, int len)
int
ncp_catch_watchdog(struct ncp_server *server)
{
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
if ( (server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
if ((server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
{
printk("ncp_catch_watchdog: did not get valid server!\n");
server->data_ready = NULL;
return -EINVAL;
}
printk("ncp_catch_watchdog: did not get valid server!\n");
server->data_ready = NULL;
return -EINVAL;
}
sock = &(inode->u.socket_i);
sock = &(inode->u.socket_i);
if (sock->type != SOCK_DGRAM)
if (sock->type != SOCK_DGRAM)
{
printk("ncp_catch_watchdog: did not get SOCK_STREAM\n");
server->data_ready = NULL;
return -EINVAL;
}
printk("ncp_catch_watchdog: did not get SOCK_STREAM\n");
server->data_ready = NULL;
return -EINVAL;
}
sk = (struct sock *) (sock->data);
sk = (struct sock *)(sock->data);
if (sk == NULL)
if (sk == NULL)
{
printk("ncp_catch_watchdog: sk == NULL");
server->data_ready = NULL;
return -EINVAL;
}
printk("ncp_catch_watchdog: sk == NULL");
server->data_ready = NULL;
return -EINVAL;
}
DDPRINTK("ncp_catch_watchdog.: sk->d_r = %x, server->d_r = %x\n",
(unsigned int) (sk->data_ready),
(unsigned int) (server->data_ready));
DDPRINTK("ncp_catch_watchdog.: sk->d_r = %x, server->d_r = %x\n",
(unsigned int)(sk->data_ready),
(unsigned int)(server->data_ready));
if (sk->data_ready == ncp_wdog_data_ready)
if (sk->data_ready == ncp_wdog_data_ready)
{
printk("ncp_catch_watchdog: already done\n");
return -EINVAL;
}
server->data_ready = sk->data_ready;
sk->data_ready = ncp_wdog_data_ready;
return 0;
printk("ncp_catch_watchdog: already done\n");
return -EINVAL;
}
server->data_ready = sk->data_ready;
sk->data_ready = ncp_wdog_data_ready;
return 0;
}
int
ncp_dont_catch_watchdog(struct ncp_server *server)
{
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
struct file *file;
struct inode *inode;
struct socket *sock;
struct sock *sk;
if ( (server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
if ((server == NULL)
|| ((file = server->wdog_filp) == NULL)
|| ((inode = file->f_inode) == NULL)
|| (!S_ISSOCK(inode->i_mode)))
{
printk("ncp_dont_catch_watchdog: "
"did not get valid server!\n");
return -EINVAL;
}
printk("ncp_dont_catch_watchdog: "
"did not get valid server!\n");
return -EINVAL;
}
sock = &(inode->u.socket_i);
sock = &(inode->u.socket_i);
if (sock->type != SOCK_DGRAM)
if (sock->type != SOCK_DGRAM)
{
printk("ncp_dont_catch_watchdog: did not get SOCK_STREAM\n");
return -EINVAL;
}
printk("ncp_dont_catch_watchdog: did not get SOCK_STREAM\n");
return -EINVAL;
}
sk = (struct sock *) (sock->data);
sk = (struct sock *)(sock->data);
if (sk == NULL)
if (sk == NULL)
{
printk("ncp_dont_catch_watchdog: sk == NULL");
return -EINVAL;
}
if (server->data_ready == NULL)
printk("ncp_dont_catch_watchdog: sk == NULL");
return -EINVAL;
}
if (server->data_ready == NULL)
{
printk("ncp_dont_catch_watchdog: "
"server->data_ready == NULL\n");
return -EINVAL;
}
if (sk->data_ready != ncp_wdog_data_ready)
printk("ncp_dont_catch_watchdog: "
"server->data_ready == NULL\n");
return -EINVAL;
}
if (sk->data_ready != ncp_wdog_data_ready)
{
printk("ncp_dont_catch_watchdog: "
"sk->data_callback != ncp_data_callback\n");
return -EINVAL;
}
printk("ncp_dont_catch_watchdog: "
"sk->data_callback != ncp_data_callback\n");
return -EINVAL;
}
DDPRINTK("ncp_dont_catch_watchdog: sk->d_r = %x, server->d_r = %x\n",
(unsigned int) (sk->data_ready),
(unsigned int) (server->data_ready));
DDPRINTK("ncp_dont_catch_watchdog: sk->d_r = %x, server->d_r = %x\n",
(unsigned int)(sk->data_ready),
(unsigned int)(server->data_ready));
sk->data_ready = server->data_ready;
server->data_ready = NULL;
return 0;
sk->data_ready = server->data_ready;
server->data_ready = NULL;
return 0;
}
@@ -229,9 +219,9 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
/* We have to check the result, so store the complete header */
struct ncp_request_header request =
*((struct ncp_request_header *)(server->packet));
*((struct ncp_request_header *) (server->packet));
struct ncp_reply_header reply;
struct ncp_reply_header reply;
file = server->ncp_filp;
@@ -251,32 +241,32 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
old_mask = current->blocked;
current->blocked |= ~(_S(SIGKILL)
#if 0
| _S(SIGSTOP)
| _S(SIGSTOP)
#endif
| ((server->m.flags & NCP_MOUNT_INTR)
? ((current->sigaction[SIGINT - 1].sa_handler == SIG_DFL
? _S(SIGINT) : 0)
| (current->sigaction[SIGQUIT - 1].sa_handler == SIG_DFL
? _S(SIGQUIT) : 0))
: 0));
| ((server->m.flags & NCP_MOUNT_INTR)
? ((current->sigaction[SIGINT - 1].sa_handler == SIG_DFL
? _S(SIGINT) : 0)
| (current->sigaction[SIGQUIT - 1].sa_handler == SIG_DFL
? _S(SIGQUIT) : 0))
: 0));
fs = get_fs();
set_fs(get_ds());
for (n = 0, timeout = init_timeout; ; n++, timeout <<= 1)
for (n = 0, timeout = init_timeout;; n++, timeout <<= 1)
{
DDPRINTK("ncpfs: %08lX:%02X%02X%02X%02X%02X%02X:%04X\n",
htonl(server->m.serv_addr.sipx_network),
server->m.serv_addr.sipx_node[0],
server->m.serv_addr.sipx_node[1],
server->m.serv_addr.sipx_node[2],
server->m.serv_addr.sipx_node[3],
server->m.serv_addr.sipx_node[4],
server->m.serv_addr.sipx_node[5],
ntohs(server->m.serv_addr.sipx_port));
htonl(server->m.serv_addr.sipx_network),
server->m.serv_addr.sipx_node[0],
server->m.serv_addr.sipx_node[1],
server->m.serv_addr.sipx_node[2],
server->m.serv_addr.sipx_node[3],
server->m.serv_addr.sipx_node[4],
server->m.serv_addr.sipx_node[5],
ntohs(server->m.serv_addr.sipx_port));
DDPRINTK("ncpfs: req.typ: %04X, con: %d, "
"seq: %d",
request.type,
(request.conn_high << 8) + request.conn_low,
request.sequence);
"seq: %d",
request.type,
(request.conn_high << 8) + request.conn_low,
request.sequence);
DDPRINTK(" func: %d\n",
request.function);
@@ -289,11 +279,11 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
printk("ncp_rpc_call: send error = %d\n", result);
break;
}
re_select:
re_select:
wait_table.nr = 0;
wait_table.entry = &entry;
current->state = TASK_INTERRUPTIBLE;
if ( !select(inode, file, SEL_IN, &wait_table)
if (!select(inode, file, SEL_IN, &wait_table)
&& !select(inode, file, SEL_IN, NULL))
{
if (timeout > max_timeout)
@@ -336,11 +326,9 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
}
major_timeout_seen = 1;
continue;
}
else
} else
current->timeout = 0;
}
else if (wait_table.nr)
} else if (wait_table.nr)
remove_wait_queue(entry.wait_address, &entry.wait);
current->state = TASK_RUNNING;
addrlen = 0;
@@ -348,7 +336,7 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
/* Get the header from the next packet using a peek, so keep it
* on the recv queue. If it is wrong, it will be some reply
* we don't now need, so discard it */
result = sock->ops->recvfrom(sock, (void *)&reply,
result = sock->ops->recvfrom(sock, (void *) &reply,
sizeof(reply), 1, MSG_PEEK,
NULL, &addrlen);
if (result < 0)
@@ -366,16 +354,16 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
if (result != -ERESTARTSYS)
{
printk("ncp_rpc_call: recv error = %d\n",
-result);
-result);
}
break;
}
if ( (result == sizeof(reply))
if ((result == sizeof(reply))
&& (reply.type == NCP_POSITIVE_ACK))
{
/* Throw away the packet */
DPRINTK("ncp_rpc_call: got positive acknowledge\n");
sock->ops->recvfrom(sock, (void *)&reply,
sock->ops->recvfrom(sock, (void *) &reply,
sizeof(reply), 1, 0,
NULL, &addrlen);
n = 0;
@@ -383,20 +371,19 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
acknowledge_seen = 1;
goto re_select;
}
DDPRINTK("ncpfs: rep.typ: %04X, con: %d, tsk: %d,"
"seq: %d\n",
reply.type,
(reply.conn_high << 8) + reply.conn_low,
reply.task,
reply.sequence);
if ( (result >= sizeof(reply))
&& (reply.type == NCP_REPLY)
&& ( (request.type == NCP_ALLOC_SLOT_REQUEST)
|| ( (reply.sequence == request.sequence)
&& (reply.conn_low == request.conn_low)
/* seem to get wrong task from NW311 && (reply.task == request.task)*/
"seq: %d\n",
reply.type,
(reply.conn_high << 8) + reply.conn_low,
reply.task,
reply.sequence);
if ((result >= sizeof(reply))
&& (reply.type == NCP_REPLY)
&& ((request.type == NCP_ALLOC_SLOT_REQUEST)
|| ((reply.sequence == request.sequence)
&& (reply.conn_low == request.conn_low)
/* seem to get wrong task from NW311 && (reply.task == request.task) */
&& (reply.conn_high == request.conn_high))))
{
if (major_timeout_seen)
@@ -407,7 +394,7 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
* we have xid mismatch, so discard the packet and start
* again. What a hack! but I can't call recvfrom with
* a null buffer yet. */
sock->ops->recvfrom(sock, (void *)&reply, sizeof(reply), 1, 0,
sock->ops->recvfrom(sock, (void *) &reply, sizeof(reply), 1, 0,
NULL, &addrlen);
DPRINTK("ncp_rpc_call: reply mismatch\n");
@@ -417,20 +404,18 @@ do_ncp_rpc_call(struct ncp_server *server, int size)
* we have the correct reply, so read into the correct place and
* return it
*/
result = sock->ops->recvfrom(sock, (void *)start, server->packet_size,
result = sock->ops->recvfrom(sock, (void *) start, server->packet_size,
1, 0, NULL, &addrlen);
if (result < 0)
{
printk("NCP: notice message: result=%d\n", result);
}
else if (result < sizeof(struct ncp_reply_header))
} else if (result < sizeof(struct ncp_reply_header))
{
printk("NCP: just caught a too small read memory size..., "
"email to NET channel\n");
printk("NCP: result=%d,addrlen=%d\n", result, addrlen);
result = -EIO;
}
current->blocked = old_mask;
set_fs(fs);
return result;
@@ -449,7 +434,6 @@ ncp_do_request(struct ncp_server *server, int size)
printk("ncpfs: Server not locked!\n");
return -EIO;
}
return do_ncp_rpc_call(server, size);
}
@@ -460,38 +444,36 @@ int
ncp_request(struct ncp_server *server, int function)
{
struct ncp_request_header *h
= (struct ncp_request_header *)(server->packet);
= (struct ncp_request_header *) (server->packet);
struct ncp_reply_header *reply
= (struct ncp_reply_header *)(server->packet);
= (struct ncp_reply_header *) (server->packet);
int request_size = server->current_size
- sizeof(struct ncp_request_header);
- sizeof(struct ncp_request_header);
int result;
if (server->has_subfunction != 0)
{
*(__u16 *)&(h->data[0]) = request_size - 2;
*(__u16 *) & (h->data[0]) = request_size - 2;
}
h->type = NCP_REQUEST;
server->sequence += 1;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->conn_high = ((server->connection) & 0xff00) >> 8;
h->task = (current->pid) & 0xff;
h->function = function;
h->task = (current->pid) & 0xff;
h->function = function;
if ((result = ncp_do_request(server, request_size + sizeof(*h))) < 0)
{
DPRINTK("ncp_request_error: %d\n", result);
return result;
}
server->completion = reply->completion_code;
server->completion = reply->completion_code;
server->conn_status = reply->connection_state;
server->reply_size = result;
server->reply_size = result;
server->ncp_reply_size = result - sizeof(struct ncp_reply_header);
result = reply->completion_code;
@@ -500,49 +482,48 @@ ncp_request(struct ncp_server *server, int function)
{
DPRINTK("ncp_completion_code: %x\n", result);
}
return result;
return result;
}
int
ncp_connect(struct ncp_server *server)
{
struct ncp_request_header *h
= (struct ncp_request_header *)(server->packet);
= (struct ncp_request_header *) (server->packet);
int result;
h->type = NCP_ALLOC_SLOT_REQUEST;
server->sequence = 0;
h->sequence = server->sequence;
h->conn_low = 0xff;
h->sequence = server->sequence;
h->conn_low = 0xff;
h->conn_high = 0xff;
h->task = (current->pid) & 0xff;
h->function = 0;
h->task = (current->pid) & 0xff;
h->function = 0;
if ((result = ncp_do_request(server, sizeof(*h))) < 0)
{
return result;
}
server->sequence = 0;
server->connection = h->conn_low + (h->conn_high * 256);
return 0;
}
int
ncp_disconnect(struct ncp_server *server)
{
struct ncp_request_header *h
= (struct ncp_request_header *)(server->packet);
= (struct ncp_request_header *) (server->packet);
h->type = NCP_DEALLOC_SLOT_REQUEST;
server->sequence += 1;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->sequence = server->sequence;
h->conn_low = (server->connection) & 0xff;
h->conn_high = ((server->connection) & 0xff00) >> 8;
h->task = (current->pid) & 0xff;
h->function = 0;
h->task = (current->pid) & 0xff;
h->function = 0;
return ncp_do_request(server, sizeof(*h));
}
@@ -557,7 +538,7 @@ ncp_lock_server(struct ncp_server *server)
DPRINTK("ncpfs: server locked!!!\n");
}
#endif
while (server->lock)
while (server->lock)
sleep_on(&server->wait);
server->lock = 1;
}
@@ -565,12 +546,10 @@ ncp_lock_server(struct ncp_server *server)
void
ncp_unlock_server(struct ncp_server *server)
{
if (server->lock != 1)
if (server->lock != 1)
{
printk("ncp_unlock_server: was not locked!\n");
}
server->lock = 0;
wake_up(&server->wait);
printk("ncp_unlock_server: was not locked!\n");
}
server->lock = 0;
wake_up(&server->wait);
}