linux/fs/nfsd
David Howells e36cb0b89c VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
Convert the following where appropriate:

 (1) S_ISLNK(dentry->d_inode) to d_is_symlink(dentry).

 (2) S_ISREG(dentry->d_inode) to d_is_reg(dentry).

 (3) S_ISDIR(dentry->d_inode) to d_is_dir(dentry).  This is actually more
     complicated than it appears as some calls should be converted to
     d_can_lookup() instead.  The difference is whether the directory in
     question is a real dir with a ->lookup op or whether it's a fake dir with
     a ->d_automount op.

In some circumstances, we can subsume checks for dentry->d_inode not being
NULL into this, provided we the code isn't in a filesystem that expects
d_inode to be NULL if the dirent really *is* negative (ie. if we're going to
use d_inode() rather than d_backing_inode() to get the inode pointer).

Note that the dentry type field may be set to something other than
DCACHE_MISS_TYPE when d_inode is NULL in the case of unionmount, where the VFS
manages the fall-through from a negative dentry to a lower layer.  In such a
case, the dentry type of the negative union dentry is set to the same as the
type of the lower dentry.

However, if you know d_inode is not NULL at the call site, then you can use
the d_is_xxx() functions even in a filesystem.

There is one further complication: a 0,0 chardev dentry may be labelled
DCACHE_WHITEOUT_TYPE rather than DCACHE_SPECIAL_TYPE.  Strictly, this was
intended for special directory entry types that don't have attached inodes.

The following perl+coccinelle script was used:

use strict;

my @callers;
open($fd, 'git grep -l \'S_IS[A-Z].*->d_inode\' |') ||
    die "Can't grep for S_ISDIR and co. callers";
@callers = <$fd>;
close($fd);
unless (@callers) {
    print "No matches\n";
    exit(0);
}

my @cocci = (
    '@@',
    'expression E;',
    '@@',
    '',
    '- S_ISLNK(E->d_inode->i_mode)',
    '+ d_is_symlink(E)',
    '',
    '@@',
    'expression E;',
    '@@',
    '',
    '- S_ISDIR(E->d_inode->i_mode)',
    '+ d_is_dir(E)',
    '',
    '@@',
    'expression E;',
    '@@',
    '',
    '- S_ISREG(E->d_inode->i_mode)',
    '+ d_is_reg(E)' );

my $coccifile = "tmp.sp.cocci";
open($fd, ">$coccifile") || die $coccifile;
print($fd "$_\n") || die $coccifile foreach (@cocci);
close($fd);

foreach my $file (@callers) {
    chomp $file;
    print "Processing ", $file, "\n";
    system("spatch", "--sp-file", $coccifile, $file, "--in-place", "--no-show-diff") == 0 ||
	die "spatch failed";
}

[AV: overlayfs parts skipped]

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2015-02-22 11:38:41 -05:00
..
acl.h
auth.c
auth.h
blocklayout.c nfsd: pNFS block layout driver 2015-02-05 14:35:18 +01:00
blocklayoutxdr.c nfsd: pNFS block layout driver 2015-02-05 14:35:18 +01:00
blocklayoutxdr.h nfsd: pNFS block layout driver 2015-02-05 14:35:18 +01:00
cache.h
current_stateid.h
export.c nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
export.h nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
fault_inject.c
idmap.h
Kconfig nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
lockd.c
Makefile nfsd: pNFS block layout driver 2015-02-05 14:35:18 +01:00
netns.h
nfs2acl.c
nfs3acl.c
nfs3proc.c
nfs3xdr.c
nfs4acl.c
nfs4callback.c nfsd: implement pNFS layout recalls 2015-02-02 18:09:43 +01:00
nfs4idmap.c
nfs4layouts.c nfsd: pNFS block layout driver 2015-02-05 14:35:18 +01:00
nfs4proc.c nfsd: add trace events 2015-02-02 18:09:44 +01:00
nfs4recover.c VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry) 2015-02-22 11:38:41 -05:00
nfs4state.c nfsd: implement pNFS layout recalls 2015-02-02 18:09:43 +01:00
nfs4xdr.c nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
nfscache.c sunrpc: add a generic rq_flags field to svc_rqst and move rq_secure to it 2014-12-09 11:21:20 -05:00
nfsctl.c nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
nfsd.h nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
nfsfh.c VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry) 2015-02-22 11:38:41 -05:00
nfsfh.h nfsd: fix comparison in fh_fsid_match() 2015-02-12 11:26:19 -05:00
nfsproc.c
nfssvc.c nfsd: default NFSv4.2 to on 2015-02-09 14:58:50 -05:00
nfsxdr.c
pnfs.h nfsd4: fix v3-less build 2015-02-16 11:43:13 -05:00
state.h nfsd: implement pNFS layout recalls 2015-02-02 18:09:43 +01:00
stats.c
stats.h
trace.c nfsd: add trace events 2015-02-02 18:09:44 +01:00
trace.h nfsd: add trace events 2015-02-02 18:09:44 +01:00
vfs.c VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry) 2015-02-22 11:38:41 -05:00
vfs.h Merge branch 'for-3.19' of git://linux-nfs.org/~bfields/linux 2014-12-16 15:25:31 -08:00
xdr3.h
xdr4.h nfsd: implement pNFS operations 2015-02-02 18:09:42 +01:00
xdr4cb.h nfsd: implement pNFS layout recalls 2015-02-02 18:09:43 +01:00
xdr.h