4 * Copyright (C) 1995, 1996 by Volker Lendecke
5 * Modified for big endian by J.F. Chadima and David S. Miller
6 * Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
7 * Modified 1998 Wolfram Pienkoss for NLS
14 #include <linux/config.h>
17 #include <linux/types.h>
18 #include <linux/errno.h>
19 #include <linux/malloc.h>
20 #include <linux/stat.h>
21 #include <linux/fcntl.h>
22 #include <asm/uaccess.h>
23 #include <asm/byteorder.h>
24 #include <asm/unaligned.h>
25 #include <asm/string.h>
27 #ifdef CONFIG_NCPFS_NLS
28 #include <linux/nls.h>
31 #include <linux/ncp.h>
32 #include <linux/ncp_fs.h>
33 #include <linux/ncp_fs_sb.h>
35 #define NCP_MIN_SYMLINK_SIZE 8
36 #define NCP_MAX_SYMLINK_SIZE 512
38 int ncp_negotiate_buffersize(struct ncp_server
*, int, int *);
39 int ncp_negotiate_size_and_options(struct ncp_server
*server
, int size
,
40 int options
, int *ret_size
, int *ret_options
);
41 int ncp_get_volume_info_with_number(struct ncp_server
*, int,
42 struct ncp_volume_info
*);
43 int ncp_close_file(struct ncp_server
*, const char *);
44 static inline int ncp_read_bounce_size(__u32 size
) {
45 return sizeof(struct ncp_reply_header
) + 2 + 2 + size
+ 8;
47 int ncp_read_bounce(struct ncp_server
*, const char *, __u32
, __u16
,
48 char *, int *, void* bounce
, __u32 bouncelen
);
49 int ncp_read_kernel(struct ncp_server
*, const char *, __u32
, __u16
,
51 int ncp_write_kernel(struct ncp_server
*, const char *, __u32
, __u16
,
54 int ncp_obtain_info(struct ncp_server
*server
, struct inode
*, char *,
55 struct nw_info_struct
*target
);
56 int ncp_lookup_volume(struct ncp_server
*, char *, struct nw_info_struct
*);
57 int ncp_modify_file_or_subdir_dos_info(struct ncp_server
*, struct inode
*,
58 __u32
, const struct nw_modify_dos_info
*info
);
59 int ncp_modify_file_or_subdir_dos_info_path(struct ncp_server
*, struct inode
*,
60 const char* path
, __u32
, const struct nw_modify_dos_info
*info
);
62 int ncp_del_file_or_subdir2(struct ncp_server
*, struct dentry
*);
63 int ncp_del_file_or_subdir(struct ncp_server
*, struct inode
*, char *);
64 int ncp_open_create_file_or_subdir(struct ncp_server
*, struct inode
*, char *,
65 int, __u32
, int, struct nw_file_info
*);
67 int ncp_initialize_search(struct ncp_server
*, struct inode
*,
68 struct nw_search_sequence
*target
);
69 int ncp_search_for_file_or_subdir(struct ncp_server
*server
,
70 struct nw_search_sequence
*seq
,
71 struct nw_info_struct
*target
);
73 int ncp_ren_or_mov_file_or_subdir(struct ncp_server
*server
,
74 struct inode
*, char *, struct inode
*, char *);
78 ncp_LogPhysicalRecord(struct ncp_server
*server
,
79 const char *file_id
, __u8 locktype
,
80 __u32 offset
, __u32 length
, __u16 timeout
);
82 #ifdef CONFIG_NCPFS_IOCTL_LOCKING
84 ncp_ClearPhysicalRecord(struct ncp_server
*server
,
86 __u32 offset
, __u32 length
);
87 #endif /* CONFIG_NCPFS_IOCTL_LOCKING */
89 #ifdef CONFIG_NCPFS_MOUNT_SUBDIR
91 ncp_mount_subdir(struct ncp_server
* server
, __u8 volNumber
,
92 __u8 srcNS
, __u32 srcDirEntNum
);
93 #endif /* CONFIG_NCPFS_MOUNT_SUBDIR */
95 #ifdef CONFIG_NCPFS_NLS
96 /* This are the NLS conversion routines with inspirations and code parts
97 * from the vfat file system and hints from Petr Vandrovec.
101 * It should be replaced by charset specifc conversion. Gordon Chaffee
102 * has prepared some things, but I don't know, what he thinks about it.
103 * The conversion tables for the io charsets should be generatable by
104 * Unicode table, shouldn't it? I have written so generation code for it.
105 * The tables for the vendor specific codepages...? Hmm. The Samba sources
106 * contains also any hints.
109 #define toupperif(c, u) ((((u) != 0) && ((c) >= 'a') && ((c) <= 'z')) \
110 ? (c)-('a'-'A') : (c))
111 #define tolowerif(c, u) ((((u) != 0) && ((c) >= 'A') && ((c) <= 'Z')) \
112 ? (c)-('A'-'a') : (c))
115 io2vol(struct ncp_server
*server
, char *name
, int case_trans
)
120 struct nls_unicode uc
;
121 struct nls_table
*nls_in
;
122 struct nls_table
*nls_out
;
124 nls_in
= server
->nls_io
;
125 nls_out
= server
->nls_vol
;
131 uc
= nls_in
->charset2uni
[toupperif(*np
, case_trans
)];
132 up
= nls_out
->page_uni2charset
[uc
.uni2
];
133 if (up
!= NULL
) nc
= up
[uc
.uni1
];
134 if (nc
!= 0) *np
= nc
;
140 vol2io(struct ncp_server
*server
, char *name
, int case_trans
)
145 struct nls_unicode uc
;
146 struct nls_table
*nls_in
;
147 struct nls_table
*nls_out
;
149 nls_in
= server
->nls_vol
;
150 nls_out
= server
->nls_io
;
156 uc
= nls_in
->charset2uni
[*np
];
157 up
= nls_out
->page_uni2charset
[uc
.uni2
];
158 if (up
!= NULL
) nc
= up
[uc
.uni1
];
159 if (nc
== 0) nc
= *np
;
160 *np
= tolowerif(nc
, case_trans
);
167 #define io2vol(S,N,U) if (U) str_upper(N)
168 #define vol2io(S,N,U) if (U) str_lower(N)
170 #endif /* CONFIG_NCPFS_NLS */
172 #endif /* _NCPLIB_H */