License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* 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>
|
2011-01-07 13:49:57 +07:00
|
|
|
#include <linux/namei.h>
|
2016-12-25 02:46:01 +07:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
2011-01-13 05:37:47 +07:00
|
|
|
#include "ncp_fs.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-05-23 02:11:27 +07:00
|
|
|
static void ncp_read_volume_list(struct file *, struct dir_context *,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ncp_cache_control *);
|
2013-05-23 02:11:27 +07:00
|
|
|
static void ncp_do_readdir(struct file *, struct dir_context *,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ncp_cache_control *);
|
|
|
|
|
2013-05-23 02:11:27 +07:00
|
|
|
static int ncp_readdir(struct file *, struct dir_context *);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-06-11 05:05:36 +07:00
|
|
|
static int ncp_create(struct inode *, struct dentry *, umode_t, bool);
|
2012-06-11 04:13:09 +07:00
|
|
|
static struct dentry *ncp_lookup(struct inode *, struct dentry *, unsigned int);
|
2005-04-17 05:20:36 +07:00
|
|
|
static int ncp_unlink(struct inode *, struct dentry *);
|
2011-07-26 12:41:39 +07:00
|
|
|
static int ncp_mkdir(struct inode *, struct dentry *, umode_t);
|
2005-04-17 05:20:36 +07:00
|
|
|
static int ncp_rmdir(struct inode *, struct dentry *);
|
|
|
|
static int ncp_rename(struct inode *, struct dentry *,
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 16:03:58 +07:00
|
|
|
struct inode *, struct dentry *, unsigned int);
|
2005-04-17 05:20:36 +07:00
|
|
|
static int ncp_mknod(struct inode * dir, struct dentry *dentry,
|
2011-07-26 12:52:52 +07:00
|
|
|
umode_t mode, dev_t rdev);
|
2005-04-17 05:20:36 +07:00
|
|
|
#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
|
|
|
|
|
2006-03-28 16:56:42 +07:00
|
|
|
const struct file_operations ncp_dir_operations =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2010-05-27 04:44:53 +07:00
|
|
|
.llseek = generic_file_llseek,
|
2005-04-17 05:20:36 +07:00
|
|
|
.read = generic_read_dir,
|
2013-05-23 02:11:27 +07:00
|
|
|
.iterate = ncp_readdir,
|
2010-05-05 20:15:37 +07:00
|
|
|
.unlocked_ioctl = ncp_ioctl,
|
2006-10-01 13:27:55 +07:00
|
|
|
#ifdef CONFIG_COMPAT
|
|
|
|
.compat_ioctl = ncp_compat_ioctl,
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2007-02-12 15:55:39 +07:00
|
|
|
const struct inode_operations ncp_dir_inode_operations =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.create = ncp_create,
|
|
|
|
.lookup = ncp_lookup,
|
|
|
|
.unlink = ncp_unlink,
|
|
|
|
.symlink = ncp_symlink,
|
|
|
|
.mkdir = ncp_mkdir,
|
|
|
|
.rmdir = ncp_rmdir,
|
|
|
|
.mknod = ncp_mknod,
|
2016-09-27 16:03:58 +07:00
|
|
|
.rename = ncp_rename,
|
2005-04-17 05:20:36 +07:00
|
|
|
.setattr = ncp_notify_change,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dentry operations routines
|
|
|
|
*/
|
2012-06-11 03:03:43 +07:00
|
|
|
static int ncp_lookup_validate(struct dentry *, unsigned int);
|
2013-05-22 05:22:44 +07:00
|
|
|
static int ncp_hash_dentry(const struct dentry *, struct qstr *);
|
2016-08-01 03:37:25 +07:00
|
|
|
static int ncp_compare_dentry(const struct dentry *,
|
2011-01-07 13:49:27 +07:00
|
|
|
unsigned int, const char *, const struct qstr *);
|
2011-01-07 13:49:23 +07:00
|
|
|
static int ncp_delete_dentry(const struct dentry *);
|
2014-12-25 09:41:47 +07:00
|
|
|
static void ncp_d_prune(struct dentry *dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-01-13 05:25:03 +07:00
|
|
|
const struct dentry_operations ncp_dentry_operations =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.d_revalidate = ncp_lookup_validate,
|
|
|
|
.d_hash = ncp_hash_dentry,
|
|
|
|
.d_compare = ncp_compare_dentry,
|
|
|
|
.d_delete = ncp_delete_dentry,
|
2014-12-25 09:41:47 +07:00
|
|
|
.d_prune = ncp_d_prune,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2010-09-27 06:47:33 +07:00
|
|
|
#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)
|
|
|
|
|
2011-01-07 13:49:27 +07:00
|
|
|
static inline int ncp_case_sensitive(const struct inode *i)
|
2010-09-27 06:47:33 +07:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_NCPFS_NFS_NS
|
2011-01-07 13:49:27 +07:00
|
|
|
return ncp_namespace(i) == NW_NS_NFS;
|
2010-09-27 06:47:33 +07:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif /* CONFIG_NCPFS_NFS_NS */
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Note: leave the hash unchanged if the directory
|
|
|
|
* is case-sensitive.
|
2013-05-22 05:22:44 +07:00
|
|
|
*
|
|
|
|
* Accessing the parent inode can be racy under RCU pathwalking.
|
|
|
|
* Use ACCESS_ONCE() to make sure we use _one_ particular inode,
|
|
|
|
* the callers will handle races.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
static int
|
2013-05-22 05:22:44 +07:00
|
|
|
ncp_hash_dentry(const struct dentry *dentry, struct qstr *this)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode_rcu(dentry);
|
2013-05-22 05:22:44 +07:00
|
|
|
|
|
|
|
if (!inode)
|
|
|
|
return 0;
|
|
|
|
|
2011-01-07 13:49:28 +07:00
|
|
|
if (!ncp_case_sensitive(inode)) {
|
2010-09-27 06:47:33 +07:00
|
|
|
struct nls_table *t;
|
|
|
|
unsigned long hash;
|
|
|
|
int i;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-09-27 16:03:57 +07:00
|
|
|
t = NCP_IO_TABLE(dentry->d_sb);
|
2016-06-10 21:51:30 +07:00
|
|
|
hash = init_name_hash(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-22 05:22:44 +07:00
|
|
|
/*
|
|
|
|
* Accessing the parent inode can be racy under RCU pathwalking.
|
|
|
|
* Use ACCESS_ONCE() to make sure we use _one_ particular inode,
|
|
|
|
* the callers will handle races.
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
static int
|
2016-08-01 03:37:25 +07:00
|
|
|
ncp_compare_dentry(const struct dentry *dentry,
|
2011-01-07 13:49:27 +07:00
|
|
|
unsigned int len, const char *str, const struct qstr *name)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-05-22 05:22:44 +07:00
|
|
|
struct inode *pinode;
|
|
|
|
|
2011-01-07 13:49:27 +07:00
|
|
|
if (len != name->len)
|
2005-04-17 05:20:36 +07:00
|
|
|
return 1;
|
|
|
|
|
2016-08-01 03:37:25 +07:00
|
|
|
pinode = d_inode_rcu(dentry->d_parent);
|
2013-05-22 05:22:44 +07:00
|
|
|
if (!pinode)
|
|
|
|
return 1;
|
|
|
|
|
2011-01-07 13:49:27 +07:00
|
|
|
if (ncp_case_sensitive(pinode))
|
|
|
|
return strncmp(str, name->name, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2011-01-07 13:49:27 +07:00
|
|
|
return ncp_strnicmp(NCP_IO_TABLE(pinode->i_sb), str, name->name, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2011-01-07 13:49:23 +07:00
|
|
|
ncp_delete_dentry(const struct dentry * dentry)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2014-10-22 02:20:42 +07:00
|
|
|
return !ncp_single_volume(NCP_SERVER(inode)) &&
|
|
|
|
is_root_inode(inode);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
2015-03-18 05:25:59 +07:00
|
|
|
inode = d_inode(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
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;
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *old_inode = d_inode(old_dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
__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;
|
2015-03-18 05:25:59 +07:00
|
|
|
if (new_dentry && d_really_is_positive(new_dentry)) {
|
|
|
|
new_nwattr = NCP_FINFO(d_inode(new_dentry))->nwattr;
|
2005-04-17 05:20:36 +07:00
|
|
|
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
|
2012-06-11 03:03:43 +07:00
|
|
|
ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
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];
|
|
|
|
|
2011-01-13 05:25:03 +07:00
|
|
|
if (dentry == dentry->d_sb->s_root)
|
|
|
|
return 1;
|
|
|
|
|
2012-06-11 03:03:43 +07:00
|
|
|
if (flags & LOOKUP_RCU)
|
2011-01-07 13:49:57 +07:00
|
|
|
return -ECHILD;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
parent = dget_parent(dentry);
|
2015-03-18 05:25:59 +07:00
|
|
|
dir = d_inode(parent);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-03-18 05:25:59 +07:00
|
|
|
if (d_really_is_negative(dentry))
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(2, "%pd2 not valid, age=%ld, server lookup\n",
|
2013-09-16 21:59:55 +07:00
|
|
|
dentry, NCP_GET_AGE(dentry));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
len = sizeof(__name);
|
|
|
|
if (ncp_is_server_root(dir)) {
|
|
|
|
res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
|
|
|
|
dentry->d_name.len, 1);
|
2010-09-27 06:47:33 +07:00
|
|
|
if (!res) {
|
2005-04-17 05:20:36 +07:00
|
|
|
res = ncp_lookup_volume(server, __name, &(finfo.i));
|
2010-09-27 06:47:33 +07:00
|
|
|
if (!res)
|
|
|
|
ncp_update_known_namespace(server, finfo.i.volNumber, NULL);
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
} 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;
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(2, "looked for %pd/%s, res=%d\n",
|
2013-09-16 21:59:55 +07:00
|
|
|
dentry->d_parent, __name, res);
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* 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) {
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode(dentry);
|
2010-09-27 06:47:33 +07:00
|
|
|
|
2016-01-23 03:40:57 +07:00
|
|
|
inode_lock(inode);
|
2010-09-27 06:47:33 +07:00
|
|
|
if (finfo.i.dirEntNum == NCP_FINFO(inode)->dirEntNum) {
|
2005-04-17 05:20:36 +07:00
|
|
|
ncp_new_dentry(dentry);
|
|
|
|
val=1;
|
|
|
|
} else
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(2, "found, but dirEntNum changed\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-09-27 06:47:33 +07:00
|
|
|
ncp_update_inode2(inode, &finfo);
|
2016-01-23 03:40:57 +07:00
|
|
|
inode_unlock(inode);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
finished:
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(2, "result=%d\n", val);
|
2005-04-17 05:20:36 +07:00
|
|
|
dput(parent);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static time_t ncp_obtain_mtime(struct dentry *dentry)
|
|
|
|
{
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-12-25 09:41:47 +07:00
|
|
|
static inline void
|
|
|
|
ncp_invalidate_dircache_entries(struct dentry *parent)
|
|
|
|
{
|
2015-03-18 05:25:59 +07:00
|
|
|
struct ncp_server *server = NCP_SERVER(d_inode(parent));
|
2014-12-25 09:41:47 +07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-05-23 02:11:27 +07:00
|
|
|
static int ncp_readdir(struct file *file, struct dir_context *ctx)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-05-23 02:11:27 +07:00
|
|
|
struct dentry *dentry = file->f_path.dentry;
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(2, "reading %pD2, pos=%d\n", file, (int)ctx->pos);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
result = -EIO;
|
2010-09-27 06:47:33 +07:00
|
|
|
/* Do not generate '.' and '..' when server is dead. */
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!ncp_conn_valid(server))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
result = 0;
|
2013-05-23 02:11:27 +07:00
|
|
|
if (!dir_emit_dots(file, ctx))
|
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2013-05-23 02:11:27 +07:00
|
|
|
if (ctx->pos == 2) {
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-23 02:11:27 +07:00
|
|
|
if (ctx->pos > ctl.head.end)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto finished;
|
|
|
|
|
2013-05-23 02:11:27 +07:00
|
|
|
ctl.fpos = ctx->pos + (NCP_DIRCACHE_START - 2);
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
2013-05-23 02:11:27 +07:00
|
|
|
bool over;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-12-25 09:41:47 +07:00
|
|
|
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);
|
2015-03-18 05:25:59 +07:00
|
|
|
if (d_really_is_negative(dent)) {
|
2014-12-25 09:41:47 +07:00
|
|
|
dput(dent);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto invalid_cache;
|
2014-12-25 09:41:47 +07:00
|
|
|
}
|
2013-05-23 02:11:27 +07:00
|
|
|
over = !dir_emit(ctx, dent->d_name.name,
|
|
|
|
dent->d_name.len,
|
2015-03-18 05:25:59 +07:00
|
|
|
d_inode(dent)->i_ino, DT_UNKNOWN);
|
2005-04-17 05:20:36 +07:00
|
|
|
dput(dent);
|
2013-05-23 02:11:27 +07:00
|
|
|
if (over)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto finished;
|
2013-05-23 02:11:27 +07:00
|
|
|
ctx->pos += 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
ctl.idx += 1;
|
2013-05-23 02:11:27 +07:00
|
|
|
if (ctx->pos > ctl.head.end)
|
2005-04-17 05:20:36 +07:00
|
|
|
goto finished;
|
|
|
|
}
|
|
|
|
if (ctl.page) {
|
|
|
|
kunmap(ctl.page);
|
|
|
|
SetPageUptodate(ctl.page);
|
|
|
|
unlock_page(ctl.page);
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 19:29:47 +07:00
|
|
|
put_page(ctl.page);
|
2005-04-17 05:20:36 +07:00
|
|
|
ctl.page = NULL;
|
|
|
|
}
|
|
|
|
ctl.idx = 0;
|
|
|
|
ctl.ofs += 1;
|
|
|
|
}
|
|
|
|
invalid_cache:
|
|
|
|
if (ctl.page) {
|
|
|
|
kunmap(ctl.page);
|
|
|
|
unlock_page(ctl.page);
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 19:29:47 +07:00
|
|
|
put_page(ctl.page);
|
2005-04-17 05:20:36 +07:00
|
|
|
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:
|
2014-12-25 09:41:47 +07:00
|
|
|
spin_lock(&dentry->d_lock);
|
|
|
|
NCP_FINFO(inode)->flags |= NCPI_DIR_CACHE;
|
|
|
|
spin_unlock(&dentry->d_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (ncp_is_server_root(inode)) {
|
2013-05-23 02:11:27 +07:00
|
|
|
ncp_read_volume_list(file, ctx, &ctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
2013-05-23 02:11:27 +07:00
|
|
|
ncp_do_readdir(file, ctx, &ctl);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
ctl.head.end = ctl.fpos - 1;
|
|
|
|
ctl.head.eof = ctl.valid;
|
|
|
|
finished:
|
2010-09-27 06:47:33 +07:00
|
|
|
if (ctl.page) {
|
|
|
|
kunmap(ctl.page);
|
|
|
|
SetPageUptodate(ctl.page);
|
|
|
|
unlock_page(ctl.page);
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 19:29:47 +07:00
|
|
|
put_page(ctl.page);
|
2010-09-27 06:47:33 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
if (page) {
|
|
|
|
cache->head = ctl.head;
|
|
|
|
kunmap(page);
|
|
|
|
SetPageUptodate(page);
|
|
|
|
unlock_page(page);
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 19:29:47 +07:00
|
|
|
put_page(page);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-12-25 09:41:47 +07:00
|
|
|
static void ncp_d_prune(struct dentry *dentry)
|
|
|
|
{
|
|
|
|
if (!dentry->d_fsdata) /* not referenced from page cache */
|
|
|
|
return;
|
2015-03-18 05:25:59 +07:00
|
|
|
NCP_FINFO(d_inode(dentry->d_parent))->flags &= ~NCPI_DIR_CACHE;
|
2014-12-25 09:41:47 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static int
|
2013-05-23 02:11:27 +07:00
|
|
|
ncp_fill_cache(struct file *file, struct dir_context *ctx,
|
2010-09-27 06:47:33 +07:00
|
|
|
struct ncp_cache_control *ctrl, struct ncp_entry_info *entry,
|
|
|
|
int inval_childs)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-05-23 02:11:27 +07:00
|
|
|
struct dentry *newdent, *dentry = file->f_path.dentry;
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *dir = d_inode(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
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);
|
2010-09-27 06:47:33 +07:00
|
|
|
if (ncp_vol2io(NCP_SERVER(dir), __name, &qname.len,
|
2005-04-17 05:20:36 +07:00
|
|
|
entry->i.entryName, entry->i.nameLen,
|
2010-09-27 06:47:33 +07:00
|
|
|
!ncp_preserve_entry_case(dir, entry->i.NSCreator)))
|
2005-04-17 05:20:36 +07:00
|
|
|
return 1; /* I'm not sure */
|
|
|
|
|
|
|
|
qname.name = __name;
|
|
|
|
|
2013-02-12 11:20:37 +07:00
|
|
|
newdent = d_hash_and_lookup(dentry, &qname);
|
2015-08-12 17:29:44 +07:00
|
|
|
if (IS_ERR(newdent))
|
2013-02-12 11:20:37 +07:00
|
|
|
goto end_advance;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!newdent) {
|
|
|
|
newdent = d_alloc(dentry, &qname);
|
|
|
|
if (!newdent)
|
|
|
|
goto end_advance;
|
|
|
|
} else {
|
|
|
|
hashed = 1;
|
2010-09-27 06:47:33 +07:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/*
|
2011-01-07 13:49:26 +07:00
|
|
|
* 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.
|
2010-09-27 06:47:33 +07:00
|
|
|
*/
|
2011-01-07 13:49:26 +07:00
|
|
|
dentry_update_name_case(newdent, &qname);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2015-03-18 05:25:59 +07:00
|
|
|
if (d_really_is_negative(newdent)) {
|
2010-09-27 06:47:33 +07:00
|
|
|
struct inode *inode;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
entry->opened = 0;
|
2010-09-27 06:47:33 +07:00
|
|
|
entry->ino = iunique(dir->i_sb, 2);
|
|
|
|
inode = ncp_iget(dir->i_sb, entry);
|
|
|
|
if (inode) {
|
|
|
|
d_instantiate(newdent, inode);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!hashed)
|
|
|
|
d_rehash(newdent);
|
2014-12-25 09:41:47 +07:00
|
|
|
} else {
|
|
|
|
spin_lock(&dentry->d_lock);
|
2016-03-08 10:17:07 +07:00
|
|
|
NCP_FINFO(dir)->flags &= ~NCPI_DIR_CACHE;
|
2014-12-25 09:41:47 +07:00
|
|
|
spin_unlock(&dentry->d_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2010-09-27 06:47:33 +07:00
|
|
|
} else {
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode(newdent);
|
2010-09-27 06:47:33 +07:00
|
|
|
|
2016-01-23 03:40:57 +07:00
|
|
|
inode_lock_nested(inode, I_MUTEX_CHILD);
|
2010-09-27 06:47:33 +07:00
|
|
|
ncp_update_inode2(inode, entry);
|
2016-01-23 03:40:57 +07:00
|
|
|
inode_unlock(inode);
|
2010-09-27 06:47:33 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (ctl.idx >= NCP_DIRCACHE_SIZE) {
|
|
|
|
if (ctl.page) {
|
|
|
|
kunmap(ctl.page);
|
|
|
|
SetPageUptodate(ctl.page);
|
|
|
|
unlock_page(ctl.page);
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 19:29:47 +07:00
|
|
|
put_page(ctl.page);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
ctl.cache = NULL;
|
|
|
|
ctl.idx -= NCP_DIRCACHE_SIZE;
|
|
|
|
ctl.ofs += 1;
|
2010-09-27 06:47:33 +07:00
|
|
|
ctl.page = grab_cache_page(&dir->i_data, ctl.ofs);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (ctl.page)
|
|
|
|
ctl.cache = kmap(ctl.page);
|
|
|
|
}
|
|
|
|
if (ctl.cache) {
|
2015-03-18 05:25:59 +07:00
|
|
|
if (d_really_is_positive(newdent)) {
|
2014-12-25 09:41:47 +07:00
|
|
|
newdent->d_fsdata = newdent;
|
|
|
|
ctl.cache->dentry[ctl.idx] = newdent;
|
2015-03-18 05:25:59 +07:00
|
|
|
ino = d_inode(newdent)->i_ino;
|
2014-12-25 09:41:47 +07:00
|
|
|
ncp_new_dentry(newdent);
|
|
|
|
}
|
|
|
|
valid = 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
dput(newdent);
|
|
|
|
end_advance:
|
|
|
|
if (!valid)
|
|
|
|
ctl.valid = 0;
|
2013-05-23 02:11:27 +07:00
|
|
|
if (!ctl.filled && (ctl.fpos == ctx->pos)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!ino)
|
2010-09-27 06:47:33 +07:00
|
|
|
ino = iunique(dir->i_sb, 2);
|
2013-05-23 02:11:27 +07:00
|
|
|
ctl.filled = !dir_emit(ctx, qname.name, qname.len,
|
|
|
|
ino, DT_UNKNOWN);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!ctl.filled)
|
2013-05-23 02:11:27 +07:00
|
|
|
ctx->pos += 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
ctl.fpos += 1;
|
|
|
|
ctl.idx += 1;
|
|
|
|
*ctrl = ctl;
|
|
|
|
return (ctl.valid || !ctl.filled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-23 02:11:27 +07:00
|
|
|
ncp_read_volume_list(struct file *file, struct dir_context *ctx,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ncp_cache_control *ctl)
|
|
|
|
{
|
2014-10-31 13:41:28 +07:00
|
|
|
struct inode *inode = file_inode(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ncp_server *server = NCP_SERVER(inode);
|
|
|
|
struct ncp_volume_info info;
|
|
|
|
struct ncp_entry_info entry;
|
|
|
|
int i;
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "pos=%ld\n", (unsigned long)ctx->pos);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) {
|
2010-09-27 06:47:33 +07:00
|
|
|
int inval_dentry;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (ncp_get_volume_info_with_number(server, i, &info) != 0)
|
|
|
|
return;
|
|
|
|
if (!strlen(info.volume_name))
|
|
|
|
continue;
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "found vol: %s\n", info.volume_name);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (ncp_lookup_volume(server, info.volume_name,
|
|
|
|
&entry.i)) {
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "could not lookup vol %s\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
info.volume_name);
|
|
|
|
continue;
|
|
|
|
}
|
2010-09-27 06:47:33 +07:00
|
|
|
inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
entry.volume = entry.i.volNumber;
|
2013-05-23 02:11:27 +07:00
|
|
|
if (!ncp_fill_cache(file, ctx, ctl, &entry, inval_dentry))
|
2005-04-17 05:20:36 +07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-23 02:11:27 +07:00
|
|
|
ncp_do_readdir(struct file *file, struct dir_context *ctx,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ncp_cache_control *ctl)
|
|
|
|
{
|
2014-10-31 13:41:28 +07:00
|
|
|
struct inode *dir = file_inode(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "%pD2, fpos=%ld\n", file, (unsigned long)ctx->pos);
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("init %pD, volnum=%d, dirent=%u\n",
|
|
|
|
file, NCP_FINFO(dir)->volNumber, NCP_FINFO(dir)->dirEntNum);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
err = ncp_initialize_search(server, dir, &seq);
|
|
|
|
if (err) {
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "init failed, err=%d\n", err);
|
2005-04-17 05:20:36 +07:00
|
|
|
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;
|
2013-05-23 02:11:27 +07:00
|
|
|
if (!ncp_fill_cache(file, ctx, ctl, &entry, 0))
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (more);
|
|
|
|
vfree(buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ncp_conn_logged_in(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct ncp_server* server = NCP_SBP(sb);
|
|
|
|
int result;
|
|
|
|
|
|
|
|
if (ncp_single_volume(server)) {
|
|
|
|
int len;
|
|
|
|
struct dentry* dent;
|
|
|
|
__u32 volNumber;
|
|
|
|
__le32 dirEntNum;
|
|
|
|
__le32 DosDirNum;
|
|
|
|
__u8 __name[NCP_MAXPATHLEN + 1];
|
|
|
|
|
|
|
|
len = sizeof(__name);
|
|
|
|
result = ncp_io2vol(server, __name, &len, server->m.mounted_vol,
|
|
|
|
strlen(server->m.mounted_vol), 1);
|
|
|
|
if (result)
|
|
|
|
goto out;
|
|
|
|
result = -ENOENT;
|
|
|
|
if (ncp_get_volume_root(server, __name, &volNumber, &dirEntNum, &DosDirNum)) {
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("%s not found\n", server->m.mounted_vol);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
dent = sb->s_root;
|
|
|
|
if (dent) {
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode* ino = d_inode(dent);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (ino) {
|
2010-09-27 06:47:33 +07:00
|
|
|
ncp_update_known_namespace(server, volNumber, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
NCP_FINFO(ino)->volNumber = volNumber;
|
|
|
|
NCP_FINFO(ino)->dirEntNum = dirEntNum;
|
|
|
|
NCP_FINFO(ino)->DosDirNum = DosDirNum;
|
2010-09-27 06:47:33 +07:00
|
|
|
result = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
2015-03-18 05:25:59 +07:00
|
|
|
ncp_dbg(1, "d_inode(sb->s_root) == NULL!\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
} else {
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "sb->s_root == NULL!\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2010-09-27 06:47:33 +07:00
|
|
|
} else
|
|
|
|
result = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
out:
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-06-11 04:13:09 +07:00
|
|
|
static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct ncp_server *server = NCP_SERVER(dir);
|
|
|
|
struct inode *inode = NULL;
|
|
|
|
struct ncp_entry_info finfo;
|
|
|
|
int error, res, len;
|
|
|
|
__u8 __name[NCP_MAXPATHLEN + 1];
|
|
|
|
|
|
|
|
error = -EIO;
|
|
|
|
if (!ncp_conn_valid(server))
|
|
|
|
goto finished;
|
|
|
|
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("server lookup for %pd2\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
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));
|
2014-04-09 06:04:19 +07:00
|
|
|
if (!res)
|
|
|
|
ncp_update_known_namespace(server, finfo.i.volNumber, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
} 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));
|
|
|
|
}
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("looked for %pd2, res=%d\n", dentry, res);
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* If we didn't find an entry, make a negative dentry.
|
|
|
|
*/
|
|
|
|
if (res)
|
|
|
|
goto add_entry;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create an inode for the entry.
|
|
|
|
*/
|
|
|
|
finfo.opened = 0;
|
|
|
|
finfo.ino = iunique(dir->i_sb, 2);
|
|
|
|
finfo.volume = finfo.i.volNumber;
|
|
|
|
error = -EACCES;
|
|
|
|
inode = ncp_iget(dir->i_sb, &finfo);
|
|
|
|
|
|
|
|
if (inode) {
|
|
|
|
ncp_new_dentry(dentry);
|
|
|
|
add_entry:
|
|
|
|
d_add(dentry, inode);
|
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
finished:
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("result=%d\n", error);
|
2005-04-17 05:20:36 +07:00
|
|
|
return ERR_PTR(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is common to create, mkdir, and mknod.
|
|
|
|
*/
|
|
|
|
static int ncp_instantiate(struct inode *dir, struct dentry *dentry,
|
|
|
|
struct ncp_entry_info *finfo)
|
|
|
|
{
|
|
|
|
struct inode *inode;
|
|
|
|
int error = -EINVAL;
|
|
|
|
|
|
|
|
finfo->ino = iunique(dir->i_sb, 2);
|
|
|
|
inode = ncp_iget(dir->i_sb, finfo);
|
|
|
|
if (!inode)
|
|
|
|
goto out_close;
|
|
|
|
d_instantiate(dentry,inode);
|
|
|
|
error = 0;
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
|
|
|
|
out_close:
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("%pd2 failed, closing file\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
ncp_close_file(NCP_SERVER(dir), finfo->file_handle);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-07-26 14:12:16 +07:00
|
|
|
int ncp_create_new(struct inode *dir, struct dentry *dentry, umode_t mode,
|
2005-04-17 05:20:36 +07:00
|
|
|
dev_t rdev, __le32 attributes)
|
|
|
|
{
|
|
|
|
struct ncp_server *server = NCP_SERVER(dir);
|
|
|
|
struct ncp_entry_info finfo;
|
|
|
|
int error, result, len;
|
|
|
|
int opmode;
|
|
|
|
__u8 __name[NCP_MAXPATHLEN + 1];
|
|
|
|
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("creating %pd2, mode=%hx\n", dentry, mode);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ncp_age_dentry(server, dentry);
|
|
|
|
len = sizeof(__name);
|
|
|
|
error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
|
|
|
|
dentry->d_name.len, !ncp_preserve_case(dir));
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
error = -EACCES;
|
|
|
|
|
|
|
|
if (S_ISREG(mode) &&
|
|
|
|
(server->m.flags & NCP_MOUNT_EXTRAS) &&
|
|
|
|
(mode & S_IXUGO))
|
|
|
|
attributes |= aSYSTEM | aSHARED;
|
|
|
|
|
|
|
|
result = ncp_open_create_file_or_subdir(server, dir, __name,
|
|
|
|
OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE,
|
|
|
|
attributes, AR_READ | AR_WRITE, &finfo);
|
|
|
|
opmode = O_RDWR;
|
|
|
|
if (result) {
|
|
|
|
result = ncp_open_create_file_or_subdir(server, dir, __name,
|
|
|
|
OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE,
|
|
|
|
attributes, AR_WRITE, &finfo);
|
|
|
|
if (result) {
|
|
|
|
if (result == 0x87)
|
|
|
|
error = -ENAMETOOLONG;
|
2010-09-27 06:47:33 +07:00
|
|
|
else if (result < 0)
|
|
|
|
error = result;
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "%pd2 failed\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
opmode = O_WRONLY;
|
|
|
|
}
|
|
|
|
finfo.access = opmode;
|
|
|
|
if (ncp_is_nfs_extras(server, finfo.volume)) {
|
|
|
|
finfo.i.nfs.mode = mode;
|
|
|
|
finfo.i.nfs.rdev = new_encode_dev(rdev);
|
|
|
|
if (ncp_modify_nfs_info(server, finfo.volume,
|
|
|
|
finfo.i.dirEntNum,
|
|
|
|
mode, new_encode_dev(rdev)) != 0)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = ncp_instantiate(dir, dentry, &finfo);
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2011-07-26 12:42:34 +07:00
|
|
|
static int ncp_create(struct inode *dir, struct dentry *dentry, umode_t mode,
|
2012-06-11 05:05:36 +07:00
|
|
|
bool excl)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return ncp_create_new(dir, dentry, mode, 0, 0);
|
|
|
|
}
|
|
|
|
|
2011-07-26 12:41:39 +07:00
|
|
|
static int ncp_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct ncp_entry_info finfo;
|
|
|
|
struct ncp_server *server = NCP_SERVER(dir);
|
|
|
|
int error, len;
|
|
|
|
__u8 __name[NCP_MAXPATHLEN + 1];
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "making %pd2\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ncp_age_dentry(server, dentry);
|
|
|
|
len = sizeof(__name);
|
|
|
|
error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
|
|
|
|
dentry->d_name.len, !ncp_preserve_case(dir));
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
2010-09-27 06:47:33 +07:00
|
|
|
error = ncp_open_create_file_or_subdir(server, dir, __name,
|
2005-04-17 05:20:36 +07:00
|
|
|
OC_MODE_CREATE, aDIR,
|
|
|
|
cpu_to_le16(0xffff),
|
2010-09-27 06:47:33 +07:00
|
|
|
&finfo);
|
|
|
|
if (error == 0) {
|
2005-04-17 05:20:36 +07:00
|
|
|
if (ncp_is_nfs_extras(server, finfo.volume)) {
|
|
|
|
mode |= S_IFDIR;
|
|
|
|
finfo.i.nfs.mode = mode;
|
|
|
|
if (ncp_modify_nfs_info(server,
|
|
|
|
finfo.volume,
|
|
|
|
finfo.i.dirEntNum,
|
|
|
|
mode, 0) != 0)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
error = ncp_instantiate(dir, dentry, &finfo);
|
2010-09-27 06:47:33 +07:00
|
|
|
} else if (error > 0) {
|
|
|
|
error = -EACCES;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ncp_rmdir(struct inode *dir, struct dentry *dentry)
|
|
|
|
{
|
|
|
|
struct ncp_server *server = NCP_SERVER(dir);
|
|
|
|
int error, result, len;
|
|
|
|
__u8 __name[NCP_MAXPATHLEN + 1];
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "removing %pd2\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
len = sizeof(__name);
|
|
|
|
error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
|
|
|
|
dentry->d_name.len, !ncp_preserve_case(dir));
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
result = ncp_del_file_or_subdir(server, dir, __name);
|
|
|
|
switch (result) {
|
|
|
|
case 0x00:
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
case 0x85: /* unauthorized to delete file */
|
|
|
|
case 0x8A: /* unauthorized to delete file */
|
|
|
|
error = -EACCES;
|
|
|
|
break;
|
|
|
|
case 0x8F:
|
|
|
|
case 0x90: /* read only */
|
|
|
|
error = -EPERM;
|
|
|
|
break;
|
|
|
|
case 0x9F: /* in use by another client */
|
|
|
|
error = -EBUSY;
|
|
|
|
break;
|
|
|
|
case 0xA0: /* directory not empty */
|
|
|
|
error = -ENOTEMPTY;
|
|
|
|
break;
|
|
|
|
case 0xFF: /* someone deleted file */
|
|
|
|
error = -ENOENT;
|
|
|
|
break;
|
|
|
|
default:
|
2010-09-27 06:47:33 +07:00
|
|
|
error = result < 0 ? result : -EACCES;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ncp_unlink(struct inode *dir, struct dentry *dentry)
|
|
|
|
{
|
2015-03-18 05:25:59 +07:00
|
|
|
struct inode *inode = d_inode(dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ncp_server *server;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
server = NCP_SERVER(dir);
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "unlinking %pd2\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether to close the file ...
|
|
|
|
*/
|
|
|
|
if (inode) {
|
2014-04-09 06:04:16 +07:00
|
|
|
ncp_vdbg("closing file\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
ncp_make_closed(inode);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = ncp_del_file_or_subdir2(server, dentry);
|
|
|
|
#ifdef CONFIG_NCPFS_STRONG
|
|
|
|
/* 9C is Invalid path.. It should be 8F, 90 - read only, but
|
|
|
|
it is not :-( */
|
|
|
|
if ((error == 0x9C || error == 0x90) && server->m.flags & NCP_MOUNT_STRONG) { /* R/O */
|
|
|
|
error = ncp_force_unlink(dir, dentry);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
switch (error) {
|
|
|
|
case 0x00:
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "removed %pd2\n", dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
case 0x85:
|
|
|
|
case 0x8A:
|
|
|
|
error = -EACCES;
|
|
|
|
break;
|
|
|
|
case 0x8D: /* some files in use */
|
|
|
|
case 0x8E: /* all files in use */
|
|
|
|
error = -EBUSY;
|
|
|
|
break;
|
|
|
|
case 0x8F: /* some read only */
|
|
|
|
case 0x90: /* all read only */
|
|
|
|
case 0x9C: /* !!! returned when in-use or read-only by NW4 */
|
|
|
|
error = -EPERM;
|
|
|
|
break;
|
|
|
|
case 0xFF:
|
|
|
|
error = -ENOENT;
|
|
|
|
break;
|
|
|
|
default:
|
2010-09-27 06:47:33 +07:00
|
|
|
error = error < 0 ? error : -EACCES;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 16:03:58 +07:00
|
|
|
struct inode *new_dir, struct dentry *new_dentry,
|
|
|
|
unsigned int flags)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct ncp_server *server = NCP_SERVER(old_dir);
|
|
|
|
int error;
|
|
|
|
int old_len, new_len;
|
|
|
|
__u8 __old_name[NCP_MAXPATHLEN + 1], __new_name[NCP_MAXPATHLEN + 1];
|
|
|
|
|
fs: make remaining filesystems use .rename2
This is trivial to do:
- add flags argument to foo_rename()
- check if flags is zero
- assign foo_rename() to .rename2 instead of .rename
This doesn't mean it's impossible to support RENAME_NOREPLACE for these
filesystems, but it is not trivial, like for local filesystems.
RENAME_NOREPLACE must guarantee atomicity (i.e. it shouldn't be possible
for a file to be created on one host while it is overwritten by rename on
another host).
Filesystems converted:
9p, afs, ceph, coda, ecryptfs, kernfs, lustre, ncpfs, nfs, ocfs2, orangefs.
After this, we can get rid of the duplicate interfaces for rename.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: David Howells <dhowells@redhat.com> [AFS]
Acked-by: Mike Marshall <hubcap@omnibond.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Mark Fasheh <mfasheh@suse.com>
2016-09-27 16:03:58 +07:00
|
|
|
if (flags)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "%pd2 to %pd2\n", old_dentry, new_dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
ncp_age_dentry(server, old_dentry);
|
|
|
|
ncp_age_dentry(server, new_dentry);
|
|
|
|
|
|
|
|
old_len = sizeof(__old_name);
|
|
|
|
error = ncp_io2vol(server, __old_name, &old_len,
|
|
|
|
old_dentry->d_name.name, old_dentry->d_name.len,
|
|
|
|
!ncp_preserve_case(old_dir));
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
new_len = sizeof(__new_name);
|
|
|
|
error = ncp_io2vol(server, __new_name, &new_len,
|
|
|
|
new_dentry->d_name.name, new_dentry->d_name.len,
|
|
|
|
!ncp_preserve_case(new_dir));
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
error = ncp_ren_or_mov_file_or_subdir(server, old_dir, __old_name,
|
|
|
|
new_dir, __new_name);
|
|
|
|
#ifdef CONFIG_NCPFS_STRONG
|
|
|
|
if ((error == 0x90 || error == 0x8B || error == -EACCES) &&
|
|
|
|
server->m.flags & NCP_MOUNT_STRONG) { /* RO */
|
|
|
|
error = ncp_force_rename(old_dir, old_dentry, __old_name,
|
|
|
|
new_dir, new_dentry, __new_name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
switch (error) {
|
|
|
|
case 0x00:
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "renamed %pd -> %pd\n",
|
|
|
|
old_dentry, new_dentry);
|
2015-06-06 20:15:55 +07:00
|
|
|
ncp_d_prune(old_dentry);
|
|
|
|
ncp_d_prune(new_dentry);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
case 0x9E:
|
|
|
|
error = -ENAMETOOLONG;
|
|
|
|
break;
|
|
|
|
case 0xFF:
|
|
|
|
error = -ENOENT;
|
|
|
|
break;
|
|
|
|
default:
|
2010-09-27 06:47:33 +07:00
|
|
|
error = error < 0 ? error : -EACCES;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ncp_mknod(struct inode * dir, struct dentry *dentry,
|
2011-07-26 12:52:52 +07:00
|
|
|
umode_t mode, dev_t rdev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
if (ncp_is_nfs_extras(NCP_SERVER(dir), NCP_FINFO(dir)->volNumber)) {
|
2014-04-09 06:04:15 +07:00
|
|
|
ncp_dbg(1, "mode = 0%ho\n", mode);
|
2005-04-17 05:20:36 +07:00
|
|
|
return ncp_create_new(dir, dentry, mode, rdev, 0);
|
|
|
|
}
|
|
|
|
return -EPERM; /* Strange, but true */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The following routines are taken directly from msdos-fs */
|
|
|
|
|
|
|
|
/* Linear day numbers of the respective 1sts in non-leap years. */
|
|
|
|
|
|
|
|
static int day_n[] =
|
|
|
|
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 0, 0, 0, 0};
|
|
|
|
/* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */
|
|
|
|
|
|
|
|
static int utc2local(int time)
|
|
|
|
{
|
|
|
|
return time - sys_tz.tz_minuteswest * 60;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int local2utc(int time)
|
|
|
|
{
|
|
|
|
return time + sys_tz.tz_minuteswest * 60;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */
|
|
|
|
int
|
|
|
|
ncp_date_dos2unix(__le16 t, __le16 d)
|
|
|
|
{
|
|
|
|
unsigned short time = le16_to_cpu(t), date = le16_to_cpu(d);
|
|
|
|
int month, year, secs;
|
|
|
|
|
|
|
|
/* first subtract and mask after that... Otherwise, if
|
|
|
|
date == 0, bad things happen */
|
|
|
|
month = ((date >> 5) - 1) & 15;
|
|
|
|
year = date >> 9;
|
|
|
|
secs = (time & 31) * 2 + 60 * ((time >> 5) & 63) + (time >> 11) * 3600 +
|
|
|
|
86400 * ((date & 31) - 1 + day_n[month] + (year / 4) +
|
|
|
|
year * 365 - ((year & 3) == 0 && month < 2 ? 1 : 0) + 3653);
|
|
|
|
/* days since 1.1.70 plus 80's leap day */
|
|
|
|
return local2utc(secs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Convert linear UNIX date to a MS-DOS time/date pair. */
|
|
|
|
void
|
|
|
|
ncp_date_unix2dos(int unix_date, __le16 *time, __le16 *date)
|
|
|
|
{
|
|
|
|
int day, year, nl_day, month;
|
|
|
|
|
|
|
|
unix_date = utc2local(unix_date);
|
|
|
|
*time = cpu_to_le16(
|
|
|
|
(unix_date % 60) / 2 + (((unix_date / 60) % 60) << 5) +
|
|
|
|
(((unix_date / 3600) % 24) << 11));
|
|
|
|
day = unix_date / 86400 - 3652;
|
|
|
|
year = day / 365;
|
|
|
|
if ((year + 3) / 4 + 365 * year > day)
|
|
|
|
year--;
|
|
|
|
day -= (year + 3) / 4 + 365 * year;
|
|
|
|
if (day == 59 && !(year & 3)) {
|
|
|
|
nl_day = day;
|
|
|
|
month = 2;
|
|
|
|
} else {
|
|
|
|
nl_day = (year & 3) || day <= 59 ? day : day - 1;
|
2009-09-23 06:45:54 +07:00
|
|
|
for (month = 1; month < 12; month++)
|
2005-04-17 05:20:36 +07:00
|
|
|
if (day_n[month] > nl_day)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*date = cpu_to_le16(nl_day - day_n[month - 1] + 1 + (month << 5) + (year << 9));
|
|
|
|
}
|