提交 bd32895c 编写于 作者: G Greg Kroah-Hartman

staging: ncpfs: delete it

The ncpfs code moved into the staging tree back in November 2017 and no
one has complained or even noticed it was gone.  Because of that, let's
just delete it.

Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 be65f9ed
......@@ -26,8 +26,6 @@ if STAGING
source "drivers/staging/ipx/Kconfig"
source "drivers/staging/ncpfs/Kconfig"
source "drivers/staging/wlan-ng/Kconfig"
source "drivers/staging/comedi/Kconfig"
......
......@@ -4,7 +4,6 @@
obj-y += media/
obj-y += typec/
obj-$(CONFIG_IPX) += ipx/
obj-$(CONFIG_NCP_FS) += ncpfs/
obj-$(CONFIG_PRISM2_USB) += wlan-ng/
obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
......
#
# NCP Filesystem configuration
#
config NCP_FS
tristate "NCP file system support (to mount NetWare volumes)"
depends on IPX!=n || INET
help
NCP (NetWare Core Protocol) is a protocol that runs over IPX and is
used by Novell NetWare clients to talk to file servers. It is to
IPX what NFS is to TCP/IP, if that helps. Saying Y here allows you
to mount NetWare file server volumes and to access them just like
any other Unix directory. For details, please read the file
<file:Documentation/filesystems/ncpfs.txt> in the kernel source and
the IPX-HOWTO from <http://www.tldp.org/docs.html#howto>.
You do not have to say Y here if you want your Linux box to act as a
file *server* for Novell NetWare clients.
General information about how to connect Linux, Windows machines and
Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>.
To compile this as a module, choose M here: the module will be called
ncpfs. Say N unless you are connected to a Novell network.
config NCPFS_PACKET_SIGNING
bool "Packet signatures"
depends on NCP_FS
help
NCP allows packets to be signed for stronger security. If you want
security, say Y. Normal users can leave it off. To be able to use
packet signing you must use ncpfs > 2.0.12.
config NCPFS_IOCTL_LOCKING
bool "Proprietary file locking"
depends on NCP_FS
help
Allows locking of records on remote volumes. Say N unless you have
special applications which are able to utilize this locking scheme.
config NCPFS_STRONG
bool "Clear remove/delete inhibit when needed"
depends on NCP_FS
help
Allows manipulation of files flagged as Delete or Rename Inhibit.
To use this feature you must mount volumes with the ncpmount
parameter "-s" (ncpfs-2.0.12 and newer). Say Y unless you are not
mounting volumes with -f 444.
config NCPFS_NFS_NS
bool "Use NFS namespace if available"
depends on NCP_FS
help
Allows you to utilize NFS namespace on NetWare servers. It brings
you case sensitive filenames. Say Y. You can disable it at
mount-time with the `-N nfs' parameter of ncpmount.
config NCPFS_OS2_NS
bool "Use LONG (OS/2) namespace if available"
depends on NCP_FS
help
Allows you to utilize OS2/LONG namespace on NetWare servers.
Filenames in this namespace are limited to 255 characters, they are
case insensitive, and case in names is preserved. Say Y. You can
disable it at mount time with the -N os2 parameter of ncpmount.
config NCPFS_SMALLDOS
bool "Lowercase DOS filenames"
depends on NCP_FS
---help---
If you say Y here, every filename on a NetWare server volume using
the OS2/LONG namespace and created under DOS or on a volume using
DOS namespace will be converted to lowercase characters.
Saying N here will give you these filenames in uppercase.
This is only a cosmetic option since the OS2/LONG namespace is case
insensitive. The only major reason for this option is backward
compatibility when moving from DOS to OS2/LONG namespace support.
Long filenames (created by Win95) will not be affected.
This option does not solve the problem that filenames appear
differently under Linux and under Windows, since Windows does an
additional conversions on the client side. You can achieve similar
effects by saying Y to "Allow using of Native Language Support"
below.
config NCPFS_NLS
bool "Use Native Language Support"
depends on NCP_FS
select NLS
help
Allows you to use codepages and I/O charsets for file name
translation between the server file system and input/output. This
may be useful, if you want to access the server with other operating
systems, e.g. Windows 95. See also NLS for more Information.
To select codepages and I/O charsets use ncpfs-2.2.0.13 or newer.
config NCPFS_EXTRAS
bool "Enable symbolic links and execute flags"
depends on NCP_FS
help
This enables the use of symbolic links and an execute permission
bit on NCPFS. The file server need not have long name space or NFS
name space loaded for these to work.
To use the new attributes, it is recommended to use the flags
'-f 600 -d 755' on the ncpmount command line.
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the linux ncp filesystem routines.
#
obj-$(CONFIG_NCP_FS) += ncpfs.o
ncpfs-y := dir.o file.o inode.o ioctl.o mmap.o ncplib_kernel.o sock.o \
ncpsign_kernel.o getopt.o
ncpfs-$(CONFIG_NCPFS_EXTRAS) += symlink.o
ncpfs-$(CONFIG_NCPFS_NFS_NS) += symlink.o
# If you want debugging output, please uncomment the following line
# ccflags-y := -DDEBUG_NCP=1
CFLAGS_ncplib_kernel.o := -finline-functions
The ncpfs code will be removed soon from the kernel tree as it is old and
obsolete and broken.
Don't worry about fixing up anything here, it's not needed.
此差异已折叠。
// SPDX-License-Identifier: GPL-2.0
/*
* file.c
*
* Copyright (C) 1995, 1996 by Volker Lendecke
* Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
*
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/uaccess.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/stat.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/sched.h>
#include "ncp_fs.h"
static int ncp_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
return file_write_and_wait_range(file, start, end);
}
/*
* Open a file with the specified read/write mode.
*/
int ncp_make_open(struct inode *inode, int right)
{
int error;
int access;
error = -EINVAL;
if (!inode) {
pr_err("%s: got NULL inode\n", __func__);
goto out;
}
ncp_dbg(1, "opened=%d, volume # %u, dir entry # %u\n",
atomic_read(&NCP_FINFO(inode)->opened),
NCP_FINFO(inode)->volNumber,
NCP_FINFO(inode)->dirEntNum);
error = -EACCES;
mutex_lock(&NCP_FINFO(inode)->open_mutex);
if (!atomic_read(&NCP_FINFO(inode)->opened)) {
struct ncp_entry_info finfo;
int result;
/* tries max. rights */
finfo.access = O_RDWR;
result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
inode, NULL, OC_MODE_OPEN,
0, AR_READ | AR_WRITE, &finfo);
if (!result)
goto update;
/* RDWR did not succeeded, try readonly or writeonly as requested */
switch (right) {
case O_RDONLY:
finfo.access = O_RDONLY;
result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
inode, NULL, OC_MODE_OPEN,
0, AR_READ, &finfo);
break;
case O_WRONLY:
finfo.access = O_WRONLY;
result = ncp_open_create_file_or_subdir(NCP_SERVER(inode),
inode, NULL, OC_MODE_OPEN,
0, AR_WRITE, &finfo);
break;
}
if (result) {
ncp_vdbg("failed, result=%d\n", result);
goto out_unlock;
}
/*
* Update the inode information.
*/
update:
ncp_update_inode(inode, &finfo);
atomic_set(&NCP_FINFO(inode)->opened, 1);
}
access = NCP_FINFO(inode)->access;
ncp_vdbg("file open, access=%x\n", access);
if (access == right || access == O_RDWR) {
atomic_inc(&NCP_FINFO(inode)->opened);
error = 0;
}
out_unlock:
mutex_unlock(&NCP_FINFO(inode)->open_mutex);
out:
return error;
}
static ssize_t
ncp_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file_inode(file);
size_t already_read = 0;
off_t pos = iocb->ki_pos;
size_t bufsize;
int error;
void *freepage;
size_t freelen;
ncp_dbg(1, "enter %pD2\n", file);
if (!iov_iter_count(to))
return 0;
if (pos > inode->i_sb->s_maxbytes)
return 0;
iov_iter_truncate(to, inode->i_sb->s_maxbytes - pos);
error = ncp_make_open(inode, O_RDONLY);
if (error) {
ncp_dbg(1, "open failed, error=%d\n", error);
return error;
}
bufsize = NCP_SERVER(inode)->buffer_size;
error = -EIO;
freelen = ncp_read_bounce_size(bufsize);
freepage = vmalloc(freelen);
if (!freepage)
goto outrel;
error = 0;
/* First read in as much as possible for each bufsize. */
while (iov_iter_count(to)) {
int read_this_time;
size_t to_read = min_t(size_t,
bufsize - (pos % bufsize),
iov_iter_count(to));
error = ncp_read_bounce(NCP_SERVER(inode),
NCP_FINFO(inode)->file_handle,
pos, to_read, to, &read_this_time,
freepage, freelen);
if (error) {
error = -EIO; /* NW errno -> Linux errno */
break;
}
pos += read_this_time;
already_read += read_this_time;
if (read_this_time != to_read)
break;
}
vfree(freepage);
iocb->ki_pos = pos;
file_accessed(file);
ncp_dbg(1, "exit %pD2\n", file);
outrel:
ncp_inode_close(inode);
return already_read ? already_read : error;
}
static ssize_t
ncp_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct inode *inode = file_inode(file);
size_t already_written = 0;
size_t bufsize;
int errno;
void *bouncebuffer;
off_t pos;
ncp_dbg(1, "enter %pD2\n", file);
errno = generic_write_checks(iocb, from);
if (errno <= 0)
return errno;
errno = ncp_make_open(inode, O_WRONLY);
if (errno) {
ncp_dbg(1, "open failed, error=%d\n", errno);
return errno;
}
bufsize = NCP_SERVER(inode)->buffer_size;
errno = file_update_time(file);
if (errno)
goto outrel;
bouncebuffer = vmalloc(bufsize);
if (!bouncebuffer) {
errno = -EIO; /* -ENOMEM */
goto outrel;
}
pos = iocb->ki_pos;
while (iov_iter_count(from)) {
int written_this_time;
size_t to_write = min_t(size_t,
bufsize - (pos % bufsize),
iov_iter_count(from));
if (!copy_from_iter_full(bouncebuffer, to_write, from)) {
errno = -EFAULT;
break;
}
if (ncp_write_kernel(NCP_SERVER(inode),
NCP_FINFO(inode)->file_handle,
pos, to_write, bouncebuffer, &written_this_time) != 0) {
errno = -EIO;
break;
}
pos += written_this_time;
already_written += written_this_time;
if (written_this_time != to_write)
break;
}
vfree(bouncebuffer);
iocb->ki_pos = pos;
if (pos > i_size_read(inode)) {
inode_lock(inode);
if (pos > i_size_read(inode))
i_size_write(inode, pos);
inode_unlock(inode);
}
ncp_dbg(1, "exit %pD2\n", file);
outrel:
ncp_inode_close(inode);
return already_written ? already_written : errno;
}
static int ncp_release(struct inode *inode, struct file *file) {
if (ncp_make_closed(inode)) {
ncp_dbg(1, "failed to close\n");
}
return 0;
}
const struct file_operations ncp_file_operations =
{
.llseek = generic_file_llseek,
.read_iter = ncp_file_read_iter,
.write_iter = ncp_file_write_iter,
.unlocked_ioctl = ncp_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ncp_compat_ioctl,
#endif
.mmap = ncp_mmap,
.release = ncp_release,
.fsync = ncp_fsync,
};
const struct inode_operations ncp_file_inode_operations =
{
.setattr = ncp_notify_change,
};
// SPDX-License-Identifier: GPL-2.0
/*
* getopt.c
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/string.h>
#include <asm/errno.h>
#include "getopt.h"
/**
* ncp_getopt - option parser
* @caller: name of the caller, for error messages
* @options: the options string
* @opts: an array of &struct option entries controlling parser operations
* @optopt: output; will contain the current option
* @optarg: output; will contain the value (if one exists)
* @value: output; may be NULL; will be overwritten with the integer value
* of the current argument.
*
* Helper to parse options on the format used by mount ("a=b,c=d,e,f").
* Returns opts->val if a matching entry in the 'opts' array is found,
* 0 when no more tokens are found, -1 if an error is encountered.
*/
int ncp_getopt(const char *caller, char **options, const struct ncp_option *opts,
char **optopt, char **optarg, unsigned long *value)
{
char *token;
char *val;
do {
if ((token = strsep(options, ",")) == NULL)
return 0;
} while (*token == '\0');
if (optopt)
*optopt = token;
if ((val = strchr (token, '=')) != NULL) {
*val++ = 0;
}
*optarg = val;
for (; opts->name; opts++) {
if (!strcmp(opts->name, token)) {
if (!val) {
if (opts->has_arg & OPT_NOPARAM) {
return opts->val;
}
pr_info("%s: the %s option requires an argument\n",
caller, token);
return -EINVAL;
}
if (opts->has_arg & OPT_INT) {
int rc = kstrtoul(val, 0, value);
if (rc) {
pr_info("%s: invalid numeric value in %s=%s\n",
caller, token, val);
return rc;
}
return opts->val;
}
if (opts->has_arg & OPT_STRING) {
return opts->val;
}
pr_info("%s: unexpected argument %s to the %s option\n",
caller, val, token);
return -EINVAL;
}
}
pr_info("%s: Unrecognized mount option %s\n", caller, token);
return -EOPNOTSUPP;
}
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_GETOPT_H
#define _LINUX_GETOPT_H
#define OPT_NOPARAM 1
#define OPT_INT 2
#define OPT_STRING 4
struct ncp_option {
const char *name;
unsigned int has_arg;
int val;
};
extern int ncp_getopt(const char *caller, char **options, const struct ncp_option *opts,
char **optopt, char **optarg, unsigned long *value);
#endif /* _LINUX_GETOPT_H */
此差异已折叠。
此差异已折叠。
// SPDX-License-Identifier: GPL-2.0
/*
* mmap.c
*
* Copyright (C) 1995, 1996 by Volker Lendecke
* Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
*
*/
#include <linux/stat.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/gfp.h>
#include <linux/mm.h>
#include <linux/shm.h>
#include <linux/errno.h>
#include <linux/mman.h>
#include <linux/string.h>
#include <linux/fcntl.h>
#include <linux/memcontrol.h>
#include <linux/uaccess.h>
#include "ncp_fs.h"
/*
* Fill in the supplied page for mmap
* XXX: how are we excluding truncate/invalidate here? Maybe need to lock
* page?
*/
static int ncp_file_mmap_fault(struct vm_fault *vmf)
{
struct inode *inode = file_inode(vmf->vma->vm_file);
char *pg_addr;
unsigned int already_read;
unsigned int count;
int bufsize;
int pos; /* XXX: loff_t ? */
/*
* ncpfs has nothing against high pages as long
* as recvmsg and memset works on it
*/
vmf->page = alloc_page(GFP_HIGHUSER);
if (!vmf->page)
return VM_FAULT_OOM;
pg_addr = kmap(vmf->page);
pos = vmf->pgoff << PAGE_SHIFT;
count = PAGE_SIZE;
/* what we can read in one go */
bufsize = NCP_SERVER(inode)->buffer_size;
already_read = 0;
if (ncp_make_open(inode, O_RDONLY) >= 0) {
while (already_read < count) {
int read_this_time;
int to_read;
to_read = bufsize - (pos % bufsize);
to_read = min_t(unsigned int, to_read, count - already_read);
if (ncp_read_kernel(NCP_SERVER(inode),
NCP_FINFO(inode)->file_handle,
pos, to_read,
pg_addr + already_read,
&read_this_time) != 0) {
read_this_time = 0;
}
pos += read_this_time;
already_read += read_this_time;
if (read_this_time < to_read) {
break;
}
}
ncp_inode_close(inode);
}
if (already_read < PAGE_SIZE)
memset(pg_addr + already_read, 0, PAGE_SIZE - already_read);
flush_dcache_page(vmf->page);
kunmap(vmf->page);
/*
* If I understand ncp_read_kernel() properly, the above always
* fetches from the network, here the analogue of disk.
* -- nyc
*/
count_vm_event(PGMAJFAULT);
count_memcg_event_mm(vmf->vma->vm_mm, PGMAJFAULT);
return VM_FAULT_MAJOR;
}
static const struct vm_operations_struct ncp_file_mmap =
{
.fault = ncp_file_mmap_fault,
};
/* This is used for a general mmap of a ncp file */
int ncp_mmap(struct file *file, struct vm_area_struct *vma)
{
struct inode *inode = file_inode(file);
ncp_dbg(1, "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)
return -EINVAL;
/* we do not support files bigger than 4GB... We eventually
supports just 4GB... */
if (vma_pages(vma) + vma->vm_pgoff
> (1U << (32 - PAGE_SHIFT)))
return -EFBIG;
vma->vm_ops = &ncp_file_mmap;
file_accessed(file);
return 0;
}
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/ncp_fs.h>
#include "ncp_fs_i.h"
#include "ncp_fs_sb.h"
#undef NCPFS_PARANOIA
#ifdef NCPFS_PARANOIA
#define ncp_vdbg(fmt, ...) \
pr_debug(fmt, ##__VA_ARGS__)
#else
#define ncp_vdbg(fmt, ...) \
do { \
if (0) \
pr_debug(fmt, ##__VA_ARGS__); \
} while (0)
#endif
#ifndef DEBUG_NCP
#define DEBUG_NCP 0
#endif
#if DEBUG_NCP > 0 && !defined(DEBUG)
#define DEBUG
#endif
#define ncp_dbg(level, fmt, ...) \
do { \
if (level <= DEBUG_NCP) \
pr_debug(fmt, ##__VA_ARGS__); \
} while (0)
#define NCP_MAX_RPC_TIMEOUT (6*HZ)
struct ncp_entry_info {
struct nw_info_struct i;
ino_t ino;
int opened;
int access;
unsigned int volume;
__u8 file_handle[6];
};
static inline struct ncp_server *NCP_SBP(const struct super_block *sb)
{
return sb->s_fs_info;
}
#define NCP_SERVER(inode) NCP_SBP((inode)->i_sb)
static inline struct ncp_inode_info *NCP_FINFO(const struct inode *inode)
{
return container_of(inode, struct ncp_inode_info, vfs_inode);
}
/* linux/fs/ncpfs/inode.c */
int ncp_notify_change(struct dentry *, struct iattr *);
struct inode *ncp_iget(struct super_block *, struct ncp_entry_info *);
void ncp_update_inode(struct inode *, struct ncp_entry_info *);
void ncp_update_inode2(struct inode *, struct ncp_entry_info *);
/* linux/fs/ncpfs/dir.c */
extern const struct inode_operations ncp_dir_inode_operations;
extern const struct file_operations ncp_dir_operations;
extern const struct dentry_operations ncp_dentry_operations;
int ncp_conn_logged_in(struct super_block *);
int ncp_date_dos2unix(__le16 time, __le16 date);
void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date);
/* linux/fs/ncpfs/ioctl.c */
long ncp_ioctl(struct file *, unsigned int, unsigned long);
long ncp_compat_ioctl(struct file *, unsigned int, unsigned long);
/* linux/fs/ncpfs/sock.c */
int ncp_request2(struct ncp_server *server, int function,
void* reply, int max_reply_size);
static inline int ncp_request(struct ncp_server *server, int function) {
return ncp_request2(server, function, server->packet, server->packet_size);
}
int ncp_connect(struct ncp_server *server);
int ncp_disconnect(struct ncp_server *server);
void ncp_lock_server(struct ncp_server *server);
void ncp_unlock_server(struct ncp_server *server);
/* linux/fs/ncpfs/symlink.c */
#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
extern const struct address_space_operations ncp_symlink_aops;
int ncp_symlink(struct inode*, struct dentry*, const char*);
#endif
/* linux/fs/ncpfs/file.c */
extern const struct inode_operations ncp_file_inode_operations;
extern const struct file_operations ncp_file_operations;
int ncp_make_open(struct inode *, int);
/* linux/fs/ncpfs/mmap.c */
int ncp_mmap(struct file *, struct vm_area_struct *);
/* linux/fs/ncpfs/ncplib_kernel.c */
int ncp_make_closed(struct inode *);
#include "ncplib_kernel.h"
/* SPDX-License-Identifier: GPL-2.0 */
/*
* ncp_fs_i.h
*
* Copyright (C) 1995 Volker Lendecke
*
*/
#ifndef _LINUX_NCP_FS_I
#define _LINUX_NCP_FS_I
/*
* This is the ncpfs part of the inode structure. This must contain
* all the information we need to work with an inode after creation.
*/
struct ncp_inode_info {
__le32 dirEntNum;
__le32 DosDirNum;
__u8 volNumber;
__le32 nwattr;
struct mutex open_mutex;
atomic_t opened;
int access;
int flags;
#define NCPI_KLUDGE_SYMLINK 0x0001
#define NCPI_DIR_CACHE 0x0002
__u8 file_handle[6];
struct inode vfs_inode;
};
#endif /* _LINUX_NCP_FS_I */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* ncp_fs_sb.h
*
* Copyright (C) 1995, 1996 by Volker Lendecke
*
*/
#ifndef _NCP_FS_SB
#define _NCP_FS_SB
#include <linux/types.h>
#include <linux/ncp_mount.h>
#include <linux/net.h>
#include <linux/mutex.h>
#include <linux/backing-dev.h>
#include <linux/workqueue.h>
#define NCP_DEFAULT_OPTIONS 0 /* 2 for packet signatures */
struct sock;
struct ncp_mount_data_kernel {
unsigned long flags; /* NCP_MOUNT_* flags */
unsigned int int_flags; /* internal flags */
#define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001
kuid_t mounted_uid; /* Who may umount() this filesystem? */
struct pid *wdog_pid; /* Who cares for our watchdog packets? */
unsigned int ncp_fd; /* The socket to the ncp port */
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 char mounted_vol[NCP_VOLNAME_LEN + 1];
kuid_t uid;
kgid_t gid;
umode_t file_mode;
umode_t dir_mode;
int info_fd;
};
struct ncp_server {
struct rcu_head rcu;
struct ncp_mount_data_kernel 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 + 2];
struct socket *ncp_sock;/* ncp socket */
struct socket *info_sock;
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
requests allowed anymore.
Bit 0 = 1 ==> Server is down. */
int buffer_size; /* Negotiated bufsize */
int reply_size; /* Size of last reply */
int packet_size;
unsigned char *packet; /* Here we prepare requests and
receive replies */
unsigned char *txbuf; /* Storage for current request */
unsigned char *rxbuf; /* Storage for reply to current request */
int lock; /* To prevent mismatch in protocols. */
struct mutex mutex;
int current_size; /* for packet preparation */
int has_subfunction;
int ncp_reply_size;
int root_setuped;
struct mutex root_setup_lock;
/* info for packet signing */
int sign_wanted; /* 1=Server needs signed packets */
int sign_active; /* 0=don't do signing, 1=do */
char sign_root[8]; /* generated from password and encr. key */
char sign_last[16];
/* Authentication info: NDS or BINDERY, username */
struct {
int auth_type;
size_t object_name_len;
void* object_name;
int object_type;
} auth;
/* Password info */
struct {
size_t len;
void* data;
} priv;
struct rw_semaphore auth_rwsem;
/* nls info: codepage for volume and charset for I/O */
struct nls_table *nls_vol;
struct nls_table *nls_io;
/* maximum age in jiffies */
atomic_t dentry_ttl;
/* miscellaneous */
unsigned int flags;
spinlock_t requests_lock; /* Lock accesses to tx.requests, tx.creq and rcv.creq when STREAM mode */
void (*data_ready)(struct sock* sk);
void (*error_report)(struct sock* sk);
void (*write_space)(struct sock* sk); /* STREAM mode only */
struct {
struct work_struct tq; /* STREAM/DGRAM: data/error ready */
struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
unsigned int state; /* STREAM only: receiver state */
struct {
__u32 magic __packed;
__u32 len __packed;
__u16 type __packed;
__u16 p1 __packed;
__u16 p2 __packed;
__u16 p3 __packed;
__u16 type2 __packed;
} buf; /* STREAM only: temporary buffer */
unsigned char* ptr; /* STREAM only: pointer to data */
size_t len; /* STREAM only: length of data to receive */
} rcv;
struct {
struct list_head requests; /* STREAM only: queued requests */
struct work_struct tq; /* STREAM only: transmitter ready */
struct ncp_request_reply* creq; /* STREAM only: currently transmitted entry */
} tx;
struct timer_list timeout_tm; /* DGRAM only: timeout timer */
struct work_struct timeout_tq; /* DGRAM only: associated queue, we run timers from process context */
int timeout_last; /* DGRAM only: current timeout length */
int timeout_retries; /* DGRAM only: retries left */
struct {
size_t len;
__u8 data[128];
} unexpected_packet;
};
extern void ncp_tcp_rcv_proc(struct work_struct *work);
extern void ncp_tcp_tx_proc(struct work_struct *work);
extern void ncpdgram_rcv_proc(struct work_struct *work);
extern void ncpdgram_timeout_proc(struct work_struct *work);
extern void ncpdgram_timeout_call(struct timer_list *t);
extern void ncp_tcp_data_ready(struct sock* sk);
extern void ncp_tcp_write_space(struct sock* sk);
extern void ncp_tcp_error_report(struct sock* sk);
#define NCP_FLAG_UTF8 1
#define NCP_CLR_FLAG(server, flag) ((server)->flags &= ~(flag))
#define NCP_SET_FLAG(server, flag) ((server)->flags |= (flag))
#define NCP_IS_FLAG(server, flag) ((server)->flags & (flag))
static inline int ncp_conn_valid(struct ncp_server *server)
{
return ((server->conn_status & 0x11) == 0);
}
static inline void ncp_invalidate_conn(struct ncp_server *server)
{
server->conn_status |= 0x01;
}
#endif
此差异已折叠。
/* SPDX-License-Identifier: GPL-2.0 */
/*
* ncplib_kernel.h
*
* Copyright (C) 1995, 1996 by Volker Lendecke
* Modified for big endian by J.F. Chadima and David S. Miller
* Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
* Modified 1998, 1999 Wolfram Pienkoss for NLS
* Modified 1999 Wolfram Pienkoss for directory caching
*
*/
#ifndef _NCPLIB_H
#define _NCPLIB_H
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/fcntl.h>
#include <linux/pagemap.h>
#include <linux/uaccess.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
#include <asm/string.h>
#ifdef CONFIG_NCPFS_NLS
#include <linux/nls.h>
#else
#include <linux/ctype.h>
#endif /* CONFIG_NCPFS_NLS */
#define NCP_MIN_SYMLINK_SIZE 8
#define NCP_MAX_SYMLINK_SIZE 512
#define NCP_BLOCK_SHIFT 9
#define NCP_BLOCK_SIZE (1 << (NCP_BLOCK_SHIFT))
int ncp_negotiate_buffersize(struct ncp_server *, int, int *);
int ncp_negotiate_size_and_options(struct ncp_server *server, int size,
int options, int *ret_size, int *ret_options);
int ncp_get_volume_info_with_number(struct ncp_server* server, int n,
struct ncp_volume_info *target);
int ncp_get_directory_info(struct ncp_server* server, __u8 dirhandle,
struct ncp_volume_info* target);
int ncp_close_file(struct ncp_server *, const char *);
static inline int ncp_read_bounce_size(__u32 size) {
return sizeof(struct ncp_reply_header) + 2 + 2 + size + 8;
};
int ncp_read_bounce(struct ncp_server *, const char *, __u32, __u16,
struct iov_iter *, int *, void *bounce, __u32 bouncelen);
int ncp_read_kernel(struct ncp_server *, const char *, __u32, __u16,
char *, int *);
int ncp_write_kernel(struct ncp_server *, const char *, __u32, __u16,
const char *, int *);
static inline void ncp_inode_close(struct inode *inode) {
atomic_dec(&NCP_FINFO(inode)->opened);
}
void ncp_extract_file_info(const void* src, struct nw_info_struct* target);
int ncp_obtain_info(struct ncp_server *server, struct inode *, const char *,
struct nw_info_struct *target);
int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target);
int ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns);
int ncp_get_volume_root(struct ncp_server *server, const char *volname,
__u32 *volume, __le32 *dirent, __le32 *dosdirent);
int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *);
int ncp_modify_file_or_subdir_dos_info(struct ncp_server *, struct inode *,
__le32, const struct nw_modify_dos_info *info);
int ncp_modify_file_or_subdir_dos_info_path(struct ncp_server *, struct inode *,
const char* path, __le32, const struct nw_modify_dos_info *info);
int ncp_modify_nfs_info(struct ncp_server *, __u8 volnum, __le32 dirent,
__u32 mode, __u32 rdev);
int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*);
int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, const char *);
int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, const char *,
int, __le32, __le16, struct ncp_entry_info *);
int ncp_initialize_search(struct ncp_server *, struct inode *,
struct nw_search_sequence *target);
int ncp_search_for_fileset(struct ncp_server *server,
struct nw_search_sequence *seq,
int* more, int* cnt,
char* buffer, size_t bufsize,
char** rbuf, size_t* rsize);
int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
struct inode *, const char *, struct inode *, const char *);
int
ncp_LogPhysicalRecord(struct ncp_server *server,
const char *file_id, __u8 locktype,
__u32 offset, __u32 length, __u16 timeout);
#ifdef CONFIG_NCPFS_IOCTL_LOCKING
int
ncp_ClearPhysicalRecord(struct ncp_server *server,
const char *file_id,
__u32 offset, __u32 length);
#endif /* CONFIG_NCPFS_IOCTL_LOCKING */
int
ncp_mount_subdir(struct ncp_server *, __u8, __u8, __le32,
__u32* volume, __le32* dirent, __le32* dosdirent);
int ncp_dirhandle_alloc(struct ncp_server *, __u8 vol, __le32 dirent, __u8 *dirhandle);
int ncp_dirhandle_free(struct ncp_server *, __u8 dirhandle);
int ncp_create_new(struct inode *dir, struct dentry *dentry,
umode_t mode, dev_t rdev, __le32 attributes);
static inline int ncp_is_nfs_extras(struct ncp_server* server, unsigned int volnum) {
#ifdef CONFIG_NCPFS_NFS_NS
return (server->m.flags & NCP_MOUNT_NFS_EXTRAS) &&
(server->name_space[volnum] == NW_NS_NFS);
#else
return 0;
#endif
}
#ifdef CONFIG_NCPFS_NLS
int ncp__io2vol(struct ncp_server *, unsigned char *, unsigned int *,
const unsigned char *, unsigned int, int);
int ncp__vol2io(struct ncp_server *, unsigned char *, unsigned int *,
const unsigned char *, unsigned int, int);
#define NCP_ESC ':'
#define NCP_IO_TABLE(sb) (NCP_SBP(sb)->nls_io)
#define ncp_tolower(t, c) nls_tolower(t, c)
#define ncp_toupper(t, c) nls_toupper(t, c)
#define ncp_strnicmp(t, s1, s2, len) \
nls_strnicmp(t, s1, s2, len)
#define ncp_io2vol(S,m,i,n,k,U) ncp__io2vol(S,m,i,n,k,U)
#define ncp_vol2io(S,m,i,n,k,U) ncp__vol2io(S,m,i,n,k,U)
#else
int ncp__io2vol(unsigned char *, unsigned int *,
const unsigned char *, unsigned int, int);
int ncp__vol2io(unsigned char *, unsigned int *,
const unsigned char *, unsigned int, int);
#define NCP_IO_TABLE(sb) NULL
#define ncp_tolower(t, c) tolower(c)
#define ncp_toupper(t, c) toupper(c)
#define ncp_io2vol(S,m,i,n,k,U) ncp__io2vol(m,i,n,k,U)
#define ncp_vol2io(S,m,i,n,k,U) ncp__vol2io(m,i,n,k,U)
static inline int ncp_strnicmp(const struct nls_table *t,
const unsigned char *s1, const unsigned char *s2, int len)
{
while (len--) {
if (tolower(*s1++) != tolower(*s2++))
return 1;
}
return 0;
}
#endif /* CONFIG_NCPFS_NLS */
#define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time)
#define NCP_MAX_AGE(server) atomic_read(&(server)->dentry_ttl)
#define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server))
static inline void
ncp_age_dentry(struct ncp_server* server, struct dentry* dentry)
{
dentry->d_time = jiffies - NCP_MAX_AGE(server);
}
static inline void
ncp_new_dentry(struct dentry* dentry)
{
dentry->d_time = jiffies;
}
struct ncp_cache_head {
time_t mtime;
unsigned long time; /* cache age */
unsigned long end; /* last valid fpos in cache */
int eof;
};
#define NCP_DIRCACHE_SIZE ((int)(PAGE_SIZE/sizeof(struct dentry *)))
union ncp_dir_cache {
struct ncp_cache_head head;
struct dentry *dentry[NCP_DIRCACHE_SIZE];
};
#define NCP_FIRSTCACHE_SIZE ((int)((NCP_DIRCACHE_SIZE * \
sizeof(struct dentry *) - sizeof(struct ncp_cache_head)) / \
sizeof(struct dentry *)))
#define NCP_DIRCACHE_START (NCP_DIRCACHE_SIZE - NCP_FIRSTCACHE_SIZE)
struct ncp_cache_control {
struct ncp_cache_head head;
struct page *page;
union ncp_dir_cache *cache;
unsigned long fpos, ofs;
int filled, valid, idx;
};
#endif /* _NCPLIB_H */
// SPDX-License-Identifier: GPL-2.0
/*
* ncpsign_kernel.c
*
* Arne de Bruijn (arne@knoware.nl), 1997
*
*/
#ifdef CONFIG_NCPFS_PACKET_SIGNING
#include <linux/string.h>
#include <linux/ncp.h>
#include <linux/bitops.h>
#include "ncp_fs.h"
#include "ncpsign_kernel.h"
/* i386: 32-bit, little endian, handles mis-alignment */
#ifdef __i386__
#define GET_LE32(p) (*(const int *)(p))
#define PUT_LE32(p,v) { *(int *)(p)=v; }
#else
/* from include/ncplib.h */
#define BVAL(buf,pos) (((const __u8 *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
#define BSET(buf,pos,val) (((__u8 *)(buf))[pos] = (val))
static inline __u16
WVAL_LH(const __u8 * buf, int pos)
{
return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8;
}
static inline __u32
DVAL_LH(const __u8 * buf, int pos)
{
return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16;
}
static inline void
WSET_LH(__u8 * buf, int pos, __u16 val)
{
BSET(buf, pos, val & 0xff);
BSET(buf, pos + 1, val >> 8);
}
static inline void
DSET_LH(__u8 * buf, int pos, __u32 val)
{
WSET_LH(buf, pos, val & 0xffff);
WSET_LH(buf, pos + 2, val >> 16);
}
#define GET_LE32(p) DVAL_LH(p,0)
#define PUT_LE32(p,v) DSET_LH(p,0,v)
#endif
static void nwsign(char *r_data1, char *r_data2, char *outdata) {
int i;
unsigned int w0,w1,w2,w3;
static int rbit[4]={0, 2, 1, 3};
#ifdef __i386__
unsigned int *data2=(unsigned int *)r_data2;
#else
unsigned int data2[16];
for (i=0;i<16;i++)
data2[i]=GET_LE32(r_data2+(i<<2));
#endif
w0=GET_LE32(r_data1);
w1=GET_LE32(r_data1+4);
w2=GET_LE32(r_data1+8);
w3=GET_LE32(r_data1+12);
for (i=0;i<16;i+=4) {
w0=rol32(w0 + ((w1 & w2) | ((~w1) & w3)) + data2[i+0],3);
w3=rol32(w3 + ((w0 & w1) | ((~w0) & w2)) + data2[i+1],7);
w2=rol32(w2 + ((w3 & w0) | ((~w3) & w1)) + data2[i+2],11);
w1=rol32(w1 + ((w2 & w3) | ((~w2) & w0)) + data2[i+3],19);
}
for (i=0;i<4;i++) {
w0=rol32(w0 + (((w2 | w3) & w1) | (w2 & w3)) + 0x5a827999 + data2[i+0],3);
w3=rol32(w3 + (((w1 | w2) & w0) | (w1 & w2)) + 0x5a827999 + data2[i+4],5);
w2=rol32(w2 + (((w0 | w1) & w3) | (w0 & w1)) + 0x5a827999 + data2[i+8],9);
w1=rol32(w1 + (((w3 | w0) & w2) | (w3 & w0)) + 0x5a827999 + data2[i+12],13);
}
for (i=0;i<4;i++) {
w0=rol32(w0 + ((w1 ^ w2) ^ w3) + 0x6ed9eba1 + data2[rbit[i]+0],3);
w3=rol32(w3 + ((w0 ^ w1) ^ w2) + 0x6ed9eba1 + data2[rbit[i]+8],9);
w2=rol32(w2 + ((w3 ^ w0) ^ w1) + 0x6ed9eba1 + data2[rbit[i]+4],11);
w1=rol32(w1 + ((w2 ^ w3) ^ w0) + 0x6ed9eba1 + data2[rbit[i]+12],15);
}
PUT_LE32(outdata,(w0+GET_LE32(r_data1)) & 0xffffffff);
PUT_LE32(outdata+4,(w1+GET_LE32(r_data1+4)) & 0xffffffff);
PUT_LE32(outdata+8,(w2+GET_LE32(r_data1+8)) & 0xffffffff);
PUT_LE32(outdata+12,(w3+GET_LE32(r_data1+12)) & 0xffffffff);
}
/* Make a signature for the current packet and add it at the end of the */
/* packet. */
void __sign_packet(struct ncp_server *server, const char *packet, size_t size, __u32 totalsize, void *sign_buff) {
unsigned char data[64];
memcpy(data, server->sign_root, 8);
*(__u32*)(data + 8) = totalsize;
if (size < 52) {
memcpy(data + 12, packet, size);
memset(data + 12 + size, 0, 52 - size);
} else {
memcpy(data + 12, packet, 52);
}
nwsign(server->sign_last, data, server->sign_last);
memcpy(sign_buff, server->sign_last, 8);
}
int sign_verify_reply(struct ncp_server *server, const char *packet, size_t size, __u32 totalsize, const void *sign_buff) {
unsigned char data[64];
unsigned char hash[16];
memcpy(data, server->sign_root, 8);
*(__u32*)(data + 8) = totalsize;
if (size < 52) {
memcpy(data + 12, packet, size);
memset(data + 12 + size, 0, 52 - size);
} else {
memcpy(data + 12, packet, 52);
}
nwsign(server->sign_last, data, hash);
return memcmp(sign_buff, hash, 8);
}
#endif /* CONFIG_NCPFS_PACKET_SIGNING */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* ncpsign_kernel.h
*
* Arne de Bruijn (arne@knoware.nl), 1997
*
*/
#ifndef _NCPSIGN_KERNEL_H
#define _NCPSIGN_KERNEL_H
#ifdef CONFIG_NCPFS_PACKET_SIGNING
void __sign_packet(struct ncp_server *server, const char *data, size_t size, __u32 totalsize, void *sign_buff);
int sign_verify_reply(struct ncp_server *server, const char *data, size_t size, __u32 totalsize, const void *sign_buff);
#endif
static inline size_t sign_packet(struct ncp_server *server, const char *data, size_t size, __u32 totalsize, void *sign_buff) {
#ifdef CONFIG_NCPFS_PACKET_SIGNING
if (server->sign_active) {
__sign_packet(server, data, size, totalsize, sign_buff);
return 8;
}
#endif
return 0;
}
#endif
此差异已折叠。
// SPDX-License-Identifier: GPL-2.0
/*
* linux/fs/ncpfs/symlink.c
*
* Code for allowing symbolic links on NCPFS (i.e. NetWare)
* Symbolic links are not supported on native NetWare, so we use an
* infrequently-used flag (Sh) and store a two-word magic header in
* the file to make sure we don't accidentally use a non-link file
* as a link.
*
* When using the NFS namespace, we set the mode to indicate a symlink and
* don't bother with the magic numbers.
*
* from linux/fs/ext2/symlink.c
*
* Copyright (C) 1998-99, Frank A. Vorstenbosch
*
* ncpfs symlink handling code
* NLS support (c) 1999 Petr Vandrovec
* Modified 2000 Ben Harris, University of Cambridge for NFS NS meta-info
*
*/
#include <linux/uaccess.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/stat.h>
#include "ncp_fs.h"
/* these magic numbers must appear in the symlink file -- this makes it a bit
more resilient against the magic attributes being set on random files. */
#define NCP_SYMLINK_MAGIC0 cpu_to_le32(0x6c6d7973) /* "symlnk->" */
#define NCP_SYMLINK_MAGIC1 cpu_to_le32(0x3e2d6b6e)
/* ----- read a symbolic link ------------------------------------------ */
static int ncp_symlink_readpage(struct file *file, struct page *page)
{
struct inode *inode = page->mapping->host;
int error, length, len;
char *link, *rawlink;
char *buf = kmap(page);
error = -ENOMEM;
rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
if (!rawlink)
goto fail;
if (ncp_make_open(inode,O_RDONLY))
goto failEIO;
error=ncp_read_kernel(NCP_SERVER(inode),NCP_FINFO(inode)->file_handle,
0,NCP_MAX_SYMLINK_SIZE,rawlink,&length);
ncp_inode_close(inode);
/* Close file handle if no other users... */
ncp_make_closed(inode);
if (error)
goto failEIO;
if (NCP_FINFO(inode)->flags & NCPI_KLUDGE_SYMLINK) {
if (length<NCP_MIN_SYMLINK_SIZE ||
((__le32 *)rawlink)[0]!=NCP_SYMLINK_MAGIC0 ||
((__le32 *)rawlink)[1]!=NCP_SYMLINK_MAGIC1)
goto failEIO;
link = rawlink + 8;
length -= 8;
} else {
link = rawlink;
}
len = NCP_MAX_SYMLINK_SIZE;
error = ncp_vol2io(NCP_SERVER(inode), buf, &len, link, length, 0);
kfree(rawlink);
if (error)
goto fail;
SetPageUptodate(page);
kunmap(page);
unlock_page(page);
return 0;
failEIO:
error = -EIO;
kfree(rawlink);
fail:
SetPageError(page);
kunmap(page);
unlock_page(page);
return error;
}
/*
* symlinks can't do much...
*/
const struct address_space_operations ncp_symlink_aops = {
.readpage = ncp_symlink_readpage,
};
/* ----- create a new symbolic link -------------------------------------- */
int ncp_symlink(struct inode *dir, struct dentry *dentry, const char *symname) {
struct inode *inode;
char *rawlink;
int length, err, i, outlen;
int kludge;
umode_t mode;
__le32 attr;
unsigned int hdr;
ncp_dbg(1, "dir=%p, dentry=%p, symname=%s\n", dir, dentry, symname);
if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber))
kludge = 0;
else
#ifdef CONFIG_NCPFS_EXTRAS
if (NCP_SERVER(dir)->m.flags & NCP_MOUNT_SYMLINKS)
kludge = 1;
else
#endif
/* EPERM is returned by VFS if symlink procedure does not exist */
return -EPERM;
rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
if (!rawlink)
return -ENOMEM;
if (kludge) {
mode = 0;
attr = aSHARED | aHIDDEN;
((__le32 *)rawlink)[0]=NCP_SYMLINK_MAGIC0;
((__le32 *)rawlink)[1]=NCP_SYMLINK_MAGIC1;
hdr = 8;
} else {
mode = S_IFLNK | S_IRWXUGO;
attr = 0;
hdr = 0;
}
length = strlen(symname);
/* map to/from server charset, do not touch upper/lower case as
symlink can point out of ncp filesystem */
outlen = NCP_MAX_SYMLINK_SIZE - hdr;
err = ncp_io2vol(NCP_SERVER(dir), rawlink + hdr, &outlen, symname, length, 0);
if (err)
goto failfree;
outlen += hdr;
err = -EIO;
if (ncp_create_new(dir,dentry,mode,0,attr)) {
goto failfree;
}
inode=d_inode(dentry);
if (ncp_make_open(inode, O_WRONLY))
goto failfree;
if (ncp_write_kernel(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle,
0, outlen, rawlink, &i) || i!=outlen) {
goto fail;
}
ncp_inode_close(inode);
ncp_make_closed(inode);
kfree(rawlink);
return 0;
fail:;
ncp_inode_close(inode);
ncp_make_closed(inode);
failfree:;
kfree(rawlink);
return err;
}
/* ----- EOF ----- */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册