summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-02-01 09:51:57 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-01 09:51:57 -0800
commit5d8515bc232172963a4cef007e97b08c5e4d0533 (patch)
tree13e774dbe2d663ca1fbf2a77933ef8deabd4d507 /fs
parentdb5933225f2fe50d3b91ebbba73ed9c3b703b99a (diff)
parent3384e01179eff2b2fe91ba7bcad98ee2be5f87f7 (diff)
Merge tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO updates from Greg KH: "Here is the big Staging and IIO driver patches for 4.16-rc1. There is the normal amount of new IIO drivers added, like all releases. The networking IPX and the ncpfs filesystem are moved into the staging tree, as they are on their way out of the kernel due to lack of use anymore. The visorbus subsystem finall has started moving out of the staging tree to the "real" part of the kernel, and the most and fsl-mc codebases are almost ready to move out, that will probably happen for 4.17-rc1 if all goes well. Other than that, there is a bunch of license header cleanups in the tree, along with the normal amount of coding style churn that we all know and love for this codebase. I also got frustrated at the Meltdown/Spectre mess and took it out on the dgnc tty driver, deleting huge chunks of it that were never even being used. Full details of everything is in the shortlog. All of these patches have been in linux-next for a while with no reported issues" * tag 'staging-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (627 commits) staging: rtlwifi: remove redundant initialization of 'cfg_cmd' staging: rtl8723bs: remove a couple of redundant initializations staging: comedi: reformat lines to 80 chars or less staging: lustre: separate a connection destroy from free struct kib_conn Staging: rtl8723bs: Use !x instead of NULL comparison Staging: rtl8723bs: Remove dead code Staging: rtl8723bs: Change names to conform to the kernel code staging: ccree: Fix missing blank line after declaration staging: rtl8188eu: remove redundant initialization of 'pwrcfgcmd' staging: rtlwifi: remove unused RTLHALMAC_ST and RTLPHYDM_ST staging: fbtft: remove unused FB_TFT_SSD1325 kconfig staging: comedi: dt2811: remove redundant initialization of 'ns' staging: wilc1000: fix alignments to match open parenthesis staging: wilc1000: removed unnecessary defined enums typedef staging: wilc1000: remove unnecessary use of parentheses staging: rtl8192u: remove redundant initialization of 'timeout' staging: sm750fb: fix CamelCase for dispSet var staging: lustre: lnet/selftest: fix compile error on UP build staging: rtl8723bs: hal_com_phycfg: Remove unneeded semicolons staging: rts5208: Fix "seg_no" calculation in reset_ms_card() ...
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig1
-rw-r--r--fs/Makefile1
-rw-r--r--fs/ncpfs/Kconfig108
-rw-r--r--fs/ncpfs/Makefile17
-rw-r--r--fs/ncpfs/dir.c1232
-rw-r--r--fs/ncpfs/file.c263
-rw-r--r--fs/ncpfs/getopt.c76
-rw-r--r--fs/ncpfs/getopt.h17
-rw-r--r--fs/ncpfs/inode.c1066
-rw-r--r--fs/ncpfs/ioctl.c923
-rw-r--r--fs/ncpfs/mmap.c125
-rw-r--r--fs/ncpfs/ncp_fs.h101
-rw-r--r--fs/ncpfs/ncp_fs_i.h31
-rw-r--r--fs/ncpfs/ncp_fs_sb.h174
-rw-r--r--fs/ncpfs/ncplib_kernel.c1322
-rw-r--r--fs/ncpfs/ncplib_kernel.h215
-rw-r--r--fs/ncpfs/ncpsign_kernel.c128
-rw-r--r--fs/ncpfs/ncpsign_kernel.h27
-rw-r--r--fs/ncpfs/sock.c855
-rw-r--r--fs/ncpfs/symlink.c182
20 files changed, 0 insertions, 6864 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index 0ed56752f208..9774588da60e 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -294,7 +294,6 @@ config NFS_COMMON
source "net/sunrpc/Kconfig"
source "fs/ceph/Kconfig"
source "fs/cifs/Kconfig"
-source "fs/ncpfs/Kconfig"
source "fs/coda/Kconfig"
source "fs/afs/Kconfig"
source "fs/9p/Kconfig"
diff --git a/fs/Makefile b/fs/Makefile
index ef772f1eaff8..add789ea270a 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -92,7 +92,6 @@ obj-$(CONFIG_LOCKD) += lockd/
obj-$(CONFIG_NLS) += nls/
obj-$(CONFIG_SYSV_FS) += sysv/
obj-$(CONFIG_CIFS) += cifs/
-obj-$(CONFIG_NCP_FS) += ncpfs/
obj-$(CONFIG_HPFS_FS) += hpfs/
obj-$(CONFIG_NTFS_FS) += ntfs/
obj-$(CONFIG_UFS_FS) += ufs/
diff --git a/fs/ncpfs/Kconfig b/fs/ncpfs/Kconfig
deleted file mode 100644
index c931cf22a1f6..000000000000
--- a/fs/ncpfs/Kconfig
+++ /dev/null
@@ -1,108 +0,0 @@
-#
-# 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.
-
diff --git a/fs/ncpfs/Makefile b/fs/ncpfs/Makefile
deleted file mode 100644
index 66fe5f878817..000000000000
--- a/fs/ncpfs/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
deleted file mode 100644
index 0c57c5c5d40a..000000000000
--- a/fs/ncpfs/dir.c
+++ /dev/null
@@ -1,1232 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * dir.c
- *
- * 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
- * Modified 2000 Ben Harris, University of Cambridge for NFS NS meta-info
- *
- */
-
-
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <linux/stat.h>
-#include <linux/kernel.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <linux/namei.h>
-#include <linux/uaccess.h>
-#include <asm/byteorder.h>
-
-#include "ncp_fs.h"
-
-static void ncp_read_volume_list(struct file *, struct dir_context *,
- struct ncp_cache_control *);
-static void ncp_do_readdir(struct file *, struct dir_context *,
- struct ncp_cache_control *);
-
-static int ncp_readdir(struct file *, struct dir_context *);
-
-static int ncp_create(struct inode *, struct dentry *, umode_t, bool);
-static struct dentry *ncp_lookup(struct inode *, struct dentry *, unsigned int);
-static int ncp_unlink(struct inode *, struct dentry *);
-static int ncp_mkdir(struct inode *, struct dentry *, umode_t);
-static int ncp_rmdir(struct inode *, struct dentry *);
-static int ncp_rename(struct inode *, struct dentry *,
- struct inode *, struct dentry *, unsigned int);
-static int ncp_mknod(struct inode * dir, struct dentry *dentry,
- umode_t mode, dev_t rdev);
-#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
-extern int ncp_symlink(struct inode *, struct dentry *, const char *);
-#else
-#define ncp_symlink NULL
-#endif
-
-const struct file_operations ncp_dir_operations =
-{
- .llseek = generic_file_llseek,
- .read = generic_read_dir,
- .iterate = ncp_readdir,
- .unlocked_ioctl = ncp_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = ncp_compat_ioctl,
-#endif
-};
-
-const struct inode_operations ncp_dir_inode_operations =
-{
- .create = ncp_create,
- .lookup = ncp_lookup,
- .unlink = ncp_unlink,
- .symlink = ncp_symlink,
- .mkdir = ncp_mkdir,
- .rmdir = ncp_rmdir,
- .mknod = ncp_mknod,
- .rename = ncp_rename,
- .setattr = ncp_notify_change,
-};
-
-/*
- * Dentry operations routines
- */
-static int ncp_lookup_validate(struct dentry *, unsigned int);
-static int ncp_hash_dentry(const struct dentry *, struct qstr *);
-static int ncp_compare_dentry(const struct dentry *,
- unsigned int, const char *, const struct qstr *);
-static int ncp_delete_dentry(const struct dentry *);
-static void ncp_d_prune(struct dentry *dentry);
-
-const struct dentry_operations ncp_dentry_operations =
-{
- .d_revalidate = ncp_lookup_validate,
- .d_hash = ncp_hash_dentry,
- .d_compare = ncp_compare_dentry,
- .d_delete = ncp_delete_dentry,
- .d_prune = ncp_d_prune,
-};
-
-#define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber])
-
-static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator)
-{
-#ifdef CONFIG_NCPFS_SMALLDOS
- int ns = ncp_namespace(i);
-
- if ((ns == NW_NS_DOS)
-#ifdef CONFIG_NCPFS_OS2_NS
- || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
-#endif /* CONFIG_NCPFS_OS2_NS */
- )
- return 0;
-#endif /* CONFIG_NCPFS_SMALLDOS */
- return 1;
-}
-
-#define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS)
-
-static inline int ncp_case_sensitive(const struct inode *i)
-{
-#ifdef CONFIG_NCPFS_NFS_NS
- return ncp_namespace(i) == NW_NS_NFS;
-#else
- return 0;
-#endif /* CONFIG_NCPFS_NFS_NS */
-}
-
-/*
- * Note: leave the hash unchanged if the directory
- * is case-sensitive.
- */
-static int
-ncp_hash_dentry(const struct dentry *dentry, struct qstr *this)
-{
- struct inode *inode = d_inode_rcu(dentry);
-
- if (!inode)
- return 0;
-
- if (!ncp_case_sensitive(inode)) {
- struct nls_table *t;
- unsigned long hash;
- int i;
-
- t = NCP_IO_TABLE(dentry->d_sb);
- hash = init_name_hash(dentry);
- for (i=0; i<this->len ; i++)
- hash = partial_name_hash(ncp_tolower(t, this->name[i]),
- hash);
- this->hash = end_name_hash(hash);
- }
- return 0;
-}
-
-static int
-ncp_compare_dentry(const struct dentry *dentry,
- unsigned int len, const char *str, const struct qstr *name)
-{
- struct inode *pinode;
-
- if (len != name->len)
- return 1;
-
- pinode = d_inode_rcu(dentry->d_parent);
- if (!pinode)
- return 1;
-
- if (ncp_case_sensitive(pinode))
- return strncmp(str, name->name, len);
-
- return ncp_strnicmp(NCP_IO_TABLE(pinode->i_sb), str, name->name, len);
-}
-
-/*
- * This is the callback from dput() when d_count is going to 0.
- * We use this to unhash dentries with bad inodes.
- * Closing files can be safely postponed until iput() - it's done there anyway.
- */
-static int
-ncp_delete_dentry(const struct dentry * dentry)
-{
- struct inode *inode = d_inode(dentry);
-
- if (inode) {
- if (is_bad_inode(inode))
- return 1;
- } else
- {
- /* N.B. Unhash negative dentries? */
- }
- return 0;
-}
-
-static inline int
-ncp_single_volume(struct ncp_server *server)
-{
- return (server->m.mounted_vol[0] != '\0');
-}
-
-static inline int ncp_is_server_root(struct inode *inode)
-{
- return !ncp_single_volume(NCP_SERVER(inode)) &&
- is_root_inode(inode);
-}
-
-
-/*
- * This is the callback when the dcache has a lookup hit.
- */
-
-
-#ifdef CONFIG_NCPFS_STRONG
-/* try to delete a readonly file (NW R bit set) */
-
-static int
-ncp_force_unlink(struct inode *dir, struct dentry* dentry)
-{
- int res=0x9c,res2;
- struct nw_modify_dos_info info;
- __le32 old_nwattr;
- struct inode *inode;
-
- memset(&info, 0, sizeof(info));
-
- /* remove the Read-Only flag on the NW server */
- inode = d_inode(dentry);
-
- old_nwattr = NCP_FINFO(inode)->nwattr;
- info.attributes = old_nwattr & ~(aRONLY|aDELETEINHIBIT|aRENAMEINHIBIT);
- res2 = ncp_modify_file_or_subdir_dos_info_path(NCP_SERVER(inode), inode, NULL, DM_ATTRIBUTES, &info);
- if (res2)
- goto leave_me;
-
- /* now try again the delete operation */
- res = ncp_del_file_or_subdir2(NCP_SERVER(dir), dentry);
-
- if (res) /* delete failed, set R bit again */
- {
- info.attributes = old_nwattr;
- res2 = ncp_modify_file_or_subdir_dos_info_path(NCP_SERVER(inode), inode, NULL, DM_ATTRIBUTES, &info);
- if (res2)
- goto leave_me;
- }
-leave_me:
- return(res);
-}
-#endif /* CONFIG_NCPFS_STRONG */
-
-#ifdef CONFIG_NCPFS_STRONG
-static int
-ncp_force_rename(struct inode *old_dir, struct dentry* old_dentry, char *_old_name,
- struct inode *new_dir, struct dentry* new_dentry, char *_new_name)
-{
- struct nw_modify_dos_info info;
- int res=0x90,res2;
- struct inode *old_inode = d_inode(old_dentry);
- __le32 old_nwattr = NCP_FINFO(old_inode)->nwattr;
- __le32 new_nwattr = 0; /* shut compiler warning */
- int old_nwattr_changed = 0;
- int new_nwattr_changed = 0;
-
- memset(&info, 0, sizeof(info));
-
- /* remove the Read-Only flag on the NW server */
-
- info.attributes = old_nwattr & ~(aRONLY|aRENAMEINHIBIT|aDELETEINHIBIT);
- res2 = ncp_modify_file_or_subdir_dos_info_path(NCP_SERVER(old_inode), old_inode, NULL, DM_ATTRIBUTES, &info);
- if (!res2)
- old_nwattr_changed = 1;
- if (new_dentry && d_really_is_positive(new_dentry)) {
- new_nwattr = NCP_FINFO(d_inode(new_dentry))->nwattr;
- info.attributes = new_nwattr & ~(aRONLY|aRENAMEINHIBIT|aDELETEINHIBIT);
- res2 = ncp_modify_file_or_subdir_dos_info_path(NCP_SERVER(new_dir), new_dir, _new_name, DM_ATTRIBUTES, &info);
- if (!res2)
- new_nwattr_changed = 1;
- }
- /* now try again the rename operation */
- /* but only if something really happened */
- if (new_nwattr_changed || old_nwattr_changed) {
- res = ncp_ren_or_mov_file_or_subdir(NCP_SERVER(old_dir),
- old_dir, _old_name,
- new_dir, _new_name);
- }
- if (res)
- goto leave_me;
- /* file was successfully renamed, so:
- do not set attributes on old file - it no longer exists
- copy attributes from old file to new */
- new_nwattr_changed = old_nwattr_changed;
- new_nwattr = old_nwattr;
- old_nwattr_changed = 0;
-
-leave_me:;
- if (old_nwattr_changed) {
- info.attributes = old_nwattr;
- res2 = ncp_modify_file_or_subdir_dos_info_path(NCP_SERVER(old_inode), old_inode, NULL, DM_ATTRIBUTES, &info);
- /* ignore errors */
- }
- if (new_nwattr_changed) {
- info.attributes = new_nwattr;
- res2 = ncp_modify_file_or_subdir_dos_info_path(NCP_SERVER(new_dir), new_dir, _new_name, DM_ATTRIBUTES, &info);
- /* ignore errors */
- }
- return(res);
-}
-#endif /* CONFIG_NCPFS_STRONG */
-
-
-static int
-ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
-{
- struct ncp_server *server;
- struct dentry *parent;
- struct inode *dir;
- struct ncp_entry_info finfo;
- int res, val = 0, len;
- __u8 __name[NCP_MAXPATHLEN + 1];
-
- if (dentry == dentry->d_sb->s_root)
- return 1;
-
- if (flags & LOOKUP_RCU)
- return -ECHILD;
-
- parent = dget_parent(dentry);
- dir = d_inode(parent);
-
- if (d_really_is_negative(dentry))
- goto finished;
-
- server = NCP_SERVER(dir);
-
- /*
- * Inspired by smbfs:
- * The default validation is based on dentry age:
- * We set the max age at mount time. (But each
- * successful server lookup renews the timestamp.)
- */
- val = NCP_TEST_AGE(server, dentry);
- if (val)
- goto finished;
-
- ncp_dbg(2, "%pd2 not valid, age=%ld, server lookup\n",
- dentry, NCP_GET_AGE(dentry));
-
- len = sizeof(__name);
- if (ncp_is_server_root(dir)) {
- res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
- dentry->d_name.len, 1);
- if (!res) {
- res = ncp_lookup_volume(server, __name, &(finfo.i));
- if (!res)
- ncp_update_known_namespace(server, finfo.i.volNumber, NULL);
- }
- } else {
- res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
- dentry->d_name.len, !ncp_preserve_case(dir));
- if (!res)
- res = ncp_obtain_info(server, dir, __name, &(finfo.i));
- }
- finfo.volume = finfo.i.volNumber;
- ncp_dbg(2, "looked for %pd/%s, res=%d\n",
- dentry->d_parent, __name, res);
- /*
- * If we didn't find it, or if it has a different dirEntNum to
- * what we remember, it's not valid any more.
- */
- if (!res) {
- struct inode *inode = d_inode(dentry);
-
- inode_lock(inode);
- if (finfo.i.dirEntNum == NCP_FINFO(inode)->dirEntNum) {
- ncp_new_dentry(dentry);
- val=1;
- } else
- ncp_dbg(2, "found, but dirEntNum changed\n");
-
- ncp_update_inode2(inode, &finfo);
- inode_unlock(inode);
- }
-
-finished:
- ncp_dbg(2, "result=%d\n", val);
- dput(parent);
- return val;
-}
-
-static time_t ncp_obtain_mtime(struct dentry *dentry)
-{
- struct inode *inode = d_inode(dentry);
- struct ncp_server *server = NCP_SERVER(inode);
- struct nw_info_struct i;
-
- if (!ncp_conn_valid(server) || ncp_is_server_root(inode))
- return 0;
-
- if (ncp_obtain_info(server, inode, NULL, &i))
- return 0;
-
- return ncp_date_dos2unix(i.modifyTime, i.modifyDate);
-}
-
-static inline void
-ncp_invalidate_dircache_entries(struct dentry *parent)
-{
- struct ncp_server *server = NCP_SERVER(d_inode(parent));
- struct dentry *dentry;
-
- spin_lock(&parent->d_lock);
- list_for_each_entry(dentry, &parent->d_subdirs, d_child) {
- dentry->d_fsdata = NULL;
- ncp_age_dentry(server, dentry);
- }
- spin_unlock(&parent->d_lock);
-}
-
-static int ncp_readdir(struct file *file, struct dir_context *ctx)
-{
- struct dentry *dentry = file->f_path.dentry;
- struct inode *inode = d_inode(dentry);
- struct page *page = NULL;
- struct ncp_server *server = NCP_SERVER(inode);
- union ncp_dir_cache *cache = NULL;
- struct ncp_cache_control ctl;
- int result, mtime_valid = 0;
- time_t mtime = 0;
-
- ctl.page = NULL;
- ctl.cache = NULL;
-
- ncp_dbg(2, "reading %pD2, pos=%d\n", file, (int)ctx->pos);
-
- result = -EIO;
- /* Do not generate '.' and '..' when server is dead. */
- if (!ncp_conn_valid(server))
- goto out;
-
- result = 0;
- if (!dir_emit_dots(file, ctx))
- goto out;
-
- page = grab_cache_page(&inode->i_data, 0);
- if (!page)
- goto read_really;
-
- ctl.cache = cache = kmap(page);
- ctl.head = cache->head;
-
- if (!PageUptodate(page) || !ctl.head.eof)
- goto init_cache;
-
- if (ctx->pos == 2) {
- if (jiffies - ctl.head.time >= NCP_MAX_AGE(server))
- goto init_cache;
-
- mtime = ncp_obtain_mtime(dentry);
- mtime_valid = 1;
- if ((!mtime) || (mtime != ctl.head.mtime))
- goto init_cache;
- }
-
- if (ctx->pos > ctl.head.end)
- goto finished;
-
- ctl.fpos = ctx->pos + (NCP_DIRCACHE_START - 2);
- ctl.ofs = ctl.fpos / NCP_DIRCACHE_SIZE;
- ctl.idx = ctl.fpos % NCP_DIRCACHE_SIZE;
-
- for (;;) {
- if (ctl.ofs != 0) {
- ctl.page = find_lock_page(&inode->i_data, ctl.ofs);
- if (!ctl.page)
- goto invalid_cache;
- ctl.cache = kmap(ctl.page);
- if (!PageUptodate(ctl.page))
- goto invalid_cache;
- }
- while (ctl.idx < NCP_DIRCACHE_SIZE) {
- struct dentry *dent;
- bool over;
-
- spin_lock(&dentry->d_lock);
- if (!(NCP_FINFO(inode)->flags & NCPI_DIR_CACHE)) {
- spin_unlock(&dentry->d_lock);
- goto invalid_cache;
- }
- dent = ctl.cache->dentry[ctl.idx];
- if (unlikely(!lockref_get_not_dead(&dent->d_lockref))) {
- spin_unlock(&dentry->d_lock);
- goto invalid_cache;
- }
- spin_unlock(&dentry->d_lock);
- if (d_really_is_negative(dent)) {
- dput(dent);
- goto invalid_cache;
- }
- over = !dir_emit(ctx, dent->d_name.name,
- dent->d_name.len,
- d_inode(dent)->i_ino, DT_UNKNOWN);
- dput(dent);
- if (over)
- goto finished;
- ctx->pos += 1;
- ctl.idx += 1;
- if (ctx->pos > ctl.head.end)
- goto finished;
- }
- if (ctl.page) {
- kunmap(ctl.page);
- SetPageUptodate(ctl.page);
- unlock_page(ctl.page);
- put_page(ctl.page);
- ctl.page = NULL;
- }
- ctl.idx = 0;
- ctl.ofs += 1;
- }
-invalid_cache:
- if (ctl.page) {
- kunmap(ctl.page);
- unlock_page(ctl.page);
- put_page(ctl.page);
- ctl.page = NULL;
- }
- ctl.cache = cache;
-init_cache:
- ncp_invalidate_dircache_entries(dentry);
- if (!mtime_valid) {
- mtime = ncp_obtain_mtime(dentry);
- mtime_valid = 1;
- }
- ctl.head.mtime = mtime;
- ctl.head.time = jiffies;
- ctl.head.eof = 0;
- ctl.fpos = 2;
- ctl.ofs = 0;
- ctl.idx = NCP_DIRCACHE_START;
- ctl.filled = 0;
- ctl.valid = 1;
-read_really:
- spin_lock(&dentry->d_lock);
- NCP_FINFO(inode)->flags |= NCPI_DIR_CACHE;
- spin_unlock(&dentry->d_lock);
- if (ncp_is_server_root(inode)) {
- ncp_read_volume_list(file, ctx, &ctl);
- } else {
- ncp_do_readdir(file, ctx, &ctl);
- }
- ctl.head.end = ctl.fpos - 1;
- ctl.head.eof = ctl.valid;
-finished:
- if (ctl.page) {
- kunmap(ctl.page);
- SetPageUptodate(ctl.page);
- unlock_page(ctl.page);
- put_page(ctl.page);
- }
- if (page) {
- cache->head = ctl.head;
- kunmap(page);
- SetPageUptodate(page);
- unlock_page(page);
- put_page(page);
- }
-out:
- return result;
-}
-
-static void ncp_d_prune(struct dentry *dentry)
-{
- if (!dentry->d_fsdata) /* not referenced from page cache */
- return;
- NCP_FINFO(d_inode(dentry->d_parent))->flags &= ~NCPI_DIR_CACHE;
-}
-
-static int
-ncp_fill_cache(struct file *file, struct dir_context *ctx,
- struct ncp_cache_control *ctrl, struct ncp_entry_info *entry,
- int inval_childs)
-{
- struct dentry *newdent, *dentry = file->f_path.dentry;
- struct inode *dir = d_inode(dentry);
- struct ncp_cache_control ctl = *ctrl;
- struct qstr qname;
- int valid = 0;
- int hashed = 0;
- ino_t ino = 0;
- __u8 __name[NCP_MAXPATHLEN + 1];
-
- qname.len = sizeof(__name);
- if (ncp_vol2io(NCP_SERVER(dir), __name, &qname.len,
- entry->i.entryName, entry->i.nameLen,
- !ncp_preserve_entry_case(dir, entry->i.NSCreator)))
- return 1; /* I'm not sure */
-
- qname.name = __name;
-
- newdent = d_hash_and_lookup(dentry, &qname);
- if (IS_ERR(newdent))
- goto end_advance;
- if (!newdent) {
- newdent = d_alloc(dentry, &qname);
- if (!newdent)
- goto end_advance;
- } else {
- hashed = 1;
-
- /* If case sensitivity changed for this volume, all entries below this one
- should be thrown away. This entry itself is not affected, as its case
- sensitivity is controlled by its own parent. */
- if (inval_childs)
- shrink_dcache_parent(newdent);
-
- /*
- * NetWare's OS2 namespace is case preserving yet case
- * insensitive. So we update dentry's name as received from
- * server. Parent dir's i_mutex is locked because we're in
- * readdir.
- */
- dentry_update_name_case(newdent, &qname);
- }
-
- if (d_really_is_negative(newdent)) {
- struct inode *inode;
-
- entry->opened = 0;
- entry->ino = iunique(dir->i_sb, 2);
- inode = ncp_iget(dir->i_sb, entry);
- if (inode) {
- d_instantiate(newdent, inode);
- if (!hashed)
- d_rehash(newdent);
- } else {
- spin_lock(&dentry->d_lock);
- NCP_FINFO(dir)->flags &= ~NCPI_DIR_CACHE;
- spin_unlock(&dentry->d_lock);
- }
- } else {
- struct inode *inode = d_inode(newdent);
-
- inode_lock_nested(inode, I_MUTEX_CHILD);
- ncp_update_inode2(inode, entry);
- inode_unlock(inode);
- }
-
- if (ctl.idx >= NCP_DIRCACHE_SIZE) {
- if (ctl.page) {
- kunmap(ctl.page);
- SetPageUptodate(ctl.page);
- unlock_page(ctl.page);
- put_page(ctl.page);
- }
- ctl.cache = NULL;
- ctl.idx -= NCP_DIRCACHE_SIZE;
- ctl.ofs += 1;
- ctl.page = grab_cache_page(&dir->i_data, ctl.ofs);
- if (ctl.page)
- ctl.cache = kmap(ctl.page);
- }
- if (ctl.cache) {
- if (d_really_is_positive(newdent)) {
- newdent->d_fsdata = newdent;
- ctl.cache->dentry[ctl.idx] = newdent;
- ino = d_inode(newdent)->i_ino;
- ncp_new_dentry(newdent);
- }
- valid = 1;
- }
- dput(newdent);
-end_advance:
- if (!valid)
- ctl.valid = 0;
- if (!ctl.filled && (ctl.fpos == ctx->pos)) {
- if (!ino)
- ino = iunique(dir->i_sb, 2);
- ctl.filled = !dir_emit(ctx, qname.name, qname.len,
- ino, DT_UNKNOWN);
- if (!ctl.filled)
- ctx->pos += 1;
- }
- ctl.fpos += 1;
- ctl.idx += 1;
- *ctrl = ctl;
- return (ctl.valid || !ctl.filled);
-}
-
-static void
-ncp_read_volume_list(struct file *file, struct dir_context *ctx,
- struct ncp_cache_control *ctl)
-{
- struct inode *inode = file_inode(file);
- struct ncp_server *server = NCP_SERVER(inode);
- struct ncp_volume_info info;
- struct ncp_entry_info entry;
- int i;
-
- ncp_dbg(1, "pos=%ld\n", (unsigned long)ctx->pos);
-
- for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) {
- int inval_dentry;
-
- if (ncp_get_volume_info_with_number(server, i, &info) != 0)
- return;
- if (!strlen(info.volume_name))
- continue;
-
- ncp_dbg(1, "found vol: %s\n", info.volume_name);
-
- if (ncp_lookup_volume(server, info.volume_name,
- &entry.i)) {
- ncp_dbg(1, "could not lookup vol %s\n",
- info.volume_name);
- continue;
- }
- inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL);
- entry.volume = entry.i.volNumber;
- if (!ncp_fill_cache(file, ctx, ctl, &entry, inval_dentry))
- return;
- }
-}
-
-static void
-ncp_do_readdir(struct file *file, struct dir_context *ctx,
- struct ncp_cache_control *ctl)
-{
- struct inode *dir = file_inode(file);
- struct ncp_server *server = NCP_SERVER(dir);
- struct nw_search_sequence seq;
- struct ncp_entry_info entry;
- int err;
- void* buf;
- int more;
- size_t bufsize;
-
- ncp_dbg(1, "%pD2, fpos=%ld\n", file, (unsigned long)ctx->pos);
- ncp_vdbg("init %pD, volnum=%d, dirent=%u\n",
- file, NCP_FINFO(dir)->volNumber, NCP_FINFO(dir)->dirEntNum);
-
- err = ncp_initialize_search(server, dir, &seq);
- if (err) {
- ncp_dbg(1, "init failed, err=%d\n", err);
- return;
- }
- /* We MUST NOT use server->buffer_size handshaked with server if we are
- using UDP, as for UDP server uses max. buffer size determined by
- MTU, and for TCP server uses hardwired value 65KB (== 66560 bytes).
- So we use 128KB, just to be sure, as there is no way how to know
- this value in advance. */
- bufsize = 131072;
- buf = vmalloc(bufsize);
- if (!buf)
- return;
- do {
- int cnt;
- char* rpl;
- size_t rpls;
-
- err = ncp_search_for_fileset(server, &seq, &more, &cnt, buf, bufsize, &rpl, &rpls);
- if (err) /* Error */
- break;
- if (!cnt) /* prevent endless loop */
- break;
- while (cnt--) {
- size_t onerpl;
-
- if (rpls < offsetof(struct nw_info_struct, entryName))
- break; /* short packet */
- ncp_extract_file_info(rpl, &entry.i);
- onerpl = offsetof(struct nw_info_struct, entryName) + entry.i.nameLen;
- if (rpls < onerpl)
- break; /* short packet */
- (void)ncp_obtain_nfs_info(server, &entry.i);
- rpl += onerpl;
- rpls -= onerpl;
- entry.volume = entry.i.volNumber;
- if (!ncp_fill_cache(file, ctx, ctl, &entry, 0))
- break;
- }
- } while (more);
- vfree(buf);