Skip to contentSkip to conversation

cifs: Scripted header file cleanup and SMB1 split

PATCH In review David Howells 4 participants 46 messages Dec 22, 2025 – Jan 19 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover cifs: Scripted header file cleanup and SMB1 split

Hi Steve,

Could you consider taking these patches? There are two parts to the set.

The first part cleans up the formatting of declarations in the header file. They remove the externs, (re)name the arguments in the declarations to match those in the C file and format them to wrap at 79 chars (this is configurable - search for 79 in the script), aligning all the first argument on each line with the char after the opening bracket.

I've attached the script below so that you can also run it yourself. It does all the git manipulation to generate one commit per header file changed. Run as:

	./cifs.pl fs/smb/client/*.[ch]

in the kernel source root dir.

The script can be rerun later to readjust any added changes.

Paulo has given his R-b for this subset (labelled cifs: Scripted clean up).

The second part splits the SMB1 parts of cifs protocol layer out into their own files. cifstransport.c is renamed to smb1transport.c also for consistency, though cifssmb.c is left unrenamed (I could rename that to smb1pdu.c). This is pretty much all moving stuff around and few actual code changes. There is one bugfix, though, to cifs_dump_mids().

I've left the splitting of the SMB1 parts of the cifs filesystem layer for a future set of patches as that's would involve removing embedded parts of functions and is easier to get wrong.

The patches can be found here also:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=cifs-cleanup

Thanks,
David
---

	#!/usr/bin/perl -w
	use strict;
	unless (@ARGV) {
	    die "Usage: $0 <c_file1> [<c_file2> ...]\n";
	}

	# Data tracking
	my %funcs = ();		# Func name => { func prototype }
	my %headers = ();	# Header filename => { header content }
	my %c_files = ();	# C filename => { ordered func list, header pref }
	my %cmarkers = ();	# C filename marker => { header filename it's in }

	# Parse state
	my $pathname = "-";
	my $lineno = 0;

	sub error(@) {
	    print STDERR $pathname, ":", $lineno, ": ", @_, "\n";
	    exit(1);
	}

	sub pad($) {
	    # Reindent the function arguments to line the arguments up with the char
	    # after the opening bracket on the func argument list
	    my ($lines) = @_;
	    return $lines if ($#{$lines} <= 0);
	    my $has_empty = 0;
	    for (my $i = 0; $i <= $#{$lines}; $i++) {
		$lines->[$i] =~ s/^[ \t]+//;
		$has_empty = 1 if ($lines->[$i] eq "");
	    }

	    if ($has_empty) {
		my @clean = grep /.+/, @{$lines};
		$lines = \@clean;
	    }

	    my $indlen = index($lines->[0], "(");
	    return $lines if ($indlen < 0);
	    my $indent = "";
	    $indlen++;
	    $indent .= "\t" x ($indlen / 8);
	    $indent .= " " x ($indlen % 8);

	    my @padded = ();
	    my $acc = "";
	    my $len = -$indlen;
	    for (my $i = 0; $i <= $#{$lines}; $i++) {
		my $argument = $lines->[$i];
		my $arglen = length($argument);
		my $last = ($i == $#{$lines} ? 1 : 0);

		if ($i == 0 ||
		    $i == 1) {
		    $acc .= $argument;
		    $acc .= ";" if ($last);
		    $len += $arglen + $last;
		    next;
		}
		if (!$acc) {
		    $acc = $indent . $argument;
		    $acc .= ";" if ($last);
		    $len += $arglen + $last;
		    next;
		}
		if ($indlen + $len + 1 + $arglen + $last > 79) {
		    push @padded, $acc;
		    $acc = $indent . $argument;
		    $acc .= ";" if ($last);
		    $len = $arglen + $last;
		    next;
		}

		$acc .= " " . $argument;
		$acc .= ";" if ($last);
		$len += 1 + $arglen + $last;
	    }
	    push @padded, $acc if ($acc);
	    return \@padded;
	}

	sub earliest(@) {
	    my $ret = -1;
	    foreach (@_) {
		$ret = $_ if ($ret < 0 || ($_ >= 0 && $_ < $ret));
	    }
	    return $ret;
	}

	foreach my $file (@ARGV) {
	    # Open the file for reading.
	    next if $file =~ /trace[.]h$/;
	    next if $file =~ /smbdirect[.][ch]$/;
	    open my $fh, "<$file"
		or die "Could not open file '$file'";
	    $pathname = $file;
	    $lineno = 0;

	    my $filename;
	    my @file_content = ();
	    my @copy = ();

	    my $state = 0;
	    my $qual = "";
	    my $type = "";
	    my $funcname = "";
	    my @funcdef = ();
	    my $bracket = 0;
	    my $comment = 0;
	    my $smb1 = 0;
	    my $header = 0;
	    my $inline = 0;
	    my $file_marker = "";
	    my $config = "";
	    my $c_file = 0;

	    $filename = $pathname;
	    $filename =~ s!.*/!!;

	    if ($file =~ m!.h$!) {
		my %new_h_file = (
		    path    => $pathname,
		    fname   => $filename,
		    content => [],
		    );
		$header = \%new_h_file;
		$headers{$filename} = \%new_h_file;
	    } elsif ($file =~ m!.c$!) {
		my %new_c_file = (
		    path  => $pathname,
		    fname => $filename,
		    funcs => [],
		    );
		$c_file = \%new_c_file;
		$c_files{$filename} = \%new_c_file;
	    } else {
		warn("Ignoring unexpected file $file\n");
		next;
	    }

	    $smb1 = 1 if ($file =~ m!/smb1ops.c|/cifssmb.c|/cifstransport.c!);

	    foreach my $line (<$fh>) {
		$lineno++;
		chomp($line);
		push @copy, $line;
		if (!$line) {
		    # Blank line
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Handle continuation or end of block comment.  Look for C file
		# prototype insertion point markers.
		if ($comment) {
		    if ($line =~ m![*]/!) {
			if ($comment == 2 && $file_marker) {
			    $cmarkers{$file_marker} = $file_marker;
			    push @copy, "#C_MARKER " . $filename;
			    $file_marker = 0;
			}
			$comment = 0;
		    } else {
			$comment++;
			if ($comment == 2 && $line =~ m! [*] ([a-z][a-z_0-9]*[.][c])$!) {
			    $file_marker = $1;
			    print("Found file marker ", $file_marker, " in ", $filename, "\n");
			}
		    }
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Check cpp directives, particularly looking for SMB1 bits
		if ($line =~ /^[#]/) {
		    if ($header) {
			if ($line =~ /ifdef.*(CONFIG_[A-Z0-9_])/) {
			    error("multiconfig") if $config;
			    $config = $1;
			    $smb1++ if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
			} elsif ($line =~ /endif/) {
			    $smb1-- if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
			    $config = "";
			}
		    }
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Exclude interference in finding func names and return types
		if ($line =~ /^[{]/ ||
		    $line =~ /##/ ||
		    $line =~ /^[_a-z0-9A-Z]+:$/ || # goto label
		    $line =~ /^do [{]/ ||
		    $line =~ m!^//!) {
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Start of a block comment
		if ($line =~ m!^/[*]!) {
		    $comment = 1 unless ($line =~ m![*]/!);
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# End of a braced section, such as a function implementation
		if ($line =~ /^[}]/) {
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = ();
			push @file_content, @copy;
			@copy = ();
			next;
		}

		if ($line =~ /^typedef/) {
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    @funcdef = ();
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Extract function qualifiers.  There may be multiple of these in more
		# or less any order.  Some of them cause the func to be skipped (e.g. inline).

		if ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
		    $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
		    error("Unexpected qualifier '$1'") if ($state != 0);
		    while ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
			   $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
			$qual .= " " if ($qual);
			$qual .= $1;
			$inline = 1 if ($1 eq "inline");
			$inline = 1 if ($1 eq "__always_inline");
			$line = substr($line, length($1));
			$line =~ s/^\s+//;
		    }
		}

		if ($state == 0) {
		    # Extract what we assume to be the return type
		    if ($line =~ /^\s/) {
			push @file_content, @copy;
			@copy = ();
			next;
		    }
		    while ($line =~ /^(unsigned|signed|bool|char|short|int|long|void|const|volatile|(struct|union|enum)\s+[_a-zA-Z][_a-zA-Z0-9]*|[*]|__init|__exit|__le16|__le32|__le64|__be16|__be32|__be64)/) {
			$type .= " " if $type;
			$type .= $1;
			$line = substr($line, length($1));
			$line =~ s/^\s+//;
		    }
		    if ($line =~ /^struct [{]/) {
			# Ignore structure definitions
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = ();
			push @file_content, @copy;
			@copy = ();
			next;
		    }
		    if (index($line, "=") >= 0) {
			# Ignore assignments
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = "";
			push @file_content, @copy;
			@copy = ();
			next;
		    }

		    # Try and extract a function's type and name
		    while ($line =~ /(^[_a-zA-Z][_a-zA-Z0-9]*)/) {
			my $name = $1;
			$line = substr($line, length($name));
			next if ($line =~ /^[{]/);
			$line =~ s/^\s+//;

			my $ch = substr($line, 0, 1);
			last if ($ch eq "[" || $ch eq ";"); # Global variables

			if ($ch eq "(") {
			    # Found the function name
			    $state = 1;
			    $line = substr($line, 1);
			    $funcname = $name;
			    my $tmp = $qual . $type . " " . $funcname . "(";
			    $tmp =~ s/[*] /*/;
			    push @funcdef, $tmp;
			    $bracket = 1;
			    last;
			}

			if ($type) {
			    last if (index($line, ";") >= 0 && index($line, "(") == -1);
			    error("Unexpected name '$name' after '$type'");
			}

			$type .= " " if $type;
			$type .= $name;
			if ($line =~ /^(\s*[*]+)/) {
			    my $ptr = $1;
			    $type .= $ptr;
			    $line = substr($line, length($ptr));
			}
		    }
		}

		# Try and extract a function's argument list
		my $from = 0;
		if ($state == 1) {
		    while (1) {
			my $o = index($line, "(", $from);
			my $c = index($line, ")", $from);
			my $m = index($line, ",", $from);

			my $b = earliest($o, $c, $m);
			if ($b < 0) {
			    push @funcdef, $line
				unless ($line eq "");
			    last;
			}
			my $ch = substr($line, $b, 1);

			# Push the arguments separately on to the list
			if ($ch eq ",") {
			    push @funcdef, substr($line, 0, $b + 1);
			    $line = substr($line, $b + 1);
			    $from = 0;
			} elsif ($ch eq "(") {
			    # Handle brackets in the argument list (e.g. function
			    # pointers)
			    $bracket++;
			    $from = $b + 1;
			} elsif ($ch eq ")") {
			    $bracket--;
			    if ($bracket == 0) {
				push @funcdef, substr($line, 0, $b + 1);
				$line = substr($line, $b + 1);
				$state = 2;
				last;
			    }
			    $from = $b + 1;
			}
		    }
		}

		if ($state == 2) {
		    $inline = 1 if ($qual =~ /inline/);
		    #print("QUAL $qual $type $funcname $inline ", $#funcdef, "\n");
		    if (!$header &&
			$qual !~ /static/ &&
			$funcname ne "__acquires" &&
			$funcname ne "__releases" &&
			$funcname ne "module_init" &&
			$funcname ne "module_exit" &&
			$funcname ne "module_param" &&
			$funcname ne "module_param_call" &&
			$funcname ne "PROC_FILE_DEFINE" &&
			$funcname !~ /MODULE_/ &&
			$funcname !~ /DEFINE_/) {

			# Okay, we appear to have a function implementation
			my $func;

			if (exists($funcs{$funcname})) {
			    $func = $funcs{$funcname};
			    $func->{body} = pad(\@funcdef);
			} else {
			    my %new_func = (
				name => $funcname,
				cond => "",
				);
			    $func = \%new_func;
			    $funcs{$funcname} = $func;
			    $func->{body} = pad(\@funcdef);
			}
			$func->{body} = pad(\@funcdef);

			if ($funcname eq "cifs_inval_name_dfs_link_error") {
			    $func->{cond} = "#ifdef CONFIG_CIFS_DFS_UPCALL";
			} elsif ($funcname eq "cifs_listxattr") {
			    $func->{cond} = "#ifdef CONFIG_CIFS_XATTR";
			}

			push @{$c_file->{funcs}}, $func;
		    } elsif (!$header || $inline) {
			# Ignore inline function implementations and other weirdies
			push @file_content, @copy;
		    } elsif ($header && !$inline) {
			push @file_content, "#FUNCPROTO " . $funcname;

			my $func;

			if (exists($funcs{$funcname})) {
			    $func = $funcs{$funcname};
			    $func->{lineno} = $lineno;
			    $func->{pathname} = $pathname;
			} else {
			    my %new_func = (
				name => $funcname,
				cond => "",
				lineno => $lineno,
				pathname => $pathname,
				);
			    $func = \%new_func;
			    $funcs{$funcname} = $func;
			}
		    }

		    @funcdef = ();
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    $inline = 0;
		    $state = 0;
		    @copy = ();
		}
		if ($line =~ /;/) {
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    @funcdef = ();
		    $state = 0;
		    push @file_content, @copy;
		    @copy = ();
		}
	    }
	    close($fh);

	    if ($header) {
		$header->{content} = \@file_content;
	    }
	}

	sub write_header($)
	{
	    my ($header) = @_;
	    my $path = $header->{path};

	    my @output = ();

	    foreach my $line (@{$header->{content}}) {
		if ($line =~ "^[#]C_MARKER (.*)") {
		    next;
		} elsif ($line =~ "^[#]FUNCPROTO ([_a-zA-Z0-9]+)") {
		    my $funcname = $1;
		    my $func = $funcs{$funcname};
		    if (!$func->{body}) {
			print($func->{pathname}, ":", $func->{lineno}, ": '", $funcname,
			      "' dead prototype\n");
			next;
		    }
		    #push @output, $line;
		    push @output, @{$func->{body}};
		} else {
		    push @output, $line;
		}
	    }

	    open my $fh, ">$path"
		or die "Could not open file '$path' for writing";
	    foreach my $f (@output) {
		print($fh $f, "\n") or die $path;
	    }
	    close($fh) or die $path;

	    print("Git $path\n");
	    if (system("git diff -s --exit-code $path") == 0) {
		print("- no changes, skipping\n");
		return;
	    }

	    if (system("git add $path") != 0) {
		die("'git add $path' failed\n");
	    }

	    open $fh, ">.commit_message"
		or die "Could not open file '.commit_message' for writing";
	    print($fh
		  qq/
	cifs: Scripted clean up $path

	Remove externs, correct argument names and reformat declarations.

	Signed-off-by: David Howells <dhowells\@redhat.com>
	cc: Steve French <sfrench\@samba.org>
	cc: Paulo Alcantara <pc\@manguebit.org>
	cc: Enzo Matsumiya <ematsumiya\@suse.de>
	cc: linux-cifs\@vger.kernel.org
	cc: linux-fsdevel\@vger.kernel.org
	cc: linux-kernel\@vger.kernel.org
	/);
	    close($fh) or die ".commit_message";

	    if (system("git commit -F .commit_message") != 0) {
		die("'git commit $path' failed\n");
	    }
	}

	foreach my $h (keys(%headers)) {
	    write_header($headers{$h});
	}

David Howells (37):
cifs: Scripted clean up fs/smb/client/cached_dir.h
cifs: Scripted clean up fs/smb/client/dfs.h
cifs: Scripted clean up fs/smb/client/cifsproto.h
cifs: Scripted clean up fs/smb/client/cifs_unicode.h
cifs: Scripted clean up fs/smb/client/netlink.h
cifs: Scripted clean up fs/smb/client/cifsfs.h
cifs: Scripted clean up fs/smb/client/dfs_cache.h
cifs: Scripted clean up fs/smb/client/dns_resolve.h
cifs: Scripted clean up fs/smb/client/cifsglob.h
cifs: Scripted clean up fs/smb/client/fscache.h
cifs: Scripted clean up fs/smb/client/fs_context.h
cifs: Scripted clean up fs/smb/client/cifs_spnego.h
cifs: Scripted clean up fs/smb/client/compress.h
cifs: Scripted clean up fs/smb/client/cifs_swn.h
cifs: Scripted clean up fs/smb/client/cifs_debug.h
cifs: Scripted clean up fs/smb/client/smb2proto.h
cifs: Scripted clean up fs/smb/client/reparse.h
cifs: Scripted clean up fs/smb/client/ntlmssp.h
cifs: SMB1 split: Rename cifstransport.c
cifs: SMB1 split: Create smb1proto.h for SMB1 declarations
cifs: SMB1 split: Separate out SMB1 decls into smb1proto.h
cifs: SMB1 split: Move some SMB1 receive bits to smb1transport.c
cifs: SMB1 split: Move some SMB1 received PDU checking bits to
smb1transport.c
cifs: SMB1 split: Add some #includes
cifs: SMB1 split: Split SMB1 protocol defs into smb1pdu.h
cifs: SMB1 split: Adjust #includes
cifs: SMB1 split: Move BCC access functions
cifs: SMB1 split: Don't return smb_hdr from cifs_{,small_}buf_get()
cifs: Fix cifs_dump_mids() to call ->dump_detail
cifs: SMB1 split: Move inline funcs
cifs: SMB1 split: cifs_debug.c
cifs: SMB1 split: misc.c
cifs: SMB1 split: netmisc.c
cifs: SMB1 split: cifsencrypt.c
cifs: SMB1 split: sess.c
cifs: SMB1 split: connect.c
cifs: SMB1 split: Make BCC accessors conditional

 fs/smb/client/Makefile        |   10 +-
 fs/smb/client/cached_dir.h    |   30 +-
 fs/smb/client/cifs_debug.c    |   18 +-
 fs/smb/client/cifs_debug.h    |    1 -
 fs/smb/client/cifs_spnego.h   |    4 +-
 fs/smb/client/cifs_swn.h      |   10 +-
 fs/smb/client/cifs_unicode.c  |    1 -
 fs/smb/client/cifs_unicode.h  |   17 +-
 fs/smb/client/cifsacl.c       |    1 -
 fs/smb/client/cifsencrypt.c   |  124 --
 fs/smb/client/cifsfs.c        |    1 -
 fs/smb/client/cifsfs.h        |  114 +-
 fs/smb/client/cifsglob.h      |   29 +-
 fs/smb/client/cifspdu.h       | 2377 +--------------------------------
 fs/smb/client/cifsproto.h     |  780 ++++-------
 fs/smb/client/cifssmb.c       |  147 +-
 fs/smb/client/cifstransport.c |  263 ----
 fs/smb/client/compress.h      |    3 +-
 fs/smb/client/connect.c       |  252 ----
 fs/smb/client/dfs.h           |    3 +-
 fs/smb/client/dfs_cache.h     |   19 +-
 fs/smb/client/dir.c           |    1 -
 fs/smb/client/dns_resolve.h   |    4 +-
 fs/smb/client/file.c          |    1 -
 fs/smb/client/fs_context.c    |    1 -
 fs/smb/client/fs_context.h    |   16 +-
 fs/smb/client/fscache.h       |   17 +-
 fs/smb/client/inode.c         |    1 -
 fs/smb/client/ioctl.c         |    1 -
 fs/smb/client/link.c          |    1 -
 fs/smb/client/misc.c          |  302 +----
 fs/smb/client/netlink.h       |    4 +-
 fs/smb/client/netmisc.c       |  824 +-----------
 fs/smb/client/ntlmssp.h       |   15 +-
 fs/smb/client/readdir.c       |    1 -
 fs/smb/client/reparse.h       |   14 +-
 fs/smb/client/sess.c          |  982 --------------
 fs/smb/client/smb1debug.c     |   25 +
 fs/smb/client/smb1encrypt.c   |  139 ++
 fs/smb/client/smb1maperror.c  |  825 ++++++++++++
 fs/smb/client/smb1misc.c      |  189 +++
 fs/smb/client/smb1ops.c       |  279 ++--
 fs/smb/client/smb1pdu.h       | 2354 ++++++++++++++++++++++++++++++++
 fs/smb/client/smb1proto.h     |  336 +++++
 fs/smb/client/smb1session.c   |  995 ++++++++++++++
 fs/smb/client/smb1transport.c |  561 ++++++++
 fs/smb/client/smb2file.c      |    2 +-
 fs/smb/client/smb2inode.c     |    2 +-
 fs/smb/client/smb2pdu.c       |    2 +-
 fs/smb/client/smb2proto.h     |  468 +++----
 fs/smb/client/smbencrypt.c    |    1 -
 fs/smb/client/transport.c     |    1 -
 fs/smb/client/xattr.c         |    1 -
 fs/smb/common/smb2pdu.h       |    3 +
 54 files changed, 6310 insertions(+), 6262 deletions(-)
 delete mode 100644 fs/smb/client/cifstransport.c
 create mode 100644 fs/smb/client/smb1debug.c
 create mode 100644 fs/smb/client/smb1encrypt.c
 create mode 100644 fs/smb/client/smb1maperror.c
 create mode 100644 fs/smb/client/smb1misc.c
 create mode 100644 fs/smb/client/smb1pdu.h
 create mode 100644 fs/smb/client/smb1proto.h
 create mode 100644 fs/smb/client/smb1session.c
 create mode 100644 fs/smb/client/smb1transport.c
#1 lore raw

PATCH 1/37 cifs: Scripted clean up fs/smb/client/cached_dir.h

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cached_dir.h | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
fs/smb/client/cached_dir.h +13 -17
index 1e383db7c337..f0837bb2161a 100644
@@ -77,22 +77,18 @@ is_valid_cached_dir(struct cached_fid *cfid)
 	return cfid->time && cfid->has_lease;
 }
 
-extern struct cached_fids *init_cached_dirs(void);
-extern void free_cached_dirs(struct cached_fids *cfids);
-extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
-			   const char *path,
-			   struct cifs_sb_info *cifs_sb,
-			   bool lookup_only, struct cached_fid **cfid);
-extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
-				     struct dentry *dentry,
-				     struct cached_fid **cfid);
-extern void close_cached_dir(struct cached_fid *cfid);
-extern void drop_cached_dir_by_name(const unsigned int xid,
-				    struct cifs_tcon *tcon,
-				    const char *name,
-				    struct cifs_sb_info *cifs_sb);
-extern void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
-extern void invalidate_all_cached_dirs(struct cifs_tcon *tcon);
-extern bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
+struct cached_fids *init_cached_dirs(void);
+void free_cached_dirs(struct cached_fids *cfids);
+int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, const char *path,
+		    struct cifs_sb_info *cifs_sb, bool lookup_only,
+		    struct cached_fid **ret_cfid);
+int open_cached_dir_by_dentry(struct cifs_tcon *tcon, struct dentry *dentry,
+			      struct cached_fid **ret_cfid);
+void close_cached_dir(struct cached_fid *cfid);
+void drop_cached_dir_by_name(const unsigned int xid, struct cifs_tcon *tcon,
+			     const char *name, struct cifs_sb_info *cifs_sb);
+void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
+void invalidate_all_cached_dirs(struct cifs_tcon *tcon);
+bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
 
 #endif			/* _CACHED_DIR_H */
#2 lore raw

PATCH 2/37 cifs: Scripted clean up fs/smb/client/dfs.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/dfs.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/dfs.h +2 -1
index e60f0a24a8a1..6b5b5ca0f55c 100644
@@ -151,7 +151,8 @@ static inline void ref_walk_mark_end(struct dfs_ref_walk *rw)
 	ref->tit = ERR_PTR(-ENOENT); /* end marker */
 }
 
-int dfs_parse_target_referral(const char *full_path, const struct dfs_info3_param *ref,
+int dfs_parse_target_referral(const char *full_path,
+			      const struct dfs_info3_param *ref,
 			      struct smb3_fs_context *ctx);
 int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx);
 
#3 lore raw

PATCH 3/37 cifs: Scripted clean up fs/smb/client/cifsproto.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifsproto.h | 965 ++++++++++++++++++--------------------
 1 file changed, 462 insertions(+), 503 deletions(-)
fs/smb/client/cifsproto.h +462 -503
index f8c0615d4ee4..75a474f9e99a 100644
@@ -25,16 +25,15 @@ struct smb3_fs_context;
  *****************************************************************
  */
 
-extern struct smb_hdr *cifs_buf_get(void);
-extern void cifs_buf_release(void *);
-extern struct smb_hdr *cifs_small_buf_get(void);
-extern void cifs_small_buf_release(void *);
-extern void free_rsp_buf(int, void *);
-extern int smb_send_kvec(struct TCP_Server_Info *server,
-			 struct msghdr *msg,
-			 size_t *sent);
-extern unsigned int _get_xid(void);
-extern void _free_xid(unsigned int);
+struct smb_hdr *cifs_buf_get(void);
+void cifs_buf_release(void *buf_to_free);
+struct smb_hdr *cifs_small_buf_get(void);
+void cifs_small_buf_release(void *buf_to_free);
+void free_rsp_buf(int resp_buftype, void *rsp);
+int smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
+		  size_t *sent);
+unsigned int _get_xid(void);
+void _free_xid(unsigned int xid);
 #define get_xid()							\
 ({									\
 	unsigned int __xid = _get_xid();				\
@@ -55,16 +54,16 @@ do {									\
 	else								\
 		trace_smb3_exit_done(curr_xid, __func__);		\
 } while (0)
-extern int init_cifs_idmap(void);
-extern void exit_cifs_idmap(void);
-extern int init_cifs_spnego(void);
-extern void exit_cifs_spnego(void);
-extern const char *build_path_from_dentry(struct dentry *, void *);
-char *__build_path_from_dentry_optional_prefix(struct dentry *direntry, void *page,
-					       const char *tree, int tree_len,
-					       bool prefix);
-extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
-						    void *page, bool prefix);
+int init_cifs_idmap(void);
+void exit_cifs_idmap(void);
+int init_cifs_spnego(void);
+void exit_cifs_spnego(void);
+const char *build_path_from_dentry(struct dentry *direntry, void *page);
+char *__build_path_from_dentry_optional_prefix(struct dentry *direntry,
+					       void *page, const char *tree,
+					       int tree_len, bool prefix);
+char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
+					     void *page, bool prefix);
 static inline void *alloc_dentry_path(void)
 {
 	return __getname();
@@ -76,57 +75,56 @@ static inline void free_dentry_path(void *page)
 		__putname(page);
 }
 
-extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
-				     struct cifs_sb_info *cifs_sb,
-				     struct cifs_tcon *tcon,
-				     int add_treename);
+char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
+			      struct cifs_sb_info *cifs_sb,
+			      struct cifs_tcon *tcon, int add_treename);
 char *cifs_build_devname(char *nodename, const char *prepath);
 void delete_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid);
-void __release_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid);
-void cifs_wake_up_task(struct TCP_Server_Info *server, struct mid_q_entry *mid);
-extern int cifs_handle_standard(struct TCP_Server_Info *server,
-				struct mid_q_entry *mid);
-extern char *smb3_fs_context_fullpath(const struct smb3_fs_context *ctx,
-				      char dirsep);
-extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
-extern int smb3_parse_opt(const char *options, const char *key, char **val);
-extern int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs);
-extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
-extern int cifs_discard_remaining_data(struct TCP_Server_Info *server);
-extern int cifs_call_async(struct TCP_Server_Info *server,
-			   struct smb_rqst *rqst,
-			   mid_receive_t receive, mid_callback_t callback,
-			   mid_handle_t handle, void *cbdata, const int flags,
-			   const struct cifs_credits *exist_credits);
-extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
-extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
-			  struct TCP_Server_Info *server,
-			  struct smb_rqst *rqst, int *resp_buf_type,
-			  const int flags, struct kvec *resp_iov);
-extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
-			      struct TCP_Server_Info *server,
-			      const int flags, const int num_rqst,
-			      struct smb_rqst *rqst, int *resp_buf_type,
-			      struct kvec *resp_iov);
+void __release_mid(struct TCP_Server_Info *server,
+		   struct mid_q_entry *midEntry);
+void cifs_wake_up_task(struct TCP_Server_Info *server,
+		       struct mid_q_entry *mid);
+int cifs_handle_standard(struct TCP_Server_Info *server,
+			 struct mid_q_entry *mid);
+char *smb3_fs_context_fullpath(const struct smb3_fs_context *ctx, char dirsep);
+int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
+int smb3_parse_opt(const char *options, const char *key, char **val);
+int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs);
+bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
+int cifs_discard_remaining_data(struct TCP_Server_Info *server);
+int cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
+		    mid_receive_t receive, mid_callback_t callback,
+		    mid_handle_t handle, void *cbdata, const int flags,
+		    const struct cifs_credits *exist_credits);
+struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
+int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
+		   struct TCP_Server_Info *server, struct smb_rqst *rqst,
+		   int *resp_buf_type, const int flags, struct kvec *resp_iov);
+int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
+		       struct TCP_Server_Info *server, const int flags,
+		       const int num_rqst, struct smb_rqst *rqst,
+		       int *resp_buf_type, struct kvec *resp_iov);
 int SendReceive(const unsigned int xid, struct cifs_ses *ses,
 		struct smb_hdr *in_buf, unsigned int in_len,
-		struct smb_hdr *out_buf, int *pbytes_returned, const int flags);
+		struct smb_hdr *out_buf, int *pbytes_returned,
+		const int flags);
 int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
 		     char *in_buf, unsigned int in_len, int flags);
-int cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server);
-struct mid_q_entry *cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *ignored,
+int cifs_sync_mid_result(struct mid_q_entry *mid,
+			 struct TCP_Server_Info *server);
+struct mid_q_entry *cifs_setup_request(struct cifs_ses *ses,
+				       struct TCP_Server_Info *server,
 				       struct smb_rqst *rqst);
 struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *server,
 					     struct smb_rqst *rqst);
 int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 		    struct smb_rqst *rqst);
-extern int cifs_check_receive(struct mid_q_entry *mid,
-			struct TCP_Server_Info *server, bool log_error);
+int cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
+		       bool log_error);
 int wait_for_free_request(struct TCP_Server_Info *server, const int flags,
 			  unsigned int *instance);
-extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server,
-				 size_t size, size_t *num,
-				 struct cifs_credits *credits);
+int cifs_wait_mtu_credits(struct TCP_Server_Info *server, size_t size,
+			  size_t *num, struct cifs_credits *credits);
 
 static inline int
 send_cancel(struct cifs_ses *ses, struct TCP_Server_Info *server,
@@ -137,291 +135,274 @@ send_cancel(struct cifs_ses *ses, struct TCP_Server_Info *server,
 		server->ops->send_cancel(ses, server, rqst, mid, xid) : 0;
 }
 
-int wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ);
-extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
-			struct kvec *, int /* nvec to send */,
-			int * /* type of buf returned */, const int flags,
-			struct kvec * /* resp vec */);
+int wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *mid);
+int SendReceive2(const unsigned int xid, struct cifs_ses *ses,
+		 struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
+		 const int flags, struct kvec *resp_iov);
 
 void smb2_query_server_interfaces(struct work_struct *work);
-void
-cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
-				      bool all_channels);
-void
-cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
-				      bool mark_smb_session);
-extern int cifs_reconnect(struct TCP_Server_Info *server,
-			  bool mark_smb_session);
-int checkSMB(char *buf, unsigned int pdu_len, unsigned int len,
-	     struct TCP_Server_Info *srvr);
-extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
-extern bool backup_cred(struct cifs_sb_info *);
-extern bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 eof,
-				   bool from_readdir);
-void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata, ssize_t result);
-extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, int);
-extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
-				  int flags,
-				  struct cifsFileInfo **ret_file);
-extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
-				  int flags,
-				  struct cifsFileInfo **ret_file);
-extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool);
-extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
-				  struct cifsFileInfo **ret_file);
-extern int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode,
-				  struct file *file);
-extern unsigned int smbCalcSize(void *buf);
-extern int decode_negTokenInit(unsigned char *security_blob, int length,
+void cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
+				     bool all_channels);
+void cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
+					   bool mark_smb_session);
+int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session);
+int checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
+	     struct TCP_Server_Info *server);
+bool is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv);
+bool backup_cred(struct cifs_sb_info *cifs_sb);
+bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file,
+			    bool from_readdir);
+void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata,
+				      ssize_t result);
+struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
+					int flags);
+int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
+			   struct cifsFileInfo **ret_file);
+int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, int flags,
+			   struct cifsFileInfo **ret_file);
+struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
+					bool fsuid_only);
+int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
+			   struct cifsFileInfo **ret_file);
+int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode,
+			   struct file *file);
+unsigned int smbCalcSize(void *buf);
+int decode_negTokenInit(unsigned char *security_blob, int length,
 			struct TCP_Server_Info *server);
-extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
-extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
-extern int map_smb_to_linux_error(char *buf, bool logErr);
-extern int map_and_check_smb_error(struct TCP_Server_Info *server,
-				   struct mid_q_entry *mid, bool logErr);
+int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
+void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
+int map_smb_to_linux_error(char *buf, bool logErr);
+int map_and_check_smb_error(struct TCP_Server_Info *server,
+			    struct mid_q_entry *mid, bool logErr);
 unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
 			     const struct cifs_tcon *treeCon, int word_count
-			     /* length of fixed section word count in two byte units  */);
-extern int small_smb_init_no_tc(const int smb_cmd, const int wct,
-				struct cifs_ses *ses,
-				void **request_buf);
-extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
-			  struct TCP_Server_Info *server,
-			  const struct nls_table *nls_cp);
-extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
-extern u64 cifs_UnixTimeToNT(struct timespec64);
-extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
-				      int offset);
-extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
-extern int cifs_get_writer(struct cifsInodeInfo *cinode);
-extern void cifs_put_writer(struct cifsInodeInfo *cinode);
-extern void cifs_done_oplock_break(struct cifsInodeInfo *cinode);
-extern int cifs_unlock_range(struct cifsFileInfo *cfile,
-			     struct file_lock *flock, const unsigned int xid);
-extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
-
-extern void cifs_down_write(struct rw_semaphore *sem);
+			     /* length of fixed section (word count) in two byte units  */);
+int small_smb_init_no_tc(const int smb_command, const int wct,
+			 struct cifs_ses *ses, void **request_buf);
+int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
+		   struct TCP_Server_Info *server,
+		   const struct nls_table *nls_cp);
+struct timespec64 cifs_NTtimeToUnix(__le64 ntutc);
+u64 cifs_UnixTimeToNT(struct timespec64 t);
+struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset);
+void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
+int cifs_get_writer(struct cifsInodeInfo *cinode);
+void cifs_put_writer(struct cifsInodeInfo *cinode);
+void cifs_done_oplock_break(struct cifsInodeInfo *cinode);
+int cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
+		      unsigned int xid);
+int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
+
+void cifs_down_write(struct rw_semaphore *sem);
 struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
 				       struct tcon_link *tlink, __u32 oplock,
 				       const char *symlink_target);
-extern int cifs_posix_open(const char *full_path, struct inode **inode,
-			   struct super_block *sb, int mode,
-			   unsigned int f_flags, __u32 *oplock, __u16 *netfid,
-			   unsigned int xid);
+int cifs_posix_open(const char *full_path, struct inode **pinode,
+		    struct super_block *sb, int mode, unsigned int f_flags,
+		    __u32 *poplock, __u16 *pnetfid, unsigned int xid);
 void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr);
-extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
-				     FILE_UNIX_BASIC_INFO *info,
-				     struct cifs_sb_info *cifs_sb);
-extern void cifs_dir_info_to_fattr(struct cifs_fattr *, FILE_DIRECTORY_INFO *,
-					struct cifs_sb_info *);
-extern int cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,
-			       bool from_readdir);
-extern struct inode *cifs_iget(struct super_block *sb,
-			       struct cifs_fattr *fattr);
+void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
+			      FILE_UNIX_BASIC_INFO *info,
+			      struct cifs_sb_info *cifs_sb);
+void cifs_dir_info_to_fattr(struct cifs_fattr *fattr,
+			    FILE_DIRECTORY_INFO *info,
+			    struct cifs_sb_info *cifs_sb);
+int cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,
+			bool from_readdir);
+struct inode *cifs_iget(struct super_block *sb, struct cifs_fattr *fattr);
 
 int cifs_get_inode_info(struct inode **inode, const char *full_path,
-			struct cifs_open_info_data *data, struct super_block *sb, int xid,
+			struct cifs_open_info_data *data,
+			struct super_block *sb, int xid,
 			const struct cifs_fid *fid);
-extern int smb311_posix_get_inode_info(struct inode **inode,
-				       const char *full_path,
-				       struct cifs_open_info_data *data,
-				       struct super_block *sb,
-				       const unsigned int xid);
-extern int cifs_get_inode_info_unix(struct inode **pinode,
-			const unsigned char *search_path,
-			struct super_block *sb, unsigned int xid);
-extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
-			      unsigned int xid, const char *full_path, __u32 dosattr);
-extern int cifs_rename_pending_delete(const char *full_path,
-				      struct dentry *dentry,
-				      const unsigned int xid);
-extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
-				struct cifs_fattr *fattr, uint sidtype);
-extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
-			      struct cifs_fattr *fattr, struct inode *inode,
-			      bool get_mode_from_special_sid,
-			      const char *path, const struct cifs_fid *pfid);
-extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
-					kuid_t uid, kgid_t gid);
-extern struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifssmb, struct inode *ino,
-				      const char *path, u32 *plen, u32 info);
-extern struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifssb,
-				const struct cifs_fid *pfid, u32 *plen, u32 info);
-extern struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
-				      struct dentry *dentry, int type);
-extern int cifs_set_acl(struct mnt_idmap *idmap,
-			struct dentry *dentry, struct posix_acl *acl, int type);
-extern int set_cifs_acl(struct smb_ntsd *pntsd, __u32 len, struct inode *ino,
-				const char *path, int flag);
-extern unsigned int setup_authusers_ACE(struct smb_ace *pace);
-extern unsigned int setup_special_mode_ACE(struct smb_ace *pace,
-					   bool posix,
-					   __u64 nmode);
-extern unsigned int setup_special_user_owner_ACE(struct smb_ace *pace);
-
-void dequeue_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid, bool malformed);
-extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
-			         unsigned int to_read);
-extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
-					size_t to_read);
+int smb311_posix_get_inode_info(struct inode **inode, const char *full_path,
+				struct cifs_open_info_data *data,
+				struct super_block *sb,
+				const unsigned int xid);
+int cifs_get_inode_info_unix(struct inode **pinode,
+			     const unsigned char *full_path,
+			     struct super_block *sb, unsigned int xid);
+int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
+		       unsigned int xid, const char *full_path, __u32 dosattr);
+int cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
+			       const unsigned int xid);
+int sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
+	      struct cifs_fattr *fattr, uint sidtype);
+int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
+		      struct inode *inode, bool mode_from_special_sid,
+		      const char *path, const struct cifs_fid *pfid);
+int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
+			kuid_t uid, kgid_t gid);
+struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
+			      struct inode *inode, const char *path,
+			      u32 *pacllen, u32 info);
+struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
+				     const struct cifs_fid *cifsfid,
+				     u32 *pacllen, u32 info);
+struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+			       int type);
+int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+		 struct posix_acl *acl, int type);
+int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen, struct inode *inode,
+		 const char *path, int aclflag);
+unsigned int setup_authusers_ACE(struct smb_ace *pntace);
+unsigned int setup_special_mode_ACE(struct smb_ace *pntace, bool posix,
+				    __u64 nmode);
+unsigned int setup_special_user_owner_ACE(struct smb_ace *pntace);
+
+void dequeue_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid,
+		 bool malformed);
+int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
+			  unsigned int to_read);
+ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
+				 size_t to_read);
 int cifs_read_iter_from_socket(struct TCP_Server_Info *server,
-			       struct iov_iter *iter,
-			       unsigned int to_read);
-extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
+			       struct iov_iter *iter, unsigned int to_read);
+int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
 void cifs_mount_put_conns(struct cifs_mount_ctx *mnt_ctx);
 int cifs_mount_get_session(struct cifs_mount_ctx *mnt_ctx);
 int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx);
 int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx);
-extern int cifs_match_super(struct super_block *, void *);
-extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
-extern void cifs_umount(struct cifs_sb_info *);
-extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
-extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
-
-extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
-				    __u64 length, __u8 type, __u16 flags,
-				    struct cifsLockInfo **conf_lock,
-				    int rw_check);
-extern void cifs_add_pending_open(struct cifs_fid *fid,
+int cifs_match_super(struct super_block *sb, void *data);
+int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
+void cifs_umount(struct cifs_sb_info *cifs_sb);
+void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
+void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
+
+bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
+			     __u64 length, __u8 type, __u16 flags,
+			     struct cifsLockInfo **conf_lock, int rw_check);
+void cifs_add_pending_open(struct cifs_fid *fid, struct tcon_link *tlink,
+			   struct cifs_pending_open *open);
+void cifs_add_pending_open_locked(struct cifs_fid *fid,
 				  struct tcon_link *tlink,
 				  struct cifs_pending_open *open);
-extern void cifs_add_pending_open_locked(struct cifs_fid *fid,
-					 struct tcon_link *tlink,
-					 struct cifs_pending_open *open);
-extern void cifs_del_pending_open(struct cifs_pending_open *open);
+void cifs_del_pending_open(struct cifs_pending_open *open);
 
-extern bool cifs_is_deferred_close(struct cifsFileInfo *cfile,
-				struct cifs_deferred_close **dclose);
+bool cifs_is_deferred_close(struct cifsFileInfo *cfile,
+			    struct cifs_deferred_close **pdclose);
 
-extern void cifs_add_deferred_close(struct cifsFileInfo *cfile,
-				struct cifs_deferred_close *dclose);
+void cifs_add_deferred_close(struct cifsFileInfo *cfile,
+			     struct cifs_deferred_close *dclose);
 
-extern void cifs_del_deferred_close(struct cifsFileInfo *cfile);
+void cifs_del_deferred_close(struct cifsFileInfo *cfile);
 
-extern void cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode);
+void cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode);
 
-extern void cifs_close_all_deferred_files(struct cifs_tcon *cifs_tcon);
+void cifs_close_all_deferred_files(struct cifs_tcon *tcon);
 
-void cifs_close_deferred_file_under_dentry(struct cifs_tcon *cifs_tcon,
+void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon,
 					   struct dentry *dentry);
 
-extern void cifs_mark_open_handles_for_deleted_file(struct inode *inode,
-				const char *path);
+void cifs_mark_open_handles_for_deleted_file(struct inode *inode,
+					     const char *path);
 
-extern struct TCP_Server_Info *
-cifs_get_tcp_session(struct smb3_fs_context *ctx,
-		     struct TCP_Server_Info *primary_server);
-extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
-				 int from_reconnect);
-extern void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
+struct TCP_Server_Info *cifs_get_tcp_session(struct smb3_fs_context *ctx,
+					     struct TCP_Server_Info *primary_server);
+void cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect);
+void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
 
-extern void cifs_release_automount_timer(void);
+void cifs_release_automount_timer(void);
 
 void cifs_proc_init(void);
 void cifs_proc_clean(void);
 
-extern void cifs_move_llist(struct list_head *source, struct list_head *dest);
-extern void cifs_free_llist(struct list_head *llist);
-extern void cifs_del_lock_waiters(struct cifsLockInfo *lock);
+void cifs_move_llist(struct list_head *source, struct list_head *dest);
+void cifs_free_llist(struct list_head *llist);
+void cifs_del_lock_waiters(struct cifsLockInfo *lock);
 
 int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon);
 
-extern int cifs_negotiate_protocol(const unsigned int xid,
-				   struct cifs_ses *ses,
-				   struct TCP_Server_Info *server);
-extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
-			      struct TCP_Server_Info *server,
-			      struct nls_table *nls_info);
-extern int cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required);
-extern int CIFSSMBNegotiate(const unsigned int xid,
-			    struct cifs_ses *ses,
+int cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses,
 			    struct TCP_Server_Info *server);
-
-extern int CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
-		    const char *tree, struct cifs_tcon *tcon,
-		    const struct nls_table *);
-
-extern int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
-		const char *searchName, struct cifs_sb_info *cifs_sb,
-		__u16 *searchHandle, __u16 search_flags,
-		struct cifs_search_info *psrch_inf,
-		bool msearch);
-
-extern int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
-		__u16 searchHandle, __u16 search_flags,
-		struct cifs_search_info *psrch_inf);
-
-extern int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
-			const __u16 search_handle);
-
-extern int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			u16 netfid, FILE_ALL_INFO *pFindData);
-extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			    const char *search_Name, FILE_ALL_INFO *data,
-			    int legacy /* whether to use old info level */,
-			    const struct nls_table *nls_codepage, int remap);
-extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
-			       const char *search_name, FILE_ALL_INFO *data,
-			       const struct nls_table *nls_codepage, int remap);
-
-extern int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
-extern int CIFSSMBUnixQPathInfo(const unsigned int xid,
-			struct cifs_tcon *tcon,
-			const unsigned char *searchName,
-			FILE_UNIX_BASIC_INFO *pFindData,
+int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
+		       struct TCP_Server_Info *server,
+		       struct nls_table *nls_info);
+int cifs_enable_signing(struct TCP_Server_Info *server,
+			bool mnt_sign_required);
+int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses,
+		     struct TCP_Server_Info *server);
+
+int CIFSTCon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
+	     struct cifs_tcon *tcon, const struct nls_table *nls_codepage);
+
+int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
+		  const char *searchName, struct cifs_sb_info *cifs_sb,
+		  __u16 *pnetfid, __u16 search_flags,
+		  struct cifs_search_info *psrch_inf, bool msearch);
+
+int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
+		 __u16 searchHandle, __u16 search_flags,
+		 struct cifs_search_info *psrch_inf);
+
+int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
+		  const __u16 searchHandle);
+
+int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		     u16 netfid, FILE_ALL_INFO *pFindData);
+int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		     const char *search_name, FILE_ALL_INFO *data,
+		     int legacy /* old style infolevel */,
+		     const struct nls_table *nls_codepage, int remap);
+int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
+			const char *search_name, FILE_ALL_INFO *data,
 			const struct nls_table *nls_codepage, int remap);
 
-extern int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
-			   const char *search_name,
-			   struct dfs_info3_param **target_nodes,
-			   unsigned int *num_of_nodes,
-			   const struct nls_table *nls_codepage, int remap);
-
-extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
-			       unsigned int *num_of_nodes,
-			       struct dfs_info3_param **target_nodes,
-			       const struct nls_table *nls_codepage, int remap,
-			       const char *searchName, bool is_unicode);
-extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
-				 struct cifs_sb_info *cifs_sb,
-				 struct smb3_fs_context *ctx);
-extern int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			struct kstatfs *FSData);
-extern int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			struct kstatfs *FSData);
-extern int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			__u64 cap);
-
-extern int CIFSSMBQFSAttributeInfo(const unsigned int xid,
-			struct cifs_tcon *tcon);
-extern int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
-extern int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
-extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
+int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
+			 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
+int CIFSSMBUnixQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
+			 const unsigned char *searchName,
+			 FILE_UNIX_BASIC_INFO *pFindData,
+			 const struct nls_table *nls_codepage, int remap);
+
+int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
+		    const char *search_name,
+		    struct dfs_info3_param **target_nodes,
+		    unsigned int *num_of_nodes,
+		    const struct nls_table *nls_codepage, int remap);
+
+int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
+			unsigned int *num_of_nodes,
+			struct dfs_info3_param **target_nodes,
+			const struct nls_table *nls_codepage, int remap,
+			const char *searchName, bool is_unicode);
+void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
+			  struct cifs_sb_info *cifs_sb,
+			  struct smb3_fs_context *ctx);
+int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		   struct kstatfs *FSData);
+int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		  struct kstatfs *FSData);
+int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
+			 __u64 cap);
+
+int CIFSSMBQFSAttributeInfo(const unsigned int xid, struct cifs_tcon *tcon);
+int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
+int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
+int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
 			struct kstatfs *FSData);
 
-extern int SMBSetInformation(const unsigned int xid, struct cifs_tcon *tcon,
-			     const char *fileName, __le32 attributes, __le64 write_time,
-			     const struct nls_table *nls_codepage,
-			     struct cifs_sb_info *cifs_sb);
-extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			const char *fileName, const FILE_BASIC_INFO *data,
-			const struct nls_table *nls_codepage,
-			struct cifs_sb_info *cifs_sb);
-extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			const FILE_BASIC_INFO *data, __u16 fid,
-			__u32 pid_of_opener);
-extern int CIFSSMBSetFileDisposition(const unsigned int xid,
-				     struct cifs_tcon *tcon,
-				     bool delete_file, __u16 fid,
-				     __u32 pid_of_opener);
-extern int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
-			 const char *file_name, __u64 size,
-			 struct cifs_sb_info *cifs_sb, bool set_allocation,
-			 struct dentry *dentry);
-extern int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
-			      struct cifsFileInfo *cfile, __u64 size,
-			      bool set_allocation);
+int SMBSetInformation(const unsigned int xid, struct cifs_tcon *tcon,
+		      const char *fileName, __le32 attributes,
+		      __le64 write_time, const struct nls_table *nls_codepage,
+		      struct cifs_sb_info *cifs_sb);
+int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		       const char *fileName, const FILE_BASIC_INFO *data,
+		       const struct nls_table *nls_codepage,
+		       struct cifs_sb_info *cifs_sb);
+int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
+		       const FILE_BASIC_INFO *data, __u16 fid,
+		       __u32 pid_of_opener);
+int CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
+			      bool delete_file, __u16 fid,
+			      __u32 pid_of_opener);
+int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
+		  const char *file_name, __u64 size,
+		  struct cifs_sb_info *cifs_sb, bool set_allocation,
+		  struct dentry *dentry);
+int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
+		       struct cifsFileInfo *cfile, __u64 size,
+		       bool set_allocation);
 
 struct cifs_unix_set_info_args {
 	__u64	ctime;
@@ -433,184 +414,170 @@ struct cifs_unix_set_info_args {
 	dev_t	device;
 };
 
-extern int CIFSSMBUnixSetFileInfo(const unsigned int xid,
-				  struct cifs_tcon *tcon,
-				  const struct cifs_unix_set_info_args *args,
-				  u16 fid, u32 pid_of_opener);
-
-extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
-				  struct cifs_tcon *tcon, const char *file_name,
-				  const struct cifs_unix_set_info_args *args,
-				  const struct nls_table *nls_codepage,
-				  int remap);
-
-extern int CIFSSMBMkDir(const unsigned int xid, struct inode *inode,
-			umode_t mode, struct cifs_tcon *tcon,
-			const char *name, struct cifs_sb_info *cifs_sb);
-extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
-			const char *name, struct cifs_sb_info *cifs_sb);
-extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
-			const char *name, __u16 type,
-			const struct nls_table *nls_codepage,
-			int remap_special_chars);
-extern int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
-			  const char *name, struct cifs_sb_info *cifs_sb,
-			  struct dentry *dentry);
+int CIFSSMBUnixSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
+			   const struct cifs_unix_set_info_args *args, u16 fid,
+			   u32 pid_of_opener);
+
+int CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
+			   const char *file_name,
+			   const struct cifs_unix_set_info_args *args,
+			   const struct nls_table *nls_codepage, int remap);
+
+int CIFSSMBMkDir(const unsigned int xid, struct inode *inode, umode_t mode,
+		 struct cifs_tcon *tcon, const char *name,
+		 struct cifs_sb_info *cifs_sb);
+int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
+		 const char *name, struct cifs_sb_info *cifs_sb);
+int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
+		     const char *fileName, __u16 type,
+		     const struct nls_table *nls_codepage, int remap);
+int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
+		   const char *name, struct cifs_sb_info *cifs_sb,
+		   struct dentry *dentry);
 int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
-		  struct dentry *source_dentry,
-		  const char *from_name, const char *to_name,
-		  struct cifs_sb_info *cifs_sb);
-extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon,
-				 int netfid, const char *target_name,
-				 const struct nls_table *nls_codepage,
-				 int remap_special_chars);
-int CIFSCreateHardLink(const unsigned int xid,
-		       struct cifs_tcon *tcon,
-		       struct dentry *source_dentry,
-		       const char *from_name, const char *to_name,
-		       struct cifs_sb_info *cifs_sb);
-extern int CIFSUnixCreateHardLink(const unsigned int xid,
-			struct cifs_tcon *tcon,
-			const char *fromName, const char *toName,
-			const struct nls_table *nls_codepage,
-			int remap_special_chars);
-extern int CIFSUnixCreateSymLink(const unsigned int xid,
-			struct cifs_tcon *tcon,
-			const char *fromName, const char *toName,
-			const struct nls_table *nls_codepage, int remap);
-extern int CIFSSMBUnixQuerySymLink(const unsigned int xid,
-			struct cifs_tcon *tcon,
-			const unsigned char *searchName, char **syminfo,
-			const struct nls_table *nls_codepage, int remap);
-extern int cifs_query_reparse_point(const unsigned int xid,
-				    struct cifs_tcon *tcon,
-				    struct cifs_sb_info *cifs_sb,
-				    const char *full_path,
-				    u32 *tag, struct kvec *rsp,
-				    int *rsp_buftype);
-extern struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data,
-					       struct super_block *sb,
-					       const unsigned int xid,
-					       struct cifs_tcon *tcon,
-					       const char *full_path,
-					       bool directory,
-					       struct kvec *reparse_iov,
-					       struct kvec *xattr_iov);
-extern int CIFSSMB_set_compression(const unsigned int xid,
-				   struct cifs_tcon *tcon, __u16 fid);
-extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
-		     int *oplock, FILE_ALL_INFO *buf);
-extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
-			const char *fileName, const int disposition,
-			const int access_flags, const int omode,
-			__u16 *netfid, int *pOplock, FILE_ALL_INFO *,
-			const struct nls_table *nls_codepage, int remap);
-extern int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
-			u32 posix_flags, __u64 mode, __u16 *netfid,
-			FILE_UNIX_BASIC_INFO *pRetData,
-			__u32 *pOplock, const char *name,
-			const struct nls_table *nls_codepage, int remap);
-extern int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
-			const int smb_file_id);
-
-extern int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
-			const int smb_file_id);
-
-extern int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
-			unsigned int *nbytes, char **buf,
-			int *return_buf_type);
-extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
-			unsigned int *nbytes, const char *buf);
-extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
-			unsigned int *nbytes, struct kvec *iov, const int nvec);
-extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
-				 const char *search_name, __u64 *inode_number,
-				 const struct nls_table *nls_codepage,
-				 int remap);
-
-extern int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
-		      const __u16 netfid, const __u8 lock_type,
-		      const __u32 num_unlock, const __u32 num_lock,
-		      LOCKING_ANDX_RANGE *buf);
-extern int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
-			const __u16 netfid, const __u32 netpid, const __u64 len,
-			const __u64 offset, const __u32 numUnlock,
-			const __u32 numLock, const __u8 lockType,
-			const bool waitFlag, const __u8 oplock_level);
-extern int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
-			const __u16 smb_file_id, const __u32 netpid,
-			const loff_t start_offset, const __u64 len,
-			struct file_lock *, const __u16 lock_type,
-			const bool waitFlag);
-extern int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
-extern int CIFSSMBEcho(struct TCP_Server_Info *server);
-extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
-
-extern struct cifs_ses *sesInfoAlloc(void);
-extern void sesInfoFree(struct cifs_ses *);
-extern struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled,
-					 enum smb3_tcon_ref_trace trace);
-extern void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
-
-extern int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
+		  struct dentry *source_dentry, const char *from_name,
+		  const char *to_name, struct cifs_sb_info *cifs_sb);
+int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *pTcon,
+			  int netfid, const char *target_name,
+			  const struct nls_table *nls_codepage, int remap);
+int CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
+		       struct dentry *source_dentry, const char *from_name,
+		       const char *to_name, struct cifs_sb_info *cifs_sb);
+int CIFSUnixCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
+			   const char *fromName, const char *toName,
+			   const struct nls_table *nls_codepage, int remap);
+int CIFSUnixCreateSymLink(const unsigned int xid, struct cifs_tcon *tcon,
+			  const char *fromName, const char *toName,
+			  const struct nls_table *nls_codepage, int remap);
+int CIFSSMBUnixQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
+			    const unsigned char *searchName,
+			    char **symlinkinfo,
+			    const struct nls_table *nls_codepage, int remap);
+int cifs_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon,
+			     struct cifs_sb_info *cifs_sb,
+			     const char *full_path, u32 *tag, struct kvec *rsp,
+			     int *rsp_buftype);
+struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data,
+					struct super_block *sb,
+					const unsigned int xid,
+					struct cifs_tcon *tcon,
+					const char *full_path, bool directory,
+					struct kvec *reparse_iov,
+					struct kvec *xattr_iov);
+int CIFSSMB_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
+			    __u16 fid);
+int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
+	      int *oplock, FILE_ALL_INFO *buf);
+int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
+		  const char *fileName, const int openDisposition,
+		  const int access_flags, const int create_options,
+		  __u16 *netfid, int *pOplock, FILE_ALL_INFO *pfile_info,
+		  const struct nls_table *nls_codepage, int remap);
+int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
+		    __u32 posix_flags, __u64 mode, __u16 *netfid,
+		    FILE_UNIX_BASIC_INFO *pRetData, __u32 *pOplock,
+		    const char *name, const struct nls_table *nls_codepage,
+		    int remap);
+int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
+		 int smb_file_id);
+
+int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
+		 int smb_file_id);
+
+int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
+		unsigned int *nbytes, char **buf, int *pbuf_type);
+int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
+		 unsigned int *nbytes, const char *buf);
+int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
+		  unsigned int *nbytes, struct kvec *iov, int n_vec);
+int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
+			  const char *search_name, __u64 *inode_number,
+			  const struct nls_table *nls_codepage, int remap);
+
+int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
+	       const __u16 netfid, const __u8 lock_type,
+	       const __u32 num_unlock, const __u32 num_lock,
+	       LOCKING_ANDX_RANGE *buf);
+int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
+		const __u16 smb_file_id, const __u32 netpid, const __u64 len,
+		const __u64 offset, const __u32 numUnlock, const __u32 numLock,
+		const __u8 lockType, const bool waitFlag,
+		const __u8 oplock_level);
+int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
+		     const __u16 smb_file_id, const __u32 netpid,
+		     const loff_t start_offset, const __u64 len,
+		     struct file_lock *pLockData, const __u16 lock_type,
+		     const bool waitFlag);
+int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
+int CIFSSMBEcho(struct TCP_Server_Info *server);
+int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
+
+struct cifs_ses *sesInfoAlloc(void);
+void sesInfoFree(struct cifs_ses *buf_to_free);
+struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled,
+				  enum smb3_tcon_ref_trace trace);
+void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
+
+int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
 		   __u32 *pexpected_response_sequence_number);
 int cifs_verify_signature(struct smb_rqst *rqst,
 			  struct TCP_Server_Info *server,
 			  __u32 expected_sequence_number);
-extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *);
-extern void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
-extern int calc_seckey(struct cifs_ses *);
-extern int generate_smb30signingkey(struct cifs_ses *ses,
-				    struct TCP_Server_Info *server);
-extern int generate_smb311signingkey(struct cifs_ses *ses,
-				     struct TCP_Server_Info *server);
+int setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp);
+void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
+int calc_seckey(struct cifs_ses *ses);
+int generate_smb30signingkey(struct cifs_ses *ses,
+			     struct TCP_Server_Info *server);
+int generate_smb311signingkey(struct cifs_ses *ses,
+			      struct TCP_Server_Info *server);
 
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
-extern ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
-			const unsigned char *searchName,
-			const unsigned char *ea_name, char *EAData,
-			size_t bufsize, struct cifs_sb_info *cifs_sb);
-extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
-		const char *fileName, const char *ea_name,
-		const void *ea_value, const __u16 ea_value_len,
-		const struct nls_table *nls_codepage,
-		struct cifs_sb_info *cifs_sb);
-extern int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
-			__u16 fid, struct smb_ntsd **acl_inf, __u32 *buflen, __u32 info);
-extern int CIFSSMBSetCIFSACL(const unsigned int, struct cifs_tcon *, __u16,
-			struct smb_ntsd *pntsd, __u32 len, int aclflag);
-extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,
-			   const unsigned char *searchName,
-			   struct posix_acl **acl, const int acl_type,
-			   const struct nls_table *nls_codepage, int remap);
-extern int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
-			   const unsigned char *fileName,
-			   const struct posix_acl *acl, const int acl_type,
-			   const struct nls_table *nls_codepage, int remap);
-extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
-			const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
+ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
+		       const unsigned char *searchName,
+		       const unsigned char *ea_name, char *EAData,
+		       size_t buf_size, struct cifs_sb_info *cifs_sb);
+int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
+		 const char *fileName, const char *ea_name,
+		 const void *ea_value, const __u16 ea_value_len,
+		 const struct nls_table *nls_codepage,
+		 struct cifs_sb_info *cifs_sb);
+int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
+		      __u16 fid, struct smb_ntsd **acl_inf, __u32 *pbuflen,
+		      __u32 info);
+int CIFSSMBSetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
+		      __u16 fid, struct smb_ntsd *pntsd, __u32 acllen,
+		      int aclflag);
+int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,
+		    const unsigned char *searchName, struct posix_acl **acl,
+		    const int acl_type, const struct nls_table *nls_codepage,
+		    int remap);
+int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
+		    const unsigned char *fileName, const struct posix_acl *acl,
+		    const int acl_type, const struct nls_table *nls_codepage,
+		    int remap);
+int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
+		   const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
-extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
-extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
-extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
-			      struct cifs_sb_info *cifs_sb,
-			      struct cifs_fattr *fattr,
-			      const unsigned char *path);
-extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
-			const struct nls_table *codepage);
+void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
+bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
+int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
+		     struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
+		     const unsigned char *path);
+int E_md4hash(const unsigned char *passwd, unsigned char *p16,
+	      const struct nls_table *codepage);
 
-extern struct TCP_Server_Info *
-cifs_find_tcp_session(struct smb3_fs_context *ctx);
+struct TCP_Server_Info *cifs_find_tcp_session(struct smb3_fs_context *ctx);
 
 struct cifs_tcon *cifs_setup_ipc(struct cifs_ses *ses, bool seal);
 
 void __cifs_put_smb_ses(struct cifs_ses *ses);
 
-extern struct cifs_ses *
-cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx);
+struct cifs_ses *cifs_get_smb_ses(struct TCP_Server_Info *server,
+				  struct smb3_fs_context *ctx);
 
 int cifs_async_readv(struct cifs_io_subrequest *rdata);
-int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid);
+int cifs_readv_receive(struct TCP_Server_Info *server,
+		       struct mid_q_entry *mid);
 
 void cifs_async_writev(struct cifs_io_subrequest *wdata);
 int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
@@ -621,46 +588,41 @@ int cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 			   struct cifs_sb_info *cifs_sb,
 			   const unsigned char *path, char *pbuf,
 			   unsigned int *pbytes_written);
-int __cifs_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
-			  char *signature, struct cifs_calc_sig_ctx *ctx);
-enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
-					enum securityEnum);
+int __cifs_calc_signature(struct smb_rqst *rqst,
+			  struct TCP_Server_Info *server, char *signature,
+			  struct cifs_calc_sig_ctx *ctx);
+enum securityEnum cifs_select_sectype(struct TCP_Server_Info *server,
+				      enum securityEnum requested);
 
 int cifs_alloc_hash(const char *name, struct shash_desc **sdesc);
 void cifs_free_hash(struct shash_desc **sdesc);
 
 int cifs_try_adding_channels(struct cifs_ses *ses);
-int smb3_update_ses_channels(struct cifs_ses *ses, struct TCP_Server_Info *server,
-					bool from_reconnect, bool disable_mchan);
+int smb3_update_ses_channels(struct cifs_ses *ses,
+			     struct TCP_Server_Info *server,
+			     bool from_reconnect, bool disable_mchan);
 bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
 
-int
-cifs_ses_get_chan_index(struct cifs_ses *ses,
-			struct TCP_Server_Info *server);
-void
-cifs_chan_set_in_reconnect(struct cifs_ses *ses,
-			     struct TCP_Server_Info *server);
-void
-cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
+int cifs_ses_get_chan_index(struct cifs_ses *ses,
+			    struct TCP_Server_Info *server);
+void cifs_chan_set_in_reconnect(struct cifs_ses *ses,
+				struct TCP_Server_Info *server);
+void cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
+				  struct TCP_Server_Info *server);
+void cifs_chan_set_need_reconnect(struct cifs_ses *ses,
+				  struct TCP_Server_Info *server);
+void cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
+				    struct TCP_Server_Info *server);
+bool cifs_chan_needs_reconnect(struct cifs_ses *ses,
 			       struct TCP_Server_Info *server);
-void
-cifs_chan_set_need_reconnect(struct cifs_ses *ses,
-			     struct TCP_Server_Info *server);
-void
-cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
+bool cifs_chan_is_iface_active(struct cifs_ses *ses,
 			       struct TCP_Server_Info *server);
-bool
-cifs_chan_needs_reconnect(struct cifs_ses *ses,
-			  struct TCP_Server_Info *server);
-bool
-cifs_chan_is_iface_active(struct cifs_ses *ses,
-			  struct TCP_Server_Info *server);
-void
-cifs_decrease_secondary_channels(struct cifs_ses *ses, bool disable_mchan);
-void
-cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
-int
-SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
+void cifs_decrease_secondary_channels(struct cifs_ses *ses,
+				      bool disable_mchan);
+void cifs_chan_update_iface(struct cifs_ses *ses,
+			    struct TCP_Server_Info *server);
+int SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon,
+			    bool in_mount);
 
 void extract_unc_hostname(const char *unc, const char **h, size_t *len);
 int copy_path_name(char *dst, const char *src);
@@ -673,9 +635,8 @@ void cifs_put_tcp_super(struct super_block *sb);
 int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix);
 char *extract_hostname(const char *unc);
 char *extract_sharename(const char *unc);
-int parse_reparse_point(struct reparse_data_buffer *buf,
-			u32 plen, struct cifs_sb_info *cifs_sb,
-			const char *full_path,
+int parse_reparse_point(struct reparse_data_buffer *buf, u32 plen,
+			struct cifs_sb_info *cifs_sb, const char *full_path,
 			struct cifs_open_info_data *data);
 int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
 			 struct dentry *dentry, struct cifs_tcon *tcon,
@@ -696,14 +657,12 @@ static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
 			      referral, NULL);
 }
 
-int match_target_ip(struct TCP_Server_Info *server,
-		    const char *host, size_t hostlen,
-		    bool *result);
+int match_target_ip(struct TCP_Server_Info *server, const char *host,
+		    size_t hostlen, bool *result);
 int cifs_inval_name_dfs_link_error(const unsigned int xid,
 				   struct cifs_tcon *tcon,
 				   struct cifs_sb_info *cifs_sb,
-				   const char *full_path,
-				   bool *islink);
+				   const char *full_path, bool *islink);
 #else
 static inline int cifs_inval_name_dfs_link_error(const unsigned int xid,
 				   struct cifs_tcon *tcon,
#4 lore raw

PATCH 4/37 cifs: Scripted clean up fs/smb/client/cifs_unicode.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifs_unicode.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
fs/smb/client/cifs_unicode.h +9 -8
index 6e4b99786498..9249db3b78c3 100644
@@ -55,19 +55,20 @@
 #define SFU_MAP_UNI_RSVD	2
 
 int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
-		    const struct nls_table *cp, int map_type);
+		    const struct nls_table *codepage, int map_type);
 int cifs_utf16_bytes(const __le16 *from, int maxbytes,
 		     const struct nls_table *codepage);
-int cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *);
+int cifs_strtoUTF16(__le16 *to, const char *from, int len,
+		    const struct nls_table *codepage);
 char *cifs_strndup_from_utf16(const char *src, const int maxlen,
 			      const bool is_unicode,
 			      const struct nls_table *codepage);
-extern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen,
-			      const struct nls_table *cp, int mapChars);
-extern int cifs_remap(struct cifs_sb_info *cifs_sb);
-extern __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
-				     int *utf16_len, const struct nls_table *cp,
-				     int remap);
+int cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
+		       const struct nls_table *cp, int map_chars);
+int cifs_remap(struct cifs_sb_info *cifs_sb);
+__le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
+			      int *utf16_len, const struct nls_table *cp,
+			      int remap);
 wchar_t cifs_toupper(wchar_t in);
 
 #endif /* _CIFS_UNICODE_H */
#5 lore raw

PATCH 5/37 cifs: Scripted clean up fs/smb/client/netlink.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/netlink.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/netlink.h +2 -2
index e2fa8ed24c54..d35eef981b6b 100644
@@ -10,7 +10,7 @@
 
 extern struct genl_family cifs_genl_family;
 
-extern int cifs_genl_init(void);
-extern void cifs_genl_exit(void);
+int cifs_genl_init(void);
+void cifs_genl_exit(void);
 
 #endif /* _CIFS_NETLINK_H */
#6 lore raw

PATCH 6/37 cifs: Scripted clean up fs/smb/client/cifsfs.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifsfs.h | 114 +++++++++++++++++++++--------------------
 1 file changed, 58 insertions(+), 56 deletions(-)
fs/smb/client/cifsfs.h +58 -56
index 75d372ceb655..121821e6c872 100644
@@ -43,40 +43,41 @@ extern const struct address_space_operations cifs_addr_ops;
 extern const struct address_space_operations cifs_addr_ops_smallbuf;
 
 /* Functions related to super block operations */
-extern void cifs_sb_active(struct super_block *sb);
-extern void cifs_sb_deactive(struct super_block *sb);
+void cifs_sb_active(struct super_block *sb);
+void cifs_sb_deactive(struct super_block *sb);
 
 /* Functions related to inodes */
 extern const struct inode_operations cifs_dir_inode_ops;
-extern struct inode *cifs_root_iget(struct super_block *);
-extern int cifs_create(struct mnt_idmap *, struct inode *,
-		       struct dentry *, umode_t, bool excl);
-extern int cifs_atomic_open(struct inode *, struct dentry *,
-			    struct file *, unsigned, umode_t);
-extern struct dentry *cifs_lookup(struct inode *, struct dentry *,
-				  unsigned int);
-extern int cifs_unlink(struct inode *dir, struct dentry *dentry);
-extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *);
-extern int cifs_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
-		      umode_t, dev_t);
-extern struct dentry *cifs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *,
-				 umode_t);
-extern int cifs_rmdir(struct inode *, struct dentry *);
-extern int cifs_rename2(struct mnt_idmap *, struct inode *,
-			struct dentry *, struct inode *, struct dentry *,
-			unsigned int);
-extern int cifs_revalidate_file_attr(struct file *filp);
-extern int cifs_revalidate_dentry_attr(struct dentry *);
-extern int cifs_revalidate_file(struct file *filp);
-extern int cifs_revalidate_dentry(struct dentry *);
-extern int cifs_revalidate_mapping(struct inode *inode);
-extern int cifs_zap_mapping(struct inode *inode);
-extern int cifs_getattr(struct mnt_idmap *, const struct path *,
-			struct kstat *, u32, unsigned int);
-extern int cifs_setattr(struct mnt_idmap *, struct dentry *,
-			struct iattr *);
-extern int cifs_fiemap(struct inode *, struct fiemap_extent_info *, u64 start,
-		       u64 len);
+struct inode *cifs_root_iget(struct super_block *sb);
+int cifs_create(struct mnt_idmap *idmap, struct inode *inode,
+		struct dentry *direntry, umode_t mode, bool excl);
+int cifs_atomic_open(struct inode *inode, struct dentry *direntry,
+		     struct file *file, unsigned int oflags, umode_t mode);
+struct dentry *cifs_lookup(struct inode *parent_dir_inode,
+			   struct dentry *direntry, unsigned int flags);
+int cifs_unlink(struct inode *dir, struct dentry *dentry);
+int cifs_hardlink(struct dentry *old_file, struct inode *inode,
+		  struct dentry *direntry);
+int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
+	       struct dentry *direntry, umode_t mode, dev_t device_number);
+struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
+			  struct dentry *direntry, umode_t mode);
+int cifs_rmdir(struct inode *inode, struct dentry *direntry);
+int cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
+		 struct dentry *source_dentry, struct inode *target_dir,
+		 struct dentry *target_dentry, unsigned int flags);
+int cifs_revalidate_file_attr(struct file *filp);
+int cifs_revalidate_dentry_attr(struct dentry *dentry);
+int cifs_revalidate_file(struct file *filp);
+int cifs_revalidate_dentry(struct dentry *dentry);
+int cifs_revalidate_mapping(struct inode *inode);
+int cifs_zap_mapping(struct inode *inode);
+int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
+		 struct kstat *stat, u32 request_mask, unsigned int flags);
+int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
+		 struct iattr *attrs);
+int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
+		u64 len);
 
 extern const struct inode_operations cifs_file_inode_ops;
 extern const struct inode_operations cifs_symlink_inode_ops;
@@ -91,54 +92,55 @@ extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */
 extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */
 extern const struct file_operations cifs_file_direct_nobrl_ops;
 extern const struct file_operations cifs_file_strict_nobrl_ops;
-extern int cifs_open(struct inode *inode, struct file *file);
-extern int cifs_close(struct inode *inode, struct file *file);
-extern int cifs_closedir(struct inode *inode, struct file *file);
-extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
-extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
+int cifs_open(struct inode *inode, struct file *file);
+int cifs_close(struct inode *inode, struct file *file);
+int cifs_closedir(struct inode *inode, struct file *file);
+ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
+ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
 ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from);
 ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter);
-extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock);
-extern int cifs_lock(struct file *, int, struct file_lock *);
-extern int cifs_fsync(struct file *, loff_t, loff_t, int);
-extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int);
-extern int cifs_flush(struct file *, fl_owner_t id);
+int cifs_flock(struct file *file, int cmd, struct file_lock *fl);
+int cifs_lock(struct file *file, int cmd, struct file_lock *flock);
+int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
+int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
+		      int datasync);
+int cifs_flush(struct file *file, fl_owner_t id);
 int cifs_file_mmap_prepare(struct vm_area_desc *desc);
 int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc);
 extern const struct file_operations cifs_dir_ops;
-extern int cifs_readdir(struct file *file, struct dir_context *ctx);
+int cifs_readdir(struct file *file, struct dir_context *ctx);
 
 /* Functions related to dir entries */
 extern const struct dentry_operations cifs_dentry_ops;
 extern const struct dentry_operations cifs_ci_dentry_ops;
 
-extern struct vfsmount *cifs_d_automount(struct path *path);
+struct vfsmount *cifs_d_automount(struct path *path);
 
 /* Functions related to symlinks */
-extern const char *cifs_get_link(struct dentry *, struct inode *,
-			struct delayed_call *);
-extern int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
-			struct dentry *direntry, const char *symname);
+const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
+			  struct delayed_call *done);
+int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
+		 struct dentry *direntry, const char *symname);
 
 #ifdef CONFIG_CIFS_XATTR
 extern const struct xattr_handler * const cifs_xattr_handlers[];
-extern ssize_t	cifs_listxattr(struct dentry *, char *, size_t);
+ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size);
 #else
 # define cifs_xattr_handlers NULL
 # define cifs_listxattr NULL
 #endif
 
-extern ssize_t cifs_file_copychunk_range(unsigned int xid,
-					struct file *src_file, loff_t off,
-					struct file *dst_file, loff_t destoff,
-					size_t len, unsigned int flags);
+ssize_t cifs_file_copychunk_range(unsigned int xid, struct file *src_file,
+				  loff_t off, struct file *dst_file,
+				  loff_t destoff, size_t len,
+				  unsigned int flags);
 
-extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
-extern void cifs_setsize(struct inode *inode, loff_t offset);
+long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg);
+void cifs_setsize(struct inode *inode, loff_t offset);
 
 struct smb3_fs_context;
-extern struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type,
-					 int flags, struct smb3_fs_context *ctx);
+struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type, int flags,
+				  struct smb3_fs_context *old_ctx);
 
 #ifdef CONFIG_CIFS_NFSD_EXPORT
 extern const struct export_operations cifs_export_ops;
#7 lore raw

PATCH 7/37 cifs: Scripted clean up fs/smb/client/dfs_cache.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/dfs_cache.h | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
fs/smb/client/dfs_cache.h +12 -7
index 18a08a2ca93b..c99dc3546c70 100644
@@ -37,17 +37,22 @@ int dfs_cache_init(void);
 void dfs_cache_destroy(void);
 extern const struct proc_ops dfscache_proc_ops;
 
-int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses, const struct nls_table *cp,
-		   int remap, const char *path, struct dfs_info3_param *ref,
+int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses,
+		   const struct nls_table *cp, int remap, const char *path,
+		   struct dfs_info3_param *ref,
 		   struct dfs_cache_tgt_list *tgt_list);
 int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
 			 struct dfs_cache_tgt_list *tgt_list);
-void dfs_cache_noreq_update_tgthint(const char *path, const struct dfs_cache_tgt_iterator *it);
-int dfs_cache_get_tgt_referral(const char *path, const struct dfs_cache_tgt_iterator *it,
+void dfs_cache_noreq_update_tgthint(const char *path,
+				    const struct dfs_cache_tgt_iterator *it);
+int dfs_cache_get_tgt_referral(const char *path,
+			       const struct dfs_cache_tgt_iterator *it,
 			       struct dfs_info3_param *ref);
-int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share,
-			    char **prefix);
-char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp, int remap);
+int dfs_cache_get_tgt_share(char *path,
+			    const struct dfs_cache_tgt_iterator *it,
+			    char **share, char **prefix);
+char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp,
+			       int remap);
 int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb);
 void dfs_cache_refresh(struct work_struct *work);
 
#8 lore raw

PATCH 8/37 cifs: Scripted clean up fs/smb/client/dns_resolve.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/dns_resolve.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/dns_resolve.h +2 -2
index 36bc4a6a55bf..951fbab5e61d 100644
@@ -15,8 +15,8 @@
 #include "cifsglob.h"
 #include "cifsproto.h"
 
-int dns_resolve_name(const char *dom, const char *name,
-		     size_t namelen, struct sockaddr *ip_addr);
+int dns_resolve_name(const char *dom, const char *name, size_t namelen,
+		     struct sockaddr *ip_addr);
 
 static inline int dns_resolve_unc(const char *dom, const char *unc,
 				  struct sockaddr *ip_addr)
#9 lore raw

PATCH 9/37 cifs: Scripted clean up fs/smb/client/cifsglob.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifsglob.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
fs/smb/client/cifsglob.h +6 -6
index 251399a2c56d..b0fefdd4f624 100644
@@ -1327,8 +1327,8 @@ struct tcon_link {
 	struct cifs_tcon	*tl_tcon;
 };
 
-extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
-extern void smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst);
+struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
+void smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst);
 
 static inline struct cifs_tcon *
 tlink_tcon(struct tcon_link *tlink)
@@ -1342,7 +1342,7 @@ cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
 	return cifs_sb->master_tlink;
 }
 
-extern void cifs_put_tlink(struct tcon_link *tlink);
+void cifs_put_tlink(struct tcon_link *tlink);
 
 static inline struct tcon_link *
 cifs_get_tlink(struct tcon_link *tlink)
@@ -1353,7 +1353,7 @@ cifs_get_tlink(struct tcon_link *tlink)
 }
 
 /* This function is always expected to succeed */
-extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
+struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
 
 #define CIFS_OPLOCK_NO_CHANGE 0xfe
 
@@ -1526,8 +1526,8 @@ cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file)
 }
 
 struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file);
-void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_hdlr,
-		       bool offload);
+void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
+		       bool wait_oplock_handler, bool offload);
 void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
 int cifs_file_flush(const unsigned int xid, struct inode *inode,
 		    struct cifsFileInfo *cfile);
#10 lore raw

PATCH 10/37 cifs: Scripted clean up fs/smb/client/fscache.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/fscache.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/smb/client/fscache.h +5 -5
index f06cb24f5f3c..b6c94db5edb9 100644
@@ -38,12 +38,12 @@ struct cifs_fscache_inode_coherency_data {
 /*
  * fscache.c
  */
-extern int cifs_fscache_get_super_cookie(struct cifs_tcon *);
-extern void cifs_fscache_release_super_cookie(struct cifs_tcon *);
+int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon);
+void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon);
 
-extern void cifs_fscache_get_inode_cookie(struct inode *inode);
-extern void cifs_fscache_release_inode_cookie(struct inode *);
-extern void cifs_fscache_unuse_inode_cookie(struct inode *inode, bool update);
+void cifs_fscache_get_inode_cookie(struct inode *inode);
+void cifs_fscache_release_inode_cookie(struct inode *inode);
+void cifs_fscache_unuse_inode_cookie(struct inode *inode, bool update);
 
 static inline
 void cifs_fscache_fill_coherency(struct inode *inode,
#11 lore raw

PATCH 11/37 cifs: Scripted clean up fs/smb/client/fs_context.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/fs_context.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
fs/smb/client/fs_context.h +9 -7
index 7af7cbbe4208..49b2a6f09ca2 100644
@@ -361,18 +361,20 @@ static inline enum cifs_symlink_type cifs_symlink_type(struct cifs_sb_info *cifs
 	return CIFS_SYMLINK_TYPE_NONE;
 }
 
-extern int smb3_init_fs_context(struct fs_context *fc);
-extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
-extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
+int smb3_init_fs_context(struct fs_context *fc);
+void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
+void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
 
 static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
 {
 	return fc->fs_private;
 }
 
-extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
-extern int smb3_sync_session_ctx_passwords(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
-extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
+int smb3_fs_context_dup(struct smb3_fs_context *new_ctx,
+			struct smb3_fs_context *ctx);
+int smb3_sync_session_ctx_passwords(struct cifs_sb_info *cifs_sb,
+				    struct cifs_ses *ses);
+void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
 
 /*
  * max deferred close timeout (jiffies) - 2^30
@@ -380,7 +382,7 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
 #define SMB3_MAX_DCLOSETIMEO (1 << 30)
 #define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
 #define MAX_CACHED_FIDS 16
-extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
+char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
 
 extern struct mutex cifs_mount_mutex;
 
#12 lore raw

PATCH 12/37 cifs: Scripted clean up fs/smb/client/cifs_spnego.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifs_spnego.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/cifs_spnego.h +2 -2
index e70929db3611..987768348624 100644
@@ -28,7 +28,7 @@ struct cifs_spnego_msg {
 };
 
 extern struct key_type cifs_spnego_key_type;
-extern struct key *cifs_get_spnego_key(struct cifs_ses *sesInfo,
-				       struct TCP_Server_Info *server);
+struct key *cifs_get_spnego_key(struct cifs_ses *sesInfo,
+				struct TCP_Server_Info *server);
 
 #endif /* _CIFS_SPNEGO_H */
#13 lore raw

PATCH 13/37 cifs: Scripted clean up fs/smb/client/compress.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/compress.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/compress.h +2 -1
index 63aea32fbe92..2679baca129b 100644
@@ -30,7 +30,8 @@
 typedef int (*compress_send_fn)(struct TCP_Server_Info *, int, struct smb_rqst *);
 
 
-int smb_compress(struct TCP_Server_Info *server, struct smb_rqst *rq, compress_send_fn send_fn);
+int smb_compress(struct TCP_Server_Info *server, struct smb_rqst *rq,
+		 compress_send_fn send_fn);
 bool should_compress(const struct cifs_tcon *tcon, const struct smb_rqst *rq);
 
 /*
#14 lore raw

PATCH 14/37 cifs: Scripted clean up fs/smb/client/cifs_swn.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifs_swn.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/smb/client/cifs_swn.h +5 -5
index 8a9d2a5c9077..955d07b69450 100644
@@ -14,15 +14,15 @@ struct sk_buff;
 struct genl_info;
 
 #ifdef CONFIG_CIFS_SWN_UPCALL
-extern int cifs_swn_register(struct cifs_tcon *tcon);
+int cifs_swn_register(struct cifs_tcon *tcon);
 
-extern int cifs_swn_unregister(struct cifs_tcon *tcon);
+int cifs_swn_unregister(struct cifs_tcon *tcon);
 
-extern int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info);
+int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info);
 
-extern void cifs_swn_dump(struct seq_file *m);
+void cifs_swn_dump(struct seq_file *m);
 
-extern void cifs_swn_check(void);
+void cifs_swn_check(void);
 
 static inline bool cifs_swn_set_server_dstaddr(struct TCP_Server_Info *server)
 {
#15 lore raw

PATCH 15/37 cifs: Scripted clean up fs/smb/client/cifs_debug.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/cifs_debug.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/cifs_debug.h +2 -1
index e0035ff42dba..35bd5c8e1d71 100644
@@ -15,7 +15,8 @@
 #define pr_fmt(fmt) "CIFS: " fmt
 
 void cifs_dump_mem(char *label, void *data, int length);
-void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server);
+void cifs_dump_detail(void *buf, size_t buf_len,
+		      struct TCP_Server_Info *server);
 void cifs_dump_mids(struct TCP_Server_Info *server);
 extern bool traceSMB;		/* flag which enables the function below */
 void dump_smb(void *buf, int smb_buf_length);
#16 lore raw

PATCH 16/37 cifs: Scripted clean up fs/smb/client/smb2proto.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/smb2proto.h | 468 ++++++++++++++++++--------------------
 1 file changed, 216 insertions(+), 252 deletions(-)
fs/smb/client/smb2proto.h +216 -252
index 063c9f83bbcd..abd62cb2cecd 100644
@@ -22,287 +22,251 @@ struct smb_rqst;
  * All Prototypes
  *****************************************************************
  */
-extern int map_smb2_to_linux_error(char *buf, bool log_err);
-extern int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int length,
-			      struct TCP_Server_Info *server);
-extern unsigned int smb2_calc_size(void *buf);
-extern char *smb2_get_data_area_len(int *off, int *len,
-				    struct smb2_hdr *shdr);
-extern __le16 *cifs_convert_path_to_utf16(const char *from,
-					  struct cifs_sb_info *cifs_sb);
+int map_smb2_to_linux_error(char *buf, bool log_err);
+int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len,
+		       struct TCP_Server_Info *server);
+unsigned int smb2_calc_size(void *buf);
+char *smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr);
+__le16 *cifs_convert_path_to_utf16(const char *from,
+				   struct cifs_sb_info *cifs_sb);
 
-extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *);
-extern int smb2_check_receive(struct mid_q_entry *mid,
-			      struct TCP_Server_Info *server, bool log_error);
-extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
-					      struct TCP_Server_Info *,
-					      struct smb_rqst *rqst);
-extern struct mid_q_entry *smb2_setup_async_request(
-			struct TCP_Server_Info *server, struct smb_rqst *rqst);
-extern struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
-						__u64 ses_id, __u32  tid);
-extern __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
-extern bool smb2_is_valid_oplock_break(char *buffer,
-				       struct TCP_Server_Info *srv);
-extern int smb3_handle_read_data(struct TCP_Server_Info *server,
-				 struct mid_q_entry *mid);
+int smb2_verify_signature(struct smb_rqst *rqst,
+			  struct TCP_Server_Info *server);
+int smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
+		       bool log_error);
+struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
+				       struct TCP_Server_Info *server,
+				       struct smb_rqst *rqst);
+struct mid_q_entry *smb2_setup_async_request(struct TCP_Server_Info *server,
+					     struct smb_rqst *rqst);
+struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
+				     __u64 ses_id, __u32  tid);
+__le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
+bool smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server);
+int smb3_handle_read_data(struct TCP_Server_Info *server,
+			  struct mid_q_entry *mid);
 struct inode *smb2_create_reparse_inode(struct cifs_open_info_data *data,
-				     struct super_block *sb,
-				     const unsigned int xid,
-				     struct cifs_tcon *tcon,
-				     const char *full_path,
-				     bool directory,
-				     struct kvec *reparse_iov,
-				     struct kvec *xattr_iov);
-int smb2_query_reparse_point(const unsigned int xid,
-			     struct cifs_tcon *tcon,
+					struct super_block *sb,
+					const unsigned int xid,
+					struct cifs_tcon *tcon,
+					const char *full_path, bool directory,
+					struct kvec *reparse_iov,
+					struct kvec *xattr_iov);
+int smb2_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon,
 			     struct cifs_sb_info *cifs_sb,
-			     const char *full_path,
-			     u32 *tag, struct kvec *rsp,
+			     const char *full_path, u32 *tag, struct kvec *rsp,
 			     int *rsp_buftype);
-int smb2_query_path_info(const unsigned int xid,
-			 struct cifs_tcon *tcon,
-			 struct cifs_sb_info *cifs_sb,
-			 const char *full_path,
+int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
+			 struct cifs_sb_info *cifs_sb, const char *full_path,
 			 struct cifs_open_info_data *data);
-extern int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
-			      const char *full_path, __u64 size,
-			      struct cifs_sb_info *cifs_sb, bool set_alloc,
-				  struct dentry *dentry);
-extern int smb2_set_file_info(struct inode *inode, const char *full_path,
-			      FILE_BASIC_INFO *buf, const unsigned int xid);
-extern int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
-			       umode_t mode, struct cifs_tcon *tcon,
-			       const char *full_path,
-			       struct cifs_sb_info *cifs_sb);
-extern int smb2_mkdir(const unsigned int xid, struct inode *inode,
-		      umode_t mode, struct cifs_tcon *tcon,
-		      const char *name, struct cifs_sb_info *cifs_sb);
-extern void smb2_mkdir_setinfo(struct inode *inode, const char *full_path,
-			       struct cifs_sb_info *cifs_sb,
-			       struct cifs_tcon *tcon, const unsigned int xid);
-extern int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
-		      const char *name, struct cifs_sb_info *cifs_sb);
-extern int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon,
-		       const char *name, struct cifs_sb_info *cifs_sb,
-			   struct dentry *dentry);
-int smb2_rename_path(const unsigned int xid,
-		     struct cifs_tcon *tcon,
-		     struct dentry *source_dentry,
-		     const char *from_name, const char *to_name,
-		     struct cifs_sb_info *cifs_sb);
-int smb2_create_hardlink(const unsigned int xid,
-			 struct cifs_tcon *tcon,
-			 struct dentry *source_dentry,
-			 const char *from_name, const char *to_name,
-			 struct cifs_sb_info *cifs_sb);
-extern int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
-			struct cifs_sb_info *cifs_sb, const unsigned char *path,
-			char *pbuf, unsigned int *pbytes_written);
-extern int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
+int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
+		       const char *full_path, __u64 size,
+		       struct cifs_sb_info *cifs_sb, bool set_alloc,
+		       struct dentry *dentry);
+int smb2_set_file_info(struct inode *inode, const char *full_path,
+		       FILE_BASIC_INFO *buf, const unsigned int xid);
+int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
+		       umode_t mode, struct cifs_tcon *tcon,
+		       const char *full_path, struct cifs_sb_info *cifs_sb);
+int smb2_mkdir(const unsigned int xid, struct inode *parent_inode,
+	       umode_t mode, struct cifs_tcon *tcon, const char *name,
+	       struct cifs_sb_info *cifs_sb);
+void smb2_mkdir_setinfo(struct inode *inode, const char *name,
+			struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
+			const unsigned int xid);
+int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
+	       const char *name, struct cifs_sb_info *cifs_sb);
+int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon,
+		const char *name, struct cifs_sb_info *cifs_sb,
+		struct dentry *dentry);
+int smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
+		     struct dentry *source_dentry, const char *from_name,
+		     const char *to_name, struct cifs_sb_info *cifs_sb);
+int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
+			 struct dentry *source_dentry, const char *from_name,
+			 const char *to_name, struct cifs_sb_info *cifs_sb);
+int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
+			   struct cifs_sb_info *cifs_sb,
+			   const unsigned char *path, char *pbuf,
+			   unsigned int *pbytes_written);
+int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 			  struct cifs_sb_info *cifs_sb,
 			  const unsigned char *path, char *pbuf,
 			  unsigned int *pbytes_read);
-int smb2_fix_symlink_target_type(char **target, bool directory, struct cifs_sb_info *cifs_sb);
+int smb2_fix_symlink_target_type(char **target, bool directory,
+				 struct cifs_sb_info *cifs_sb);
 int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
-			      bool relative,
-			      const char *full_path,
+			      bool relative, const char *full_path,
 			      struct cifs_sb_info *cifs_sb);
 int smb2_parse_symlink_response(struct cifs_sb_info *cifs_sb,
-				const struct kvec *iov,
-				const char *full_path,
+				const struct kvec *iov, const char *full_path,
 				char **path);
-int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 *oplock,
-		   void *buf);
-extern int smb2_unlock_range(struct cifsFileInfo *cfile,
-			     struct file_lock *flock, const unsigned int xid);
-extern int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
-extern void smb2_reconnect_server(struct work_struct *work);
-extern int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
-extern unsigned long smb_rqst_len(struct TCP_Server_Info *server,
-				  struct smb_rqst *rqst);
-extern void smb2_set_next_command(struct cifs_tcon *tcon,
-				  struct smb_rqst *rqst);
-extern void smb2_set_related(struct smb_rqst *rqst);
-extern void smb2_set_replay(struct TCP_Server_Info *server,
-			    struct smb_rqst *rqst);
-extern bool smb2_should_replay(struct cifs_tcon *tcon,
-			  int *pretries,
-			  int *pcur_sleep);
+int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
+		   __u32 *oplock, void *buf);
+int smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
+		      const unsigned int xid);
+int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
+void smb2_reconnect_server(struct work_struct *work);
+int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
+unsigned long smb_rqst_len(struct TCP_Server_Info *server,
+			   struct smb_rqst *rqst);
+void smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst);
+void smb2_set_related(struct smb_rqst *rqst);
+void smb2_set_replay(struct TCP_Server_Info *server, struct smb_rqst *rqst);
+bool smb2_should_replay(struct cifs_tcon *tcon, int *pretries,
+			int *pcur_sleep);
 
 /*
  * SMB2 Worker functions - most of protocol specific implementation details
  * are contained within these calls.
  */
-extern int SMB2_negotiate(const unsigned int xid,
-			  struct cifs_ses *ses,
-			  struct TCP_Server_Info *server);
-extern int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
-			   struct TCP_Server_Info *server,
-			   const struct nls_table *nls_cp);
-extern int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses);
-extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses,
-		     const char *tree, struct cifs_tcon *tcon,
-		     const struct nls_table *);
-extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
-extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
-		     __le16 *path, __u8 *oplock,
-		     struct smb2_file_all_info *buf,
-		     struct create_posix_rsp *posix,
-		     struct kvec *err_iov, int *resp_buftype);
-extern int SMB2_open_init(struct cifs_tcon *tcon,
-			  struct TCP_Server_Info *server,
-			  struct smb_rqst *rqst,
-			  __u8 *oplock, struct cifs_open_parms *oparms,
-			  __le16 *path);
-extern void SMB2_open_free(struct smb_rqst *rqst);
-extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
-		     u64 persistent_fid, u64 volatile_fid, u32 opcode,
-		     char *in_data, u32 indatalen, u32 maxoutlen,
-		     char **out_data, u32 *plen /* returned data len */);
-extern int SMB2_ioctl_init(struct cifs_tcon *tcon,
-			   struct TCP_Server_Info *server,
-			   struct smb_rqst *rqst,
-			   u64 persistent_fid, u64 volatile_fid, u32 opcode,
-			   char *in_data, u32 indatalen,
-			   __u32 max_response_size);
-extern void SMB2_ioctl_free(struct smb_rqst *rqst);
-extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
-			u64 persistent_fid, u64 volatile_fid, bool watch_tree,
-			u32 completion_filter, u32 max_out_data_len,
-			char **out_data, u32 *plen /* returned data len */);
+int SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses,
+		   struct TCP_Server_Info *server);
+int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
+		    struct TCP_Server_Info *server,
+		    const struct nls_table *nls_cp);
+int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses);
+int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
+	      struct cifs_tcon *tcon, const struct nls_table *cp);
+int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
+int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
+	      __le16 *path, __u8 *oplock, struct smb2_file_all_info *buf,
+	      struct create_posix_rsp *posix, struct kvec *err_iov,
+	      int *buftype);
+int SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+		   struct smb_rqst *rqst, __u8 *oplock,
+		   struct cifs_open_parms *oparms, __le16 *path);
+void SMB2_open_free(struct smb_rqst *rqst);
+int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
+	       u64 persistent_fid, u64 volatile_fid, u32 opcode, char *in_data,
+	       u32 indatalen, u32 max_out_data_len, char **out_data,
+	       u32 *plen /* returned data len */);
+int SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+		    struct smb_rqst *rqst, u64 persistent_fid,
+		    u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen,
+		    __u32 max_response_size);
+void SMB2_ioctl_free(struct smb_rqst *rqst);
+int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
+		       u64 persistent_fid, u64 volatile_fid, bool watch_tree,
+		       u32 completion_filter, u32 max_out_data_len,
+		       char **out_data, u32 *plen /* returned data len */);
 
-extern int __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
-			u64 persistent_fid, u64 volatile_fid,
-			struct smb2_file_network_open_info *pbuf);
-extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
-		      u64 persistent_file_id, u64 volatile_file_id);
-extern int SMB2_close_init(struct cifs_tcon *tcon,
-			   struct TCP_Server_Info *server,
-			   struct smb_rqst *rqst,
-			   u64 persistent_fid, u64 volatile_fid,
-			   bool query_attrs);
-extern void SMB2_close_free(struct smb_rqst *rqst);
-extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
-		      u64 persistent_file_id, u64 volatile_file_id);
-extern int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
-			   struct cifs_tcon *tcon,
-			   struct TCP_Server_Info *server,
-			   u64 persistent_file_id, u64 volatile_file_id);
-extern void SMB2_flush_free(struct smb_rqst *rqst);
-extern int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
-		u64 persistent_fid, u64 volatile_fid, struct smb311_posix_qinfo *data, u32 *plen);
-extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
-			   u64 persistent_file_id, u64 volatile_file_id,
-			   struct smb2_file_all_info *data);
-extern int SMB2_query_info_init(struct cifs_tcon *tcon,
-				struct TCP_Server_Info *server,
-				struct smb_rqst *rqst,
-				u64 persistent_fid, u64 volatile_fid,
-				u8 info_class, u8 info_type,
-				u32 additional_info, size_t output_len,
-				size_t input_len, void *input);
-extern void SMB2_query_info_free(struct smb_rqst *rqst);
-extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
-			  u64 persistent_file_id, u64 volatile_file_id,
-			  void **data, unsigned int *plen, u32 info);
-extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
+int __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
+		 u64 persistent_fid, u64 volatile_fid,
+		 struct smb2_file_network_open_info *pbuf);
+int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
+	       u64 persistent_fid, u64 volatile_fid);
+int SMB2_close_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+		    struct smb_rqst *rqst, u64 persistent_fid,
+		    u64 volatile_fid, bool query_attrs);
+void SMB2_close_free(struct smb_rqst *rqst);
+int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
+	       u64 persistent_fid, u64 volatile_fid);
+int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
+		    struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+		    u64 persistent_fid, u64 volatile_fid);
+void SMB2_flush_free(struct smb_rqst *rqst);
+int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
 			    u64 persistent_fid, u64 volatile_fid,
-			    __le64 *uniqueid);
-extern int smb2_async_readv(struct cifs_io_subrequest *rdata);
-extern int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
-		     unsigned int *nbytes, char **buf, int *buf_type);
-extern void smb2_async_writev(struct cifs_io_subrequest *wdata);
-extern int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
-		      unsigned int *nbytes, struct kvec *iov, int n_vec);
-extern int SMB2_echo(struct TCP_Server_Info *server);
-extern int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
-				u64 persistent_fid, u64 volatile_fid, int index,
-				struct cifs_search_info *srch_inf);
-extern int SMB2_query_directory_init(unsigned int xid, struct cifs_tcon *tcon,
-				     struct TCP_Server_Info *server,
-				     struct smb_rqst *rqst,
-				     u64 persistent_fid, u64 volatile_fid,
-				     int index, int info_level);
-extern void SMB2_query_directory_free(struct smb_rqst *rqst);
-extern int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
-			u64 persistent_fid, u64 volatile_fid, u32 pid,
-			loff_t new_eof);
-extern int SMB2_set_info_init(struct cifs_tcon *tcon,
+			    struct smb311_posix_qinfo *data, u32 *plen);
+int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
+		    u64 persistent_fid, u64 volatile_fid,
+		    struct smb2_file_all_info *data);
+int SMB2_query_info_init(struct cifs_tcon *tcon,
+			 struct TCP_Server_Info *server, struct smb_rqst *rqst,
+			 u64 persistent_fid, u64 volatile_fid, u8 info_class,
+			 u8 info_type, u32 additional_info, size_t output_len,
+			 size_t input_len, void *input);
+void SMB2_query_info_free(struct smb_rqst *rqst);
+int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
+		   u64 persistent_fid, u64 volatile_fid, void **data,
+		   u32 *plen, u32 extra_info);
+int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
+		     u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid);
+int smb2_async_readv(struct cifs_io_subrequest *rdata);
+int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
+	      unsigned int *nbytes, char **buf, int *buf_type);
+void smb2_async_writev(struct cifs_io_subrequest *wdata);
+int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
+	       unsigned int *nbytes, struct kvec *iov, int n_vec);
+int SMB2_echo(struct TCP_Server_Info *server);
+int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
+			 u64 persistent_fid, u64 volatile_fid, int index,
+			 struct cifs_search_info *srch_inf);
+int SMB2_query_directory_init(const unsigned int xid, struct cifs_tcon *tcon,
 			      struct TCP_Server_Info *server,
-			      struct smb_rqst *rqst,
-			      u64 persistent_fid, u64 volatile_fid, u32 pid,
-			      u8 info_class, u8 info_type, u32 additional_info,
-			      void **data, unsigned int *size);
-extern void SMB2_set_info_free(struct smb_rqst *rqst);
-extern int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
-			u64 persistent_fid, u64 volatile_fid,
-			struct smb_ntsd *pnntsd, int pacllen, int aclflag);
-extern int SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
-		       u64 persistent_fid, u64 volatile_fid,
-		       struct smb2_file_full_ea_info *buf, int len);
-extern int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
-				u64 persistent_fid, u64 volatile_fid);
-extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
-			     const u64 persistent_fid, const u64 volatile_fid,
-			     const __u8 oplock_level);
-extern int smb2_handle_cancelled_close(struct cifs_tcon *tcon,
-				       __u64 persistent_fid,
-				       __u64 volatile_fid);
-extern int smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server);
+			      struct smb_rqst *rqst, u64 persistent_fid,
+			      u64 volatile_fid, int index, int info_level);
+void SMB2_query_directory_free(struct smb_rqst *rqst);
+int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
+		 u64 persistent_fid, u64 volatile_fid, u32 pid,
+		 loff_t new_eof);
+int SMB2_set_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
+		       struct smb_rqst *rqst, u64 persistent_fid,
+		       u64 volatile_fid, u32 pid, u8 info_class, u8 info_type,
+		       u32 additional_info, void **data, unsigned int *size);
+void SMB2_set_info_free(struct smb_rqst *rqst);
+int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
+		 u64 persistent_fid, u64 volatile_fid, struct smb_ntsd *pnntsd,
+		 int pacllen, int aclflag);
+int SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
+		u64 persistent_fid, u64 volatile_fid,
+		struct smb2_file_full_ea_info *buf, int len);
+int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
+			 u64 persistent_fid, u64 volatile_fid);
+int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
+		      const u64 persistent_fid, const u64 volatile_fid,
+		      __u8 oplock_level);
+int smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
+				__u64 volatile_fid);
+int smb2_handle_cancelled_mid(struct mid_q_entry *mid,
+			      struct TCP_Server_Info *server);
 void smb2_cancelled_close_fid(struct work_struct *work);
-extern int SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
-			 u64 persistent_file_id, u64 volatile_file_id,
-			 struct kstatfs *FSData);
-extern int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
-			 u64 persistent_file_id, u64 volatile_file_id, int lvl);
-extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
-		     const __u64 persist_fid, const __u64 volatile_fid,
-		     const __u32 pid, const __u64 length, const __u64 offset,
-		     const __u32 lockFlags, const bool wait);
-extern int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
-		      const __u64 persist_fid, const __u64 volatile_fid,
-		      const __u32 pid, const __u32 num_lock,
-		      struct smb2_lock_element *buf);
-extern int SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
-			    __u8 *lease_key, const __le32 lease_state);
-extern int smb3_validate_negotiate(const unsigned int, struct cifs_tcon *);
+int SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
+			  u64 persistent_fid, u64 volatile_fid,
+			  struct kstatfs *fsdata);
+int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
+		  u64 persistent_fid, u64 volatile_fid, int level);
+int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
+	      const __u64 persist_fid, const __u64 volatile_fid,
+	      const __u32 pid, const __u64 length, const __u64 offset,
+	      const __u32 lock_flags, const bool wait);
+int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
+	       const __u64 persist_fid, const __u64 volatile_fid,
+	       const __u32 pid, const __u32 num_lock,
+	       struct smb2_lock_element *buf);
+int SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
+		     __u8 *lease_key, const __le32 lease_state);
+int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon);
 
-extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
-					enum securityEnum);
-int smb2_parse_contexts(struct TCP_Server_Info *server,
-			struct kvec *rsp_iov,
-			__u16 *epoch,
-			char *lease_key, __u8 *oplock,
+enum securityEnum smb2_select_sectype(struct TCP_Server_Info *server,
+				      enum securityEnum requested);
+int smb2_parse_contexts(struct TCP_Server_Info *server, struct kvec *rsp_iov,
+			__u16 *epoch, char *lease_key, __u8 *oplock,
 			struct smb2_file_all_info *buf,
 			struct create_posix_rsp *posix);
 
-extern int smb3_encryption_required(const struct cifs_tcon *tcon);
-extern int smb2_validate_iov(unsigned int offset, unsigned int buffer_length,
-			     struct kvec *iov, unsigned int min_buf_size);
-extern int smb2_validate_and_copy_iov(unsigned int offset,
-				      unsigned int buffer_length,
-				      struct kvec *iov,
-				      unsigned int minbufsize, char *data);
-extern void smb2_copy_fs_info_to_kstatfs(
-	 struct smb2_fs_full_size_info *pfs_inf,
-	 struct kstatfs *kst);
-extern int smb3_crypto_shash_allocate(struct TCP_Server_Info *server);
-extern void smb311_update_preauth_hash(struct cifs_ses *ses,
-				       struct TCP_Server_Info *server,
-				       struct kvec *iov, int nvec);
-extern int smb2_query_info_compound(const unsigned int xid,
-				    struct cifs_tcon *tcon,
-				    const char *path, u32 desired_access,
-				    u32 class, u32 type, u32 output_len,
-				    struct kvec *rsp, int *buftype,
-				    struct cifs_sb_info *cifs_sb);
+int smb3_encryption_required(const struct cifs_tcon *tcon);
+int smb2_validate_iov(unsigned int offset, unsigned int buffer_length,
+		      struct kvec *iov, unsigned int min_buf_size);
+int smb2_validate_and_copy_iov(unsigned int offset, unsigned int buffer_length,
+			       struct kvec *iov, unsigned int minbufsize,
+			       char *data);
+void smb2_copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf,
+				  struct kstatfs *kst);
+int smb3_crypto_shash_allocate(struct TCP_Server_Info *server);
+void smb311_update_preauth_hash(struct cifs_ses *ses,
+				struct TCP_Server_Info *server,
+				struct kvec *iov, int nvec);
+int smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
+			     const char *path, u32 desired_access, u32 class,
+			     u32 type, u32 output_len, struct kvec *rsp,
+			     int *buftype, struct cifs_sb_info *cifs_sb);
 /* query path info from the server using SMB311 POSIX extensions*/
 int posix_info_parse(const void *beg, const void *end,
 		     struct smb2_posix_info_parsed *out);
 int posix_info_sid_size(const void *beg, const void *end);
-int smb2_rename_pending_delete(const char *full_path,
-			       struct dentry *dentry,
+int smb2_rename_pending_delete(const char *full_path, struct dentry *dentry,
 			       const unsigned int xid);
 
 #endif			/* _SMB2PROTO_H */
#17 lore raw

PATCH 17/37 cifs: Scripted clean up fs/smb/client/reparse.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/reparse.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
fs/smb/client/reparse.h +7 -6
index 19caab2fd11e..cfbb7dd28958 100644
@@ -130,11 +130,12 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
 				 struct cifs_fattr *fattr,
 				 struct cifs_open_info_data *data);
 int create_reparse_symlink(const unsigned int xid, struct inode *inode,
-				struct dentry *dentry, struct cifs_tcon *tcon,
-				const char *full_path, const char *symname);
-int mknod_reparse(unsigned int xid, struct inode *inode,
-		       struct dentry *dentry, struct cifs_tcon *tcon,
-		       const char *full_path, umode_t mode, dev_t dev);
-struct reparse_data_buffer *smb2_get_reparse_point_buffer(const struct kvec *rsp_iov, u32 *len);
+			   struct dentry *dentry, struct cifs_tcon *tcon,
+			   const char *full_path, const char *symname);
+int mknod_reparse(unsigned int xid, struct inode *inode, struct dentry *dentry,
+		  struct cifs_tcon *tcon, const char *full_path, umode_t mode,
+		  dev_t dev);
+struct reparse_data_buffer *smb2_get_reparse_point_buffer(const struct kvec *rsp_iov,
+							  u32 *plen);
 
 #endif /* _CIFS_REPARSE_H */
#18 lore raw

PATCH 18/37 cifs: Scripted clean up fs/smb/client/ntlmssp.h

In reply to David Howells

Remove externs, correct argument names and reformat declarations.

---
 fs/smb/client/ntlmssp.h | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
fs/smb/client/ntlmssp.h +8 -7
index a11fddc321f6..be0365f08396 100644
@@ -142,16 +142,17 @@ typedef struct _AUTHENTICATE_MESSAGE {
  * Size of the session key (crypto key encrypted with the password
  */
 
-int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
+int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
+			     struct cifs_ses *ses);
 int build_ntlmssp_negotiate_blob(unsigned char **pbuffer, u16 *buflen,
 				 struct cifs_ses *ses,
 				 struct TCP_Server_Info *server,
 				 const struct nls_table *nls_cp);
 int build_ntlmssp_smb3_negotiate_blob(unsigned char **pbuffer, u16 *buflen,
-				 struct cifs_ses *ses,
-				 struct TCP_Server_Info *server,
-				 const struct nls_table *nls_cp);
+				      struct cifs_ses *ses,
+				      struct TCP_Server_Info *server,
+				      const struct nls_table *nls_cp);
 int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
-			struct cifs_ses *ses,
-			struct TCP_Server_Info *server,
-			const struct nls_table *nls_cp);
+			    struct cifs_ses *ses,
+			    struct TCP_Server_Info *server,
+			    const struct nls_table *nls_cp);
#19 lore raw

PATCH 19/37 cifs: SMB1 split: Rename cifstransport.c

In reply to David Howells

Rename cifstransport.c to smb1transport.c in order to give consistent names SMB1-specific files.

---
 fs/smb/client/Makefile                             | 5 ++++-
 fs/smb/client/{cifstransport.c => smb1transport.c} | 0
 2 files changed, 4 insertions(+), 1 deletion(-)
 rename fs/smb/client/{cifstransport.c => smb1transport.c} (100%)
fs/smb/client/Makefile +4 -1
index 4c97b31a25c2..9754b4776df8 100644
@@ -32,6 +32,9 @@ cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o
 
 cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
 
-cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += smb1ops.o cifssmb.o cifstransport.o
+cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
+	cifssmb.o \
+	smb1ops.o \
+	smb1transport.o
 
 cifs-$(CONFIG_CIFS_COMPRESSION) += compress.o compress/lz77.o
fs/smb/client/smb1transport.c renamed from fs/smb/client/cifstransport.c +0 -0
similarity index 100%
rename from fs/smb/client/cifstransport.c
rename to fs/smb/client/smb1transport.c
#20 lore raw

PATCH 20/37 cifs: SMB1 split: Create smb1proto.h for SMB1 declarations

In reply to David Howells
---
 fs/smb/client/cifsglob.h  |  2 --
 fs/smb/client/cifsproto.h | 11 +----------
 fs/smb/client/smb1proto.h | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 12 deletions(-)
 create mode 100644 fs/smb/client/smb1proto.h
fs/smb/client/cifsglob.h +0 -2
index b0fefdd4f624..7001004ee106 100644
@@ -2120,8 +2120,6 @@ extern mempool_t cifs_io_subrequest_pool;
 
 /* Operations for different SMB versions */
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
-extern struct smb_version_operations smb1_operations;
-extern struct smb_version_values smb1_values;
 extern struct smb_version_operations smb20_operations;
 extern struct smb_version_values smb20_values;
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
fs/smb/client/cifsproto.h +1 -10
index 75a474f9e99a..6454c5847724 100644
@@ -14,6 +14,7 @@
 #ifdef CONFIG_CIFS_DFS_UPCALL
 #include "dfs_cache.h"
 #endif
+#include "smb1proto.h"
 
 struct statfs;
 struct smb_rqst;
@@ -404,16 +405,6 @@ int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
 		       struct cifsFileInfo *cfile, __u64 size,
 		       bool set_allocation);
 
-struct cifs_unix_set_info_args {
-	__u64	ctime;
-	__u64	atime;
-	__u64	mtime;
-	__u64	mode;
-	kuid_t	uid;
-	kgid_t	gid;
-	dev_t	device;
-};
-
 int CIFSSMBUnixSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 			   const struct cifs_unix_set_info_args *args, u16 fid,
 			   u32 pid_of_opener);
fs/smb/client/smb1proto.h new file +38 -0
new file mode 100644
index 000000000000..0088edbcc73f
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+/*
+ *
+ *   Copyright (c) International Business Machines  Corp., 2002,2008
+ *   Author(s): Steve French ([email protected])
+ *
+ */
+#ifndef _SMB1PROTO_H
+#define _SMB1PROTO_H
+
+#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
+
+struct cifs_unix_set_info_args {
+	__u64	ctime;
+	__u64	atime;
+	__u64	mtime;
+	__u64	mode;
+	kuid_t	uid;
+	kgid_t	gid;
+	dev_t	device;
+};
+
+/*
+ * cifssmb.c
+ */
+
+/*
+ * smb1ops.c
+ */
+extern struct smb_version_operations smb1_operations;
+extern struct smb_version_values smb1_values;
+
+/*
+ * smb1transport.c
+ */
+
+#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
+#endif /* _SMB1PROTO_H */
#21 lore raw

PATCH 21/37 cifs: SMB1 split: Separate out SMB1 decls into smb1proto.h

In reply to David Howells

Separate out SMB1 declarations scriptedly into smb1proto.h. Script below:

	#!/usr/bin/perl -w
	use strict;
	unless (@ARGV) {
	    die "Usage: $0 <c_file1> [<c_file2> ...]\n";
	}

	# Data tracking
	my %funcs = ();		# Func name => { func prototype }
	my %headers = ();	# Header filename => { header content }
	my %c_files = ();	# C filename => { ordered func list, header pref }
	my %cmarkers = ();	# C filename marker => { header filename it's in }

	# Parse state
	my $pathname = "-";
	my $lineno = 0;

	sub error(@) {
	    print STDERR $pathname, ":", $lineno, ": ", @_, "\n";
	    exit(1);
	}

	sub pad($) {
	    # Reindent the function arguments to line the arguments up with the char
	    # after the opening bracket on the func argument list
	    my ($lines) = @_;
	    return $lines if ($#{$lines} <= 0);
	    my $has_empty = 0;
	    for (my $i = 0; $i <= $#{$lines}; $i++) {
		$lines->[$i] =~ s/^[ \t]+//;
		$has_empty = 1 if ($lines->[$i] eq "");
	    }

	    if ($has_empty) {
		my @clean = grep /.+/, @{$lines};
		$lines = \@clean;
	    }

	    my $indlen = index($lines->[0], "(");
	    return $lines if ($indlen < 0);
	    my $indent = "";
	    $indlen++;
	    $indent .= "\t" x ($indlen / 8);
	    $indent .= " " x ($indlen % 8);

	    my @padded = ();
	    my $acc = "";
	    my $len = -$indlen;
	    for (my $i = 0; $i <= $#{$lines}; $i++) {
		my $argument = $lines->[$i];
		my $arglen = length($argument);
		my $last = ($i == $#{$lines} ? 1 : 0);

		if ($i == 0 ||
		    $i == 1) {
		    $acc .= $argument;
		    $acc .= ";" if ($last);
		    $len += $arglen + $last;
		    next;
		}
		if (!$acc) {
		    $acc = $indent . $argument;
		    $acc .= ";" if ($last);
		    $len += $arglen + $last;
		    next;
		}
		if ($indlen + $len + 1 + $arglen + $last > 79) {
		    push @padded, $acc;
		    $acc = $indent . $argument;
		    $acc .= ";" if ($last);
		    $len = $arglen + $last;
		    next;
		}

		$acc .= " " . $argument;
		$acc .= ";" if ($last);
		$len += 1 + $arglen + $last;
	    }
	    push @padded, $acc if ($acc);
	    return \@padded;
	}

	sub earliest(@) {
	    my $ret = -1;
	    foreach (@_) {
		$ret = $_ if ($ret < 0 || ($_ >= 0 && $_ < $ret));
	    }
	    return $ret;
	}

	foreach my $file (@ARGV) {
	    # Open the file for reading.
	    next if $file =~ /trace[.]h$/;
	    next if $file =~ /smbdirect[.][ch]$/;
	    open my $fh, "<$file"
		or die "Could not open file '$file'";
	    $pathname = $file;
	    $lineno = 0;

	    my $filename;
	    my @file_content = ();
	    my @copy = ();

	    my $state = 0;
	    my $qual = "";
	    my $type = "";
	    my $funcname = "";
	    my @funcdef = ();
	    my $bracket = 0;
	    my $comment = 0;
	    my $smb1 = 0;
	    my $header = 0;
	    my $inline = 0;
	    my $file_marker = "";
	    my $config = "";
	    my $c_file = 0;

	    $filename = $pathname;
	    $filename =~ s!.*/!!;

	    if ($file =~ m!.h$!) {
		my %new_h_file = (
		    path    => $pathname,
		    fname   => $filename,
		    content => [],
		    );
		$header = \%new_h_file;
		$headers{$filename} = \%new_h_file;
	    } elsif ($file =~ m!.c$!) {
		my %new_c_file = (
		    path  => $pathname,
		    fname => $filename,
		    funcs => [],
		    );
		$c_file = \%new_c_file;
		$c_files{$filename} = \%new_c_file;
	    } else {
		warn("Ignoring unexpected file $file\n");
		next;
	    }

	    $smb1 = 1 if ($file =~ m!/smb1ops.c|/cifssmb.c|/cifstransport.c!);

	    foreach my $line (<$fh>) {
		$lineno++;
		chomp($line);
		push @copy, $line;
		if (!$line) {
		    # Blank line
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Handle continuation or end of block comment.  Look for C file
		# prototype insertion point markers.
		if ($comment) {
		    if ($line =~ m![*]/!) {
			if ($comment == 2 && $file_marker) {
			    $cmarkers{$file_marker} = $file_marker;
			    push @copy, "#C_MARKER " . $file_marker;
			    $file_marker = 0;
			}
			$comment = 0;
		    } else {
			$comment++;
			if ($comment == 2 && $line =~ m! [*] ([a-z][a-z_0-9]*[.][c])$!) {
			    $file_marker = $1;
			    print("Found file marker ", $file_marker, " in ", $filename, "\n");
			}
		    }
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Check cpp directives, particularly looking for SMB1 bits
		if ($line =~ /^[#]/) {
		    if ($header) {
			if ($line =~ /ifdef.*(CONFIG_[A-Z0-9_])/) {
			    error("multiconfig") if $config;
			    $config = $1;
			    $smb1++ if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
			} elsif ($line =~ /endif/) {
			    $smb1-- if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
			    $config = "";
			}
		    }
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Exclude interference in finding func names and return types
		if ($line =~ /^[{]/ ||
		    $line =~ /##/ ||
		    $line =~ /^[_a-z0-9A-Z]+:$/ || # goto label
		    $line =~ /^do [{]/ ||
		    $line =~ m!^//!) {
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Start of a block comment
		if ($line =~ m!^/[*]!) {
		    $comment = 1 unless ($line =~ m![*]/!);
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# End of a braced section, such as a function implementation
		if ($line =~ /^[}]/) {
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = ();
			push @file_content, @copy;
			@copy = ();
			next;
		}

		if ($line =~ /^typedef/) {
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    @funcdef = ();
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Extract function qualifiers.  There may be multiple of these in more
		# or less any order.  Some of them cause the func to be skipped (e.g. inline).

		if ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
		    $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
		    error("Unexpected qualifier '$1'") if ($state != 0);
		    while ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
			   $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
			$qual .= " " if ($qual);
			$qual .= $1;
			$inline = 1 if ($1 eq "inline");
			$inline = 1 if ($1 eq "__always_inline");
			$line = substr($line, length($1));
			$line =~ s/^\s+//;
		    }
		}

		if ($state == 0) {
		    # Extract what we assume to be the return type
		    if ($line =~ /^\s/) {
			push @file_content, @copy;
			@copy = ();
			next;
		    }
		    while ($line =~ /^(unsigned|signed|bool|char|short|int|long|void|const|volatile|(struct|union|enum)\s+[_a-zA-Z][_a-zA-Z0-9]*|[*]|__init|__exit|__le16|__le32|__le64|__be16|__be32|__be64)/) {
			$type .= " " if $type;
			$type .= $1;
			$line = substr($line, length($1));
			$line =~ s/^\s+//;
		    }
		    if ($line =~ /^struct [{]/) {
			# Ignore structure definitions
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = ();
			push @file_content, @copy;
			@copy = ();
			next;
		    }
		    if (index($line, "=") >= 0) {
			# Ignore assignments
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = "";
			push @file_content, @copy;
			@copy = ();
			next;
		    }

		    # Try and extract a function's type and name
		    while ($line =~ /(^[_a-zA-Z][_a-zA-Z0-9]*)/) {
			my $name = $1;
			$line = substr($line, length($name));
			next if ($line =~ /^[{]/);
			$line =~ s/^\s+//;

			my $ch = substr($line, 0, 1);
			last if ($ch eq "[" || $ch eq ";"); # Global variables

			if ($ch eq "(") {
			    # Found the function name
			    $state = 1;
			    $line = substr($line, 1);
			    $funcname = $name;
			    my $tmp = $qual . $type . " " . $funcname . "(";
			    $tmp =~ s/[*] /*/;
			    push @funcdef, $tmp;
			    $bracket = 1;
			    last;
			}

			if ($type) {
			    last if (index($line, ";") >= 0 && index($line, "(") == -1);
			    error("Unexpected name '$name' after '$type'");
			}

			$type .= " " if $type;
			$type .= $name;
			if ($line =~ /^(\s*[*]+)/) {
			    my $ptr = $1;
			    $type .= $ptr;
			    $line = substr($line, length($ptr));
			}
		    }
		}

		# Try and extract a function's argument list
		my $from = 0;
		if ($state == 1) {
		    while (1) {
			my $o = index($line, "(", $from);
			my $c = index($line, ")", $from);
			my $m = index($line, ",", $from);

			my $b = earliest($o, $c, $m);
			if ($b < 0) {
			    push @funcdef, $line
				unless ($line eq "");
			    last;
			}
			my $ch = substr($line, $b, 1);

			# Push the arguments separately on to the list
			if ($ch eq ",") {
			    push @funcdef, substr($line, 0, $b + 1);
			    $line = substr($line, $b + 1);
			    $from = 0;
			} elsif ($ch eq "(") {
			    # Handle brackets in the argument list (e.g. function
			    # pointers)
			    $bracket++;
			    $from = $b + 1;
			} elsif ($ch eq ")") {
			    $bracket--;
			    if ($bracket == 0) {
				push @funcdef, substr($line, 0, $b + 1);
				$line = substr($line, $b + 1);
				$state = 2;
				last;
			    }
			    $from = $b + 1;
			}
		    }
		}

		if ($state == 2) {
		    $inline = 1 if ($qual =~ /inline/);
		    #print("QUAL $qual $type $funcname $inline ", $#funcdef, "\n");
		    if (!$header &&
			$qual !~ /static/ &&
			$funcname ne "__acquires" &&
			$funcname ne "__releases" &&
			$funcname ne "module_init" &&
			$funcname ne "module_exit" &&
			$funcname ne "module_param" &&
			$funcname ne "module_param_call" &&
			$funcname ne "PROC_FILE_DEFINE" &&
			$funcname !~ /MODULE_/ &&
			$funcname !~ /DEFINE_/) {

			# Okay, we appear to have a function implementation
			my $func;
			my $dup = 0;

			if (exists($funcs{$funcname})) {
			    $func = $funcs{$funcname};
			    if (exists $func->{body}) {
				print("dup $funcname\n");
				$dup = 1;
			    }
			} else {
			    my %new_func = (
				name => $funcname,
				cond => "",
				legacy => 0,
				);
			    $func = \%new_func;
			    $funcs{$funcname} = $func;
			    $func->{body} = pad(\@funcdef);
			}
			$func->{body} = pad(\@funcdef);
			$func->{legacy} = 1 if $smb1;

			if ($funcname eq "cifs_inval_name_dfs_link_error") {
			    $func->{cond} = "#ifdef CONFIG_CIFS_DFS_UPCALL";
			} elsif ($funcname eq "cifs_listxattr") {
			    $func->{cond} = "#ifdef CONFIG_CIFS_XATTR";
			}

			push @{$c_file->{funcs}}, $func
			    unless $dup;
		    } elsif (!$header || $inline) {
			# Ignore inline function implementations and other weirdies
			push @file_content, @copy;
		    } elsif ($header && !$inline) {
			push @file_content, "#FUNCPROTO " . $funcname;

			my $func;

			if (exists($funcs{$funcname})) {
			    $func = $funcs{$funcname};
			    $func->{lineno} = $lineno;
			    $func->{pathname} = $pathname;
			} else {
			    my %new_func = (
				name => $funcname,
				cond => "",
				lineno => $lineno,
				pathname => $pathname,
				legacy => 0,
				);
			    $func = \%new_func;
			    $funcs{$funcname} = $func;
			}

			$func->{legacy} = 1 if $smb1;
		    }

		    @funcdef = ();
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    $inline = 0;
		    $state = 0;
		    @copy = ();
		}
		if ($line =~ /;/) {
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    @funcdef = ();
		    $state = 0;
		    push @file_content, @copy;
		    @copy = ();
		}
	    }
	    close($fh);

	    if ($header) {
		$header->{content} = \@file_content;
	    }
	}

	sub write_header($)
	{
	    my ($header) = @_;
	    my $path = $header->{path};
	    my $legacy = 0;

	    $legacy = 1 if ($path =~ m!smb1proto[.]h!);

	    my @output = ();

	    foreach my $line (@{$header->{content}}) {
		if ($line =~ "^[#]C_MARKER (.*)") {
		    my $file_marker = $cmarkers{$1};
		    my $c_file = $c_files{$file_marker};
		    print("Found $line\n");
		    foreach my $func (@{$c_file->{funcs}}) {
			print("func ", $func->{name}, "\n");
			push @output, @{$func->{body}};
		    }
		    next;
		} elsif ($line =~ "^[#]FUNCPROTO ([_a-zA-Z0-9]+)") {
		    my $funcname = $1;
		    my $func = $funcs{$funcname};
		    if (!$func->{body}) {
			print($func->{pathname}, ":", $func->{lineno}, ": '", $funcname,
			      "' dead prototype\n");
			next;
		    }
		    if ($func->{legacy} == $legacy) {
			#push @output, $line;
			push @output, @{$func->{body}};
		    }
		} else {
		    push @output, $line;
		}
	    }

	    open my $fh, ">$path"
		or die "Could not open file '$path' for writing";
	    foreach my $f (@output) {
		print($fh $f, "\n") or die $path;
	    }
	    close($fh) or die $path;
	}

	foreach my $h (keys(%headers)) {
	    write_header($headers{$h});
	}
---
 fs/smb/client/cifsproto.h | 226 +++-----------------------------------
 fs/smb/client/fscache.h   |   5 +
 fs/smb/client/smb1proto.h | 201 +++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+), 213 deletions(-)
fs/smb/client/cifsproto.h +13 -213
index 6454c5847724..b151796b3ba5 100644
@@ -105,23 +105,10 @@ int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
 		       struct TCP_Server_Info *server, const int flags,
 		       const int num_rqst, struct smb_rqst *rqst,
 		       int *resp_buf_type, struct kvec *resp_iov);
-int SendReceive(const unsigned int xid, struct cifs_ses *ses,
-		struct smb_hdr *in_buf, unsigned int in_len,
-		struct smb_hdr *out_buf, int *pbytes_returned,
-		const int flags);
-int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
-		     char *in_buf, unsigned int in_len, int flags);
 int cifs_sync_mid_result(struct mid_q_entry *mid,
 			 struct TCP_Server_Info *server);
-struct mid_q_entry *cifs_setup_request(struct cifs_ses *ses,
-				       struct TCP_Server_Info *server,
-				       struct smb_rqst *rqst);
-struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *server,
-					     struct smb_rqst *rqst);
 int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 		    struct smb_rqst *rqst);
-int cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
-		       bool log_error);
 int wait_for_free_request(struct TCP_Server_Info *server, const int flags,
 			  unsigned int *instance);
 int cifs_wait_mtu_credits(struct TCP_Server_Info *server, size_t size,
@@ -137,9 +124,6 @@ send_cancel(struct cifs_ses *ses, struct TCP_Server_Info *server,
 }
 
 int wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *mid);
-int SendReceive2(const unsigned int xid, struct cifs_ses *ses,
-		 struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
-		 const int flags, struct kvec *resp_iov);
 
 void smb2_query_server_interfaces(struct work_struct *work);
 void cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
@@ -178,8 +162,6 @@ int map_and_check_smb_error(struct TCP_Server_Info *server,
 unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
 			     const struct cifs_tcon *treeCon, int word_count
 			     /* length of fixed section (word count) in two byte units  */);
-int small_smb_init_no_tc(const int smb_command, const int wct,
-			 struct cifs_ses *ses, void **request_buf);
 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
 		   struct TCP_Server_Info *server,
 		   const struct nls_table *nls_cp);
@@ -321,46 +303,15 @@ int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
 		       struct nls_table *nls_info);
 int cifs_enable_signing(struct TCP_Server_Info *server,
 			bool mnt_sign_required);
-int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses,
-		     struct TCP_Server_Info *server);
 
 int CIFSTCon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 	     struct cifs_tcon *tcon, const struct nls_table *nls_codepage);
 
-int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
-		  const char *searchName, struct cifs_sb_info *cifs_sb,
-		  __u16 *pnetfid, __u16 search_flags,
-		  struct cifs_search_info *psrch_inf, bool msearch);
-
-int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
-		 __u16 searchHandle, __u16 search_flags,
-		 struct cifs_search_info *psrch_inf);
-
-int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
-		  const __u16 searchHandle);
-
-int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		     u16 netfid, FILE_ALL_INFO *pFindData);
-int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		     const char *search_name, FILE_ALL_INFO *data,
-		     int legacy /* old style infolevel */,
-		     const struct nls_table *nls_codepage, int remap);
-int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
-			const char *search_name, FILE_ALL_INFO *data,
-			const struct nls_table *nls_codepage, int remap);
-
-int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
-int CIFSSMBUnixQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			 const unsigned char *searchName,
-			 FILE_UNIX_BASIC_INFO *pFindData,
-			 const struct nls_table *nls_codepage, int remap);
-
-int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
-		    const char *search_name,
-		    struct dfs_info3_param **target_nodes,
-		    unsigned int *num_of_nodes,
-		    const struct nls_table *nls_codepage, int remap);
+
+
+
+
+
 
 int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
 			unsigned int *num_of_nodes,
@@ -370,138 +321,14 @@ int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
 void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
 			  struct cifs_sb_info *cifs_sb,
 			  struct smb3_fs_context *ctx);
-int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		   struct kstatfs *FSData);
-int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		  struct kstatfs *FSData);
-int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			 __u64 cap);
-
-int CIFSSMBQFSAttributeInfo(const unsigned int xid, struct cifs_tcon *tcon);
-int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
-int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
-int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			struct kstatfs *FSData);
-
-int SMBSetInformation(const unsigned int xid, struct cifs_tcon *tcon,
-		      const char *fileName, __le32 attributes,
-		      __le64 write_time, const struct nls_table *nls_codepage,
-		      struct cifs_sb_info *cifs_sb);
-int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		       const char *fileName, const FILE_BASIC_INFO *data,
-		       const struct nls_table *nls_codepage,
-		       struct cifs_sb_info *cifs_sb);
-int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-		       const FILE_BASIC_INFO *data, __u16 fid,
-		       __u32 pid_of_opener);
-int CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
-			      bool delete_file, __u16 fid,
-			      __u32 pid_of_opener);
-int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
-		  const char *file_name, __u64 size,
-		  struct cifs_sb_info *cifs_sb, bool set_allocation,
-		  struct dentry *dentry);
-int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
-		       struct cifsFileInfo *cfile, __u64 size,
-		       bool set_allocation);
-
-int CIFSSMBUnixSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			   const struct cifs_unix_set_info_args *args, u16 fid,
-			   u32 pid_of_opener);
-
-int CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
-			   const char *file_name,
-			   const struct cifs_unix_set_info_args *args,
-			   const struct nls_table *nls_codepage, int remap);
-
-int CIFSSMBMkDir(const unsigned int xid, struct inode *inode, umode_t mode,
-		 struct cifs_tcon *tcon, const char *name,
-		 struct cifs_sb_info *cifs_sb);
-int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
-		 const char *name, struct cifs_sb_info *cifs_sb);
-int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
-		     const char *fileName, __u16 type,
-		     const struct nls_table *nls_codepage, int remap);
-int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
-		   const char *name, struct cifs_sb_info *cifs_sb,
-		   struct dentry *dentry);
-int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
-		  struct dentry *source_dentry, const char *from_name,
-		  const char *to_name, struct cifs_sb_info *cifs_sb);
-int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *pTcon,
-			  int netfid, const char *target_name,
-			  const struct nls_table *nls_codepage, int remap);
-int CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
-		       struct dentry *source_dentry, const char *from_name,
-		       const char *to_name, struct cifs_sb_info *cifs_sb);
-int CIFSUnixCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
-			   const char *fromName, const char *toName,
-			   const struct nls_table *nls_codepage, int remap);
-int CIFSUnixCreateSymLink(const unsigned int xid, struct cifs_tcon *tcon,
-			  const char *fromName, const char *toName,
-			  const struct nls_table *nls_codepage, int remap);
-int CIFSSMBUnixQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
-			    const unsigned char *searchName,
-			    char **symlinkinfo,
-			    const struct nls_table *nls_codepage, int remap);
-int cifs_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon,
-			     struct cifs_sb_info *cifs_sb,
-			     const char *full_path, u32 *tag, struct kvec *rsp,
-			     int *rsp_buftype);
-struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data,
-					struct super_block *sb,
-					const unsigned int xid,
-					struct cifs_tcon *tcon,
-					const char *full_path, bool directory,
-					struct kvec *reparse_iov,
-					struct kvec *xattr_iov);
-int CIFSSMB_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
-			    __u16 fid);
-int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
-	      int *oplock, FILE_ALL_INFO *buf);
-int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
-		  const char *fileName, const int openDisposition,
-		  const int access_flags, const int create_options,
-		  __u16 *netfid, int *pOplock, FILE_ALL_INFO *pfile_info,
-		  const struct nls_table *nls_codepage, int remap);
-int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
-		    __u32 posix_flags, __u64 mode, __u16 *netfid,
-		    FILE_UNIX_BASIC_INFO *pRetData, __u32 *pOplock,
-		    const char *name, const struct nls_table *nls_codepage,
-		    int remap);
-int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
-		 int smb_file_id);
-
-int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
-		 int smb_file_id);
-
-int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
-		unsigned int *nbytes, char **buf, int *pbuf_type);
-int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
-		 unsigned int *nbytes, const char *buf);
-int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
-		  unsigned int *nbytes, struct kvec *iov, int n_vec);
-int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
-			  const char *search_name, __u64 *inode_number,
-			  const struct nls_table *nls_codepage, int remap);
-
-int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
-	       const __u16 netfid, const __u8 lock_type,
-	       const __u32 num_unlock, const __u32 num_lock,
-	       LOCKING_ANDX_RANGE *buf);
-int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
-		const __u16 smb_file_id, const __u32 netpid, const __u64 len,
-		const __u64 offset, const __u32 numUnlock, const __u32 numLock,
-		const __u8 lockType, const bool waitFlag,
-		const __u8 oplock_level);
-int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
-		     const __u16 smb_file_id, const __u32 netpid,
-		     const loff_t start_offset, const __u64 len,
-		     struct file_lock *pLockData, const __u16 lock_type,
-		     const bool waitFlag);
-int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
-int CIFSSMBEcho(struct TCP_Server_Info *server);
-int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
+
+
+
+
+
+
+
+
 
 struct cifs_ses *sesInfoAlloc(void);
 void sesInfoFree(struct cifs_ses *buf_to_free);
@@ -523,31 +350,6 @@ int generate_smb311signingkey(struct cifs_ses *ses,
 			      struct TCP_Server_Info *server);
 
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
-ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
-		       const unsigned char *searchName,
-		       const unsigned char *ea_name, char *EAData,
-		       size_t buf_size, struct cifs_sb_info *cifs_sb);
-int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
-		 const char *fileName, const char *ea_name,
-		 const void *ea_value, const __u16 ea_value_len,
-		 const struct nls_table *nls_codepage,
-		 struct cifs_sb_info *cifs_sb);
-int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
-		      __u16 fid, struct smb_ntsd **acl_inf, __u32 *pbuflen,
-		      __u32 info);
-int CIFSSMBSetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
-		      __u16 fid, struct smb_ntsd *pntsd, __u32 acllen,
-		      int aclflag);
-int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,
-		    const unsigned char *searchName, struct posix_acl **acl,
-		    const int acl_type, const struct nls_table *nls_codepage,
-		    int remap);
-int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
-		    const unsigned char *fileName, const struct posix_acl *acl,
-		    const int acl_type, const struct nls_table *nls_codepage,
-		    int remap);
-int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
-		   const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
 void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
 bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
@@ -566,11 +368,9 @@ void __cifs_put_smb_ses(struct cifs_ses *ses);
 struct cifs_ses *cifs_get_smb_ses(struct TCP_Server_Info *server,
 				  struct smb3_fs_context *ctx);
 
-int cifs_async_readv(struct cifs_io_subrequest *rdata);
 int cifs_readv_receive(struct TCP_Server_Info *server,
 		       struct mid_q_entry *mid);
 
-void cifs_async_writev(struct cifs_io_subrequest *wdata);
 int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 			  struct cifs_sb_info *cifs_sb,
 			  const unsigned char *path, char *pbuf,
fs/smb/client/fscache.h +5 -0
index b6c94db5edb9..3521222886c1 100644
@@ -40,6 +40,11 @@ struct cifs_fscache_inode_coherency_data {
  */
 int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon);
 void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon);
+void cifs_fscache_get_inode_cookie(struct inode *inode);
+void cifs_fscache_unuse_inode_cookie(struct inode *inode, bool update);
+void cifs_fscache_release_inode_cookie(struct inode *inode);
+int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon);
+void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon);
 
 void cifs_fscache_get_inode_cookie(struct inode *inode);
 void cifs_fscache_release_inode_cookie(struct inode *inode);
fs/smb/client/smb1proto.h +201 -0

213 lines not on this page · raw message

#22 lore raw

PATCH 22/37 cifs: SMB1 split: Move some SMB1 receive bits to smb1transport.c

In reply to David Howells

Move some SMB1 receive bits to smb1transport.c from smb1ops.c where they're mixed in with unrelated code to do with encoding, decoding and processing PDUs.

---
 fs/smb/client/smb1ops.c       | 171 ----------------------------------
 fs/smb/client/smb1proto.h     |   2 +
 fs/smb/client/smb1transport.c | 171 ++++++++++++++++++++++++++++++++++
 3 files changed, 173 insertions(+), 171 deletions(-)
fs/smb/client/smb1ops.c +0 -171
index 9729b56bd9d4..2534113596c7 100644
@@ -284,146 +284,6 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
 	return mid;
 }
 
-/*
-	return codes:
-		0	not a transact2, or all data present
-		>0	transact2 with that much data missing
-		-EINVAL	invalid transact2
- */
-static int
-check2ndT2(char *buf)
-{
-	struct smb_hdr *pSMB = (struct smb_hdr *)buf;
-	struct smb_t2_rsp *pSMBt;
-	int remaining;
-	__u16 total_data_size, data_in_this_rsp;
-
-	if (pSMB->Command != SMB_COM_TRANSACTION2)
-		return 0;
-
-	/* check for plausible wct, bcc and t2 data and parm sizes */
-	/* check for parm and data offset going beyond end of smb */
-	if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
-		cifs_dbg(FYI, "Invalid transact2 word count\n");
-		return -EINVAL;
-	}
-
-	pSMBt = (struct smb_t2_rsp *)pSMB;
-
-	total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
-	data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
-
-	if (total_data_size == data_in_this_rsp)
-		return 0;
-	else if (total_data_size < data_in_this_rsp) {
-		cifs_dbg(FYI, "total data %d smaller than data in frame %d\n",
-			 total_data_size, data_in_this_rsp);
-		return -EINVAL;
-	}
-
-	remaining = total_data_size - data_in_this_rsp;
-
-	cifs_dbg(FYI, "missing %d bytes from transact2, check next response\n",
-		 remaining);
-	if (total_data_size > CIFSMaxBufSize) {
-		cifs_dbg(VFS, "TotalDataSize %d is over maximum buffer %d\n",
-			 total_data_size, CIFSMaxBufSize);
-		return -EINVAL;
-	}
-	return remaining;
-}
-
-static int
-coalesce_t2(char *second_buf, struct smb_hdr *target_hdr, unsigned int *pdu_len)
-{
-	struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf;
-	struct smb_t2_rsp *pSMBt  = (struct smb_t2_rsp *)target_hdr;
-	char *data_area_of_tgt;
-	char *data_area_of_src;
-	int remaining;
-	unsigned int byte_count, total_in_tgt;
-	__u16 tgt_total_cnt, src_total_cnt, total_in_src;
-
-	src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount);
-	tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
-
-	if (tgt_total_cnt != src_total_cnt)
-		cifs_dbg(FYI, "total data count of primary and secondary t2 differ source=%hu target=%hu\n",
-			 src_total_cnt, tgt_total_cnt);
-
-	total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
-
-	remaining = tgt_total_cnt - total_in_tgt;
-
-	if (remaining < 0) {
-		cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n",
-			 tgt_total_cnt, total_in_tgt);
-		return -EPROTO;
-	}
-
-	if (remaining == 0) {
-		/* nothing to do, ignore */
-		cifs_dbg(FYI, "no more data remains\n");
-		return 0;
-	}
-
-	total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
-	if (remaining < total_in_src)
-		cifs_dbg(FYI, "transact2 2nd response contains too much data\n");
-
-	/* find end of first SMB data area */
-	data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
-				get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
-
-	/* validate target area */
-	data_area_of_src = (char *)&pSMBs->hdr.Protocol +
-				get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
-
-	data_area_of_tgt += total_in_tgt;
-
-	total_in_tgt += total_in_src;
-	/* is the result too big for the field? */
-	if (total_in_tgt > USHRT_MAX) {
-		cifs_dbg(FYI, "coalesced DataCount too large (%u)\n",
-			 total_in_tgt);
-		return -EPROTO;
-	}
-	put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount);
-
-	/* fix up the BCC */
-	byte_count = get_bcc(target_hdr);
-	byte_count += total_in_src;
-	/* is the result too big for the field? */
-	if (byte_count > USHRT_MAX) {
-		cifs_dbg(FYI, "coalesced BCC too large (%u)\n", byte_count);
-		return -EPROTO;
-	}
-	put_bcc(byte_count, target_hdr);
-
-	byte_count = *pdu_len;
-	byte_count += total_in_src;
-	/* don't allow buffer to overflow */
-	if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
-		cifs_dbg(FYI, "coalesced BCC exceeds buffer size (%u)\n",
-			 byte_count);
-		return -ENOBUFS;
-	}
-	*pdu_len = byte_count;
-
-	/* copy second buffer into end of first buffer */
-	memcpy(data_area_of_tgt, data_area_of_src, total_in_src);
-
-	if (remaining != total_in_src) {
-		/* more responses to go */
-		cifs_dbg(FYI, "waiting for more secondary responses\n");
-		return 1;
-	}
-
-	/* we are done */
-	cifs_dbg(FYI, "found the last secondary response\n");
-	return 0;
-}
-
 static void
 cifs_downgrade_oplock(struct TCP_Server_Info *server,
 		      struct cifsInodeInfo *cinode, __u32 oplock,
@@ -432,37 +292,6 @@ cifs_downgrade_oplock(struct TCP_Server_Info *server,
 	cifs_set_oplock_level(cinode, oplock);
 }
 
-static bool
-cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
-		  char *buf, int malformed)
-{
-	if (malformed)
-		return false;
-	if (check2ndT2(buf) <= 0)
-		return false;
-	mid->multiRsp = true;
-	if (mid->resp_buf) {
-		/* merge response - fix up 1st*/
-		malformed = coalesce_t2(buf, mid->resp_buf, &mid->response_pdu_len);
-		if (malformed > 0)
-			return true;
-		/* All parts received or packet is malformed. */
-		mid->multiEnd = true;
-		dequeue_mid(server, mid, malformed);
-		return true;
-	}
-	if (!server->large_buf) {
-		/*FIXME: switch to already allocated largebuf?*/
-		cifs_dbg(VFS, "1st trans2 resp needs bigbuf\n");
-	} else {
-		/* Have first buffer */
-		mid->resp_buf = buf;
-		mid->large_buf = true;
-		server->bigbuf = NULL;
-	}
-	return true;
-}
-
 static bool
 cifs_need_neg(struct TCP_Server_Info *server)
 {
fs/smb/client/smb1proto.h +2 -0
index 1fd4fd0bbb7a..bf24974fbb00 100644
@@ -233,6 +233,8 @@ int SendReceive(const unsigned int xid, struct cifs_ses *ses,
 		struct smb_hdr *in_buf, unsigned int in_len,
 		struct smb_hdr *out_buf, int *pbytes_returned,
 		const int flags);
+bool cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
+		       char *buf, int malformed);
 
 
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
fs/smb/client/smb1transport.c +171 -0

174 lines not on this page · raw message

#23 lore raw

PATCH 23/37 cifs: SMB1 split: Move some SMB1 received PDU checking bits to smb1transport.c

In reply to David Howells

Move some SMB1 received checking bits to smb1transport.c from misc.c so that they're with the rest of the receive handling code.

---
 fs/smb/client/cifsproto.h     |   2 -
 fs/smb/client/misc.c          | 126 ----------------------------------
 fs/smb/client/smb1proto.h     |   2 +
 fs/smb/client/smb1transport.c | 126 ++++++++++++++++++++++++++++++++++
 4 files changed, 128 insertions(+), 128 deletions(-)
fs/smb/client/cifsproto.h +0 -2
index b151796b3ba5..53d23958b9da 100644
@@ -131,8 +131,6 @@ void cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
 void cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
 					   bool mark_smb_session);
 int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session);
-int checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
-	     struct TCP_Server_Info *server);
 bool is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv);
 bool backup_cred(struct cifs_sb_info *cifs_sb);
 bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file,
fs/smb/client/misc.c +0 -126

132 lines not on this page · raw message

fs/smb/client/smb1proto.h +2 -0
index bf24974fbb00..c73cc10dfcc8 100644
@@ -235,6 +235,8 @@ int SendReceive(const unsigned int xid, struct cifs_ses *ses,
 		const int flags);
 bool cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 		       char *buf, int malformed);
+int checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
+	     struct TCP_Server_Info *server);
 
 
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
fs/smb/client/smb1transport.c +126 -0

129 lines not on this page · raw message

#24 lore raw

PATCH 24/37 cifs: SMB1 split: Add some #includes

In reply to David Howells

Add some #includes to make sure things continue to compile as splitting occurs.

---
 fs/smb/client/cifssmb.c       | 5 +++--
 fs/smb/client/smb1transport.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
fs/smb/client/cifssmb.c +3 -2
index 3db1a892c526..478dddc902a3 100644
@@ -26,11 +26,12 @@
 #include <linux/uaccess.h>
 #include <linux/netfs.h>
 #include <trace/events/netfs.h>
+#include "cifsglob.h"
+#include "cifsproto.h"
+#include "../common/smbfsctl.h"
 #include "cifspdu.h"
 #include "cifsfs.h"
-#include "cifsglob.h"
 #include "cifsacl.h"
-#include "cifsproto.h"
 #include "cifs_unicode.h"
 #include "cifs_debug.h"
 #include "fscache.h"
fs/smb/client/smb1transport.c +2 -2
index 5e508b2c661f..7154522c471c 100644
@@ -22,13 +22,13 @@
 #include <linux/mempool.h>
 #include <linux/sched/signal.h>
 #include <linux/task_io_accounting_ops.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
-#include "cifs_debug.h"
+#include "cifspdu.h"
 #include "smb2proto.h"
 #include "smbdirect.h"
 #include "compress.h"
+#include "cifs_debug.h"
 
 /* Max number of iovectors we can use off the stack when sending requests. */
 #define CIFS_MAX_IOV_SIZE 8
#25 lore raw

PATCH 25/37 cifs: SMB1 split: Split SMB1 protocol defs into smb1pdu.h

In reply to David Howells

Split SMB1 protocol defs into smb1pdu.h. This should perhaps go in the common/ directory.

---
 fs/smb/client/cifs_debug.c    |    1 -
 fs/smb/client/cifsfs.c        |    1 -
 fs/smb/client/cifsglob.h      |    1 +
 fs/smb/client/cifspdu.h       | 2343 +-------------------------------
 fs/smb/client/cifssmb.c       |    2 +-
 fs/smb/client/connect.c       |    1 -
 fs/smb/client/dir.c           |    1 -
 fs/smb/client/file.c          |    1 -
 fs/smb/client/fs_context.c    |    1 -
 fs/smb/client/inode.c         |    1 -
 fs/smb/client/ioctl.c         |    1 -
 fs/smb/client/link.c          |    1 -
 fs/smb/client/misc.c          |    1 -
 fs/smb/client/netmisc.c       |    1 -
 fs/smb/client/readdir.c       |    1 -
 fs/smb/client/reparse.h       |    1 +
 fs/smb/client/sess.c          |    1 -
 fs/smb/client/smb1ops.c       |    1 -
 fs/smb/client/smb1pdu.h       | 2354 +++++++++++++++++++++++++++++++++
 fs/smb/client/smb1transport.c |    3 +-
 fs/smb/client/smb2file.c      |    1 +
 fs/smb/client/smb2inode.c     |    1 +
 fs/smb/client/smb2pdu.c       |    1 +
 23 files changed, 2363 insertions(+), 2358 deletions(-)
 create mode 100644 fs/smb/client/smb1pdu.h
fs/smb/client/cifs_debug.c +0 -1
index b188bf38ff9d..98136547ea5f 100644
@@ -13,7 +13,6 @@
 #include <linux/proc_fs.h>
 #include <linux/uaccess.h>
 #include <uapi/linux/ethtool.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/cifsfs.c +0 -1
index d9664634144d..99f84f7e81a5 100644
@@ -33,7 +33,6 @@
 #include <uapi/linux/magic.h>
 #include <net/ipv6.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #define DECLARE_GLOBALS_HERE
 #include "cifsglob.h"
 #include "cifsproto.h"
fs/smb/client/cifsglob.h +1 -0
index 7001004ee106..188201519f47 100644
@@ -28,6 +28,7 @@
 #include "../common/smb2pdu.h"
 #include "../common/fscc.h"
 #include "smb2pdu.h"
+#include "smb1pdu.h"
 #include <linux/filelock.h>
 
 #define SMB_PATH_MAX 260
fs/smb/client/cifspdu.h +1 -2342

2,355 lines not on this page · raw message

fs/smb/client/cifssmb.c +1 -1
index 478dddc902a3..8738fdbb5a59 100644
@@ -28,8 +28,8 @@
 #include <trace/events/netfs.h>
 #include "cifsglob.h"
 #include "cifsproto.h"
+#include "smb1proto.h"
 #include "../common/smbfsctl.h"
-#include "cifspdu.h"
 #include "cifsfs.h"
 #include "cifsacl.h"
 #include "cifs_unicode.h"
fs/smb/client/connect.c +0 -1
index ce620503e9f7..536edb0a8ed3 100644
@@ -32,7 +32,6 @@
 #include <net/ipv6.h>
 #include <linux/parser.h>
 #include <linux/bvec.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_unicode.h"
fs/smb/client/dir.c +0 -1
index 747256025e49..cb10088197d2 100644
@@ -14,7 +14,6 @@
 #include <linux/mount.h>
 #include <linux/file.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/file.c +0 -1
index 7ff5cc9c5c5b..51360d64b7b2 100644
@@ -25,7 +25,6 @@
 #include <linux/mm.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "smb2proto.h"
fs/smb/client/fs_context.c +0 -1
index c2de97e4ad59..ee129de3b2c7 100644
@@ -26,7 +26,6 @@
 #include <linux/parser.h>
 #include <linux/utsname.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_unicode.h"
fs/smb/client/inode.c +0 -1
index f9ee95953fa4..c23c057162e6 100644
@@ -16,7 +16,6 @@
 #include <linux/fiemap.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "smb2proto.h"
fs/smb/client/ioctl.c +0 -1
index 0a9935ce05a5..903ec46a28d5 100644
@@ -13,7 +13,6 @@
 #include <linux/mount.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/link.c +0 -1
index fdfdc9a3abdd..a2f7bfa8ad1e 100644
@@ -11,7 +11,6 @@
 #include <linux/slab.h>
 #include <linux/namei.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/misc.c +0 -1
index f3ecdf20dbe0..b5bd55501571 100644
@@ -10,7 +10,6 @@
 #include <linux/ctype.h>
 #include <linux/mempool.h>
 #include <linux/vmalloc.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/netmisc.c +0 -1
index ae15f0bef009..59a19f3854a8 100644
@@ -17,7 +17,6 @@
 #include <asm/byteorder.h>
 #include <linux/inet.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "smberr.h"
fs/smb/client/readdir.c +0 -1
index 6844f1dc3921..67a8555efa1e 100644
@@ -13,7 +13,6 @@
 #include <linux/pagemap.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_unicode.h"
fs/smb/client/reparse.h +1 -0
index cfbb7dd28958..570b0d25aeba 100644
@@ -11,6 +11,7 @@
 #include <linux/uidgid.h>
 #include "fs_context.h"
 #include "cifsglob.h"
+#include "../common/smbfsctl.h"
 
 #define REPARSE_SYM_PATH_MAX 4060
 
fs/smb/client/sess.c +0 -1
index a72d6a6d20f0..9373b77a1b31 100644
@@ -8,7 +8,6 @@
  *
  */
 
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_unicode.h"
fs/smb/client/smb1ops.c +0 -1
index 2534113596c7..65d55a81b1b2 100644
@@ -12,7 +12,6 @@
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
-#include "cifspdu.h"
 #include "cifs_unicode.h"
 #include "fs_context.h"
 #include "nterr.h"
fs/smb/client/smb1pdu.h new file +2354 -0

524 lines not on this page · raw message

fs/smb/client/smb1transport.c +2 -1
index 7154522c471c..0528c1919961 100644

Lines of this file are not shown. View the raw message.

fs/smb/client/smb2file.c +1 -0
index 7f11ae6bb785..5b03ae4afc66 100644

Lines of this file are not shown. View the raw message.

fs/smb/client/smb2inode.c +1 -0
index 2ded3246600c..fff1db197543 100644

Lines of this file are not shown. View the raw message.

fs/smb/client/smb2pdu.c +1 -0
index 5d57c895ca37..9815e30eecfc 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#26 lore raw

Re: [PATCH 25/37] cifs: SMB1 split: Split SMB1 protocol defs into smb1pdu.h

FILE_BASIC_INFO (and possibly other definitions) is also used in client/smb2inode.c, and it is defined in MS-FSCC 2.4.7, so perhaps we should move these definitions into a new header file client/fscc.h.

Of course, for FILE_BASIC_INFO, smb/server/ has smb2_file_basic_info in smb/server, so we could move them into common/fscc.h.

Thanks,
ChenXiaoSong <[email protected]>

Quoted 22 lines · David Howells
fs/smb/client/cifsfs.c +0 -9
-typedef struct {
-	__le64 CreationTime;
-	__le64 LastAccessTime;
-	__le64 LastWriteTime;
-	__le64 ChangeTime;
-	__le32 Attributes;
-	__u32 Pad;
-} __packed FILE_BASIC_INFO;	/* size info, level 0x101 */
-
fs/smb/client/smb1pdu.h new file +9 -0
+typedef struct {
+	__le64 CreationTime;
+	__le64 LastAccessTime;
+	__le64 LastWriteTime;
+	__le64 ChangeTime;
+	__le32 Attributes;
+	__u32 Pad;
+} __packed FILE_BASIC_INFO;	/* size info, level 0x101 */
+
#27 lore raw

PATCH 26/37 cifs: SMB1 split: Adjust #includes

In reply to David Howells

Adjust the #include set after the removal of the SMB1 protocol defs from cifspdu.h.

---
 fs/smb/client/cifs_unicode.c | 1 -
 fs/smb/client/cifsacl.c      | 1 -
 fs/smb/client/cifsencrypt.c  | 1 -
 fs/smb/client/cifsglob.h     | 2 --
 fs/smb/client/misc.c         | 1 +
 fs/smb/client/netmisc.c      | 1 +
 fs/smb/client/smb1proto.h    | 2 ++
 fs/smb/client/smb2file.c     | 1 -
 fs/smb/client/smb2inode.c    | 1 -
 fs/smb/client/smb2pdu.c      | 1 -
 fs/smb/client/smbencrypt.c   | 1 -
 fs/smb/client/transport.c    | 1 -
 fs/smb/client/xattr.c        | 1 -
 13 files changed, 4 insertions(+), 11 deletions(-)
fs/smb/client/cifs_unicode.c +0 -1
index f8659d36793f..e7891b4406f2 100644
@@ -8,7 +8,6 @@
 #include <linux/slab.h>
 #include "cifs_fs_sb.h"
 #include "cifs_unicode.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifs_debug.h"
 
fs/smb/client/cifsacl.c +0 -1
index 7e6e473bd4a0..f03eda46f452 100644
@@ -17,7 +17,6 @@
 #include <linux/posix_acl.h>
 #include <linux/posix_acl_xattr.h>
 #include <keys/user-type.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsacl.h"
 #include "cifsproto.h"
fs/smb/client/cifsencrypt.c +0 -1
index ca2a84e8673e..661c7b8dc602 100644
@@ -11,7 +11,6 @@
 
 #include <linux/fs.h>
 #include <linux/slab.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifs_debug.h"
 #include "cifs_unicode.h"
fs/smb/client/cifsglob.h +0 -2
index 188201519f47..2cbaf3f32e8e 100644
@@ -104,8 +104,6 @@
  */
 #define SMB2_MAX_CREDITS_AVAILABLE 32000
 
-#include "cifspdu.h"
-
 #ifndef XATTR_DOS_ATTRIB
 #define XATTR_DOS_ATTRIB "user.DOSATTRIB"
 #endif
fs/smb/client/misc.c +1 -0
index b5bd55501571..dab2d594f024 100644
@@ -18,6 +18,7 @@
 #include "cifs_unicode.h"
 #include "smb2pdu.h"
 #include "smb2proto.h"
+#include "smb1proto.h"
 #include "cifsfs.h"
 #ifdef CONFIG_CIFS_DFS_UPCALL
 #include "dns_resolve.h"
fs/smb/client/netmisc.c +1 -0
index 59a19f3854a8..1f8994a38b37 100644
@@ -19,6 +19,7 @@
 #include "cifsfs.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
+#include "smb1proto.h"
 #include "smberr.h"
 #include "cifs_debug.h"
 #include "nterr.h"
fs/smb/client/smb1proto.h +2 -0
index c73cc10dfcc8..916030b1d635 100644
@@ -8,6 +8,8 @@
 #ifndef _SMB1PROTO_H
 #define _SMB1PROTO_H
 
+#include "cifspdu.h"
+
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
 
 struct cifs_unix_set_info_args {
fs/smb/client/smb2file.c +0 -1
index 5b03ae4afc66..0f0514be29cd 100644
@@ -13,7 +13,6 @@
 #include <linux/pagemap.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/smb2inode.c +0 -1
index fff1db197543..d1183579cf08 100644
@@ -13,7 +13,6 @@
 #include <linux/pagemap.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/smb2pdu.c +0 -1
index 9815e30eecfc..22168a20894b 100644
@@ -35,7 +35,6 @@
 #include "../common/smbfsctl.h"
 #include "../common/smb2status.h"
 #include "smb2glob.h"
-#include "cifspdu.h"
 #include "cifs_spnego.h"
 #include "../common/smbdirect/smbdirect.h"
 #include "smbdirect.h"
fs/smb/client/smbencrypt.c +0 -1
index 1d1ee9f18f37..094b8296d9b4 100644
@@ -20,7 +20,6 @@
 #include <linux/random.h>
 #include "cifs_fs_sb.h"
 #include "cifs_unicode.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifs_debug.h"
 #include "cifsproto.h"
fs/smb/client/transport.c +0 -1
index 3b34c3f4da2d..75697f6d2566 100644
@@ -23,7 +23,6 @@
 #include <linux/sched/signal.h>
 #include <linux/task_io_accounting_ops.h>
 #include <linux/task_work.h>
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
fs/smb/client/xattr.c +0 -1
index 6bc89c59164a..e1a7d9a10a53 100644
@@ -11,7 +11,6 @@
 #include <linux/slab.h>
 #include <linux/xattr.h>
 #include "cifsfs.h"
-#include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
#28 lore raw

PATCH 27/37 cifs: SMB1 split: Move BCC access functions

In reply to David Howells

Move the BCC access functions to smb1proto.h as they're only applicable to SMB1.

---
 fs/smb/client/cifspdu.h   | 34 ----------------------------------
 fs/smb/client/smb1proto.h | 36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 35 deletions(-)
fs/smb/client/cifspdu.h +0 -34
index de061247ecd7..78512af18d96 100644
@@ -9,38 +9,4 @@
 #ifndef _CIFSPDU_H
 #define _CIFSPDU_H
 
-#include <linux/unaligned.h>
-#include "../common/smb1pdu.h"
-
-#define GETU16(var)  (*((__u16 *)var))	/* BB check for endian issues */
-#define GETU32(var)  (*((__u32 *)var))	/* BB check for endian issues */
-
-/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */
-static inline void *
-BCC(struct smb_hdr *smb)
-{
-	return (void *)smb + sizeof(*smb) + 2 * smb->WordCount;
-}
-
-/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
-#define pByteArea(smb_var) (BCC(smb_var) + 2)
-
-/* get the unconverted ByteCount for a SMB packet and return it */
-static inline __u16
-get_bcc(struct smb_hdr *hdr)
-{
-	__le16 *bc_ptr = (__le16 *)BCC(hdr);
-
-	return get_unaligned_le16(bc_ptr);
-}
-
-/* set the ByteCount for a SMB packet in little-endian */
-static inline void
-put_bcc(__u16 count, struct smb_hdr *hdr)
-{
-	__le16 *bc_ptr = (__le16 *)BCC(hdr);
-
-	put_unaligned_le16(count, bc_ptr);
-}
-
 #endif /* _CIFSPDU_H */
fs/smb/client/smb1proto.h +35 -1
index 916030b1d635..eaf317a53b76 100644
@@ -8,10 +8,12 @@
 #ifndef _SMB1PROTO_H
 #define _SMB1PROTO_H
 
-#include "cifspdu.h"
+#include "../common/smb2pdu.h"
 
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
 
+#include <linux/unaligned.h>
+
 struct cifs_unix_set_info_args {
 	__u64	ctime;
 	__u64	atime;
@@ -242,4 +244,36 @@ int checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
 
 
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
+
+#define GETU16(var)  (*((__u16 *)var))	/* BB check for endian issues */
+#define GETU32(var)  (*((__u32 *)var))	/* BB check for endian issues */
+
+/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */
+static inline void *
+BCC(struct smb_hdr *smb)
+{
+	return (void *)smb + sizeof(*smb) + 2 * smb->WordCount;
+}
+
+/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
+#define pByteArea(smb_var) (BCC(smb_var) + 2)
+
+/* get the unconverted ByteCount for a SMB packet and return it */
+static inline __u16
+get_bcc(struct smb_hdr *hdr)
+{
+	__le16 *bc_ptr = (__le16 *)BCC(hdr);
+
+	return get_unaligned_le16(bc_ptr);
+}
+
+/* set the ByteCount for a SMB packet in little-endian */
+static inline void
+put_bcc(__u16 count, struct smb_hdr *hdr)
+{
+	__le16 *bc_ptr = (__le16 *)BCC(hdr);
+
+	put_unaligned_le16(count, bc_ptr);
+}
+
 #endif /* _SMB1PROTO_H */
#29 lore raw

PATCH 28/37 cifs: SMB1 split: Don't return smb_hdr from cifs_{,small_}buf_get()

In reply to David Howells

Return void* rather than struct smb_hdr* from from cifs_buf_get() and cifs_small_buf_get() as SMB2/3 shouldn't be accessing smb_hdr.

---
 fs/smb/client/cifsproto.h | 4 ++--
 fs/smb/client/misc.c      | 9 ++++-----
 2 files changed, 6 insertions(+), 7 deletions(-)
fs/smb/client/cifsproto.h +2 -2
index 53d23958b9da..6cf084aeb30e 100644
@@ -26,9 +26,9 @@ struct smb3_fs_context;
  *****************************************************************
  */
 
-struct smb_hdr *cifs_buf_get(void);
+void *cifs_buf_get(void);
 void cifs_buf_release(void *buf_to_free);
-struct smb_hdr *cifs_small_buf_get(void);
+void *cifs_small_buf_get(void);
 void cifs_small_buf_release(void *buf_to_free);
 void free_rsp_buf(int resp_buftype, void *rsp);
 int smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
fs/smb/client/misc.c +4 -5
index dab2d594f024..273c54d39857 100644
@@ -178,10 +178,10 @@ tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
 	kfree(tcon);
 }
 
-struct smb_hdr *
+void *
 cifs_buf_get(void)
 {
-	struct smb_hdr *ret_buf = NULL;
+	void *ret_buf = NULL;
 	/*
 	 * SMB2 header is bigger than CIFS one - no problems to clean some
 	 * more bytes for CIFS.
@@ -220,10 +220,10 @@ cifs_buf_release(void *buf_to_free)
 	return;
 }
 
-struct smb_hdr *
+void *
 cifs_small_buf_get(void)
 {
-	struct smb_hdr *ret_buf = NULL;
+	void *ret_buf = NULL;
 
 /* We could use negotiated size instead of max_msgsize -
    but it may be more efficient to always alloc same size
@@ -231,7 +231,6 @@ cifs_small_buf_get(void)
    defaults to this and can not be bigger */
 	ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS);
 	/* No need to clear memory here, cleared in header assemble */
-	/*	memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
 	atomic_inc(&small_buf_alloc_count);
 #ifdef CONFIG_CIFS_STATS2
 	atomic_inc(&total_small_buf_alloc_count);
#30 lore raw

PATCH 29/37 cifs: Fix cifs_dump_mids() to call ->dump_detail

In reply to David Howells
---
 fs/smb/client/cifs_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/cifs_debug.c +1 -1
index 98136547ea5f..b21444777872 100644
@@ -78,7 +78,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
 		cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n",
 			 mid_entry->multiRsp, mid_entry->multiEnd);
 		if (mid_entry->resp_buf) {
-			cifs_dump_detail(mid_entry->resp_buf,
+			server->ops->dump_detail(mid_entry->resp_buf,
 					 mid_entry->response_pdu_len, server);
 			cifs_dump_mem("existing buf: ", mid_entry->resp_buf, 62);
 		}
#31 lore raw

PATCH 30/37 cifs: SMB1 split: Move inline funcs

In reply to David Howells

Move some SMB1-specific inline funcs to smb1proto.h.

---
 fs/smb/client/cifsglob.h  | 12 ------------
 fs/smb/client/smb1proto.h | 12 ++++++++++++
 2 files changed, 12 insertions(+), 12 deletions(-)
fs/smb/client/cifsglob.h +0 -12
index 2cbaf3f32e8e..ae37fb2dc535 100644
@@ -949,18 +949,6 @@ revert_current_mid_from_hdr(struct TCP_Server_Info *server,
 	return revert_current_mid(server, num > 0 ? num : 1);
 }
 
-static inline __u16
-get_mid(const struct smb_hdr *smb)
-{
-	return le16_to_cpu(smb->Mid);
-}
-
-static inline bool
-compare_mid(__u16 mid, const struct smb_hdr *smb)
-{
-	return mid == le16_to_cpu(smb->Mid);
-}
-
 /*
  * When the server supports very large reads and writes via POSIX extensions,
  * we can allow up to 2^24-1, minus the size of a READ/WRITE_AND_X header, not
fs/smb/client/smb1proto.h +12 -0
index eaf317a53b76..abbc3db11743 100644
@@ -243,6 +243,18 @@ int checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
 	     struct TCP_Server_Info *server);
 
 
+static inline __u16
+get_mid(const struct smb_hdr *smb)
+{
+	return le16_to_cpu(smb->Mid);
+}
+
+static inline bool
+compare_mid(__u16 mid, const struct smb_hdr *smb)
+{
+	return mid == le16_to_cpu(smb->Mid);
+}
+
 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
 
 #define GETU16(var)  (*((__u16 *)var))	/* BB check for endian issues */
#32 lore raw

PATCH 31/37 cifs: SMB1 split: cifs_debug.c

In reply to David Howells

Split SMB1 bits from cifs_debug.c to smb1debug.c.

---
 fs/smb/client/Makefile     |  1 +
 fs/smb/client/cifs_debug.c | 15 ---------------
 fs/smb/client/cifs_debug.h |  2 --
 fs/smb/client/smb1debug.c  | 25 +++++++++++++++++++++++++
 fs/smb/client/smb1proto.h  |  8 ++++++++
 fs/smb/common/smb2pdu.h    |  3 +++
 6 files changed, 37 insertions(+), 17 deletions(-)
 create mode 100644 fs/smb/client/smb1debug.c
fs/smb/client/Makefile +1 -0
index 9754b4776df8..c51f67a5caaa 100644
@@ -34,6 +34,7 @@ cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
 
 cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
 	cifssmb.o \
+	smb1debug.o \
 	smb1ops.o \
 	smb1transport.o
 
fs/smb/client/cifs_debug.c +0 -15
index b21444777872..b5917329fd48 100644
@@ -36,21 +36,6 @@ cifs_dump_mem(char *label, void *data, int length)
 		       data, length, true);
 }
 
-void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)
-{
-#ifdef CONFIG_CIFS_DEBUG2
-	struct smb_hdr *smb = buf;
-
-	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n",
-		 smb->Command, smb->Status.CifsError, smb->Flags,
-		 smb->Flags2, smb->Mid, smb->Pid, smb->WordCount);
-	if (!server->ops->check_message(buf, buf_len, server->total_read, server)) {
-		cifs_dbg(VFS, "smb buf %p len %u\n", smb,
-			 server->ops->calc_smb_size(smb));
-	}
-#endif /* CONFIG_CIFS_DEBUG2 */
-}
-
 void cifs_dump_mids(struct TCP_Server_Info *server)
 {
 #ifdef CONFIG_CIFS_DEBUG2
fs/smb/client/cifs_debug.h +0 -2
index 35bd5c8e1d71..00650929a133 100644
@@ -15,8 +15,6 @@
 #define pr_fmt(fmt) "CIFS: " fmt
 
 void cifs_dump_mem(char *label, void *data, int length);
-void cifs_dump_detail(void *buf, size_t buf_len,
-		      struct TCP_Server_Info *server);
 void cifs_dump_mids(struct TCP_Server_Info *server);
 extern bool traceSMB;		/* flag which enables the function below */
 void dump_smb(void *buf, int smb_buf_length);
fs/smb/client/smb1debug.c new file +25 -0
new file mode 100644
index 000000000000..e2d013e751e5
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ *   Copyright (C) International Business Machines  Corp., 2000,2005
+ *
+ *   Modified by Steve French ([email protected])
+ */
+#include "cifsproto.h"
+#include "smb1proto.h"
+#include "cifs_debug.h"
+
+void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)
+{
+#ifdef CONFIG_CIFS_DEBUG2
+	struct smb_hdr *smb = buf;
+
+	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n",
+		 smb->Command, smb->Status.CifsError, smb->Flags,
+		 smb->Flags2, smb->Mid, smb->Pid, smb->WordCount);
+	if (!server->ops->check_message(buf, buf_len, server->total_read, server)) {
+		cifs_dbg(VFS, "smb buf %p len %u\n", smb,
+			 server->ops->calc_smb_size(smb));
+	}
+#endif /* CONFIG_CIFS_DEBUG2 */
+}
fs/smb/client/smb1proto.h +8 -0
index abbc3db11743..de021e17dc4b 100644
@@ -8,10 +8,12 @@
 #ifndef _SMB1PROTO_H
 #define _SMB1PROTO_H
 
+#include <linux/uidgid_types.h>
 #include "../common/smb2pdu.h"
 
 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
 
+#include "cifsglob.h"
 #include <linux/unaligned.h>
 
 struct cifs_unix_set_info_args {
@@ -212,6 +214,12 @@ int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
 		 const struct nls_table *nls_codepage,
 		 struct cifs_sb_info *cifs_sb);
 
+/*
+ * smb1debug.c
+ */
+void cifs_dump_detail(void *buf, size_t buf_len,
+		      struct TCP_Server_Info *server);
+
 /*
  * smb1ops.c
  */
fs/smb/common/smb2pdu.h +3 -0
index f5ebbe31384a..e482c86ceb00 100644
@@ -2,6 +2,9 @@
 #ifndef _COMMON_SMB2PDU_H
 #define _COMMON_SMB2PDU_H
 
+#include <linux/types.h>
+#include <linux/build_bug.h>
+
 /*
  * Note that, due to trying to use names similar to the protocol specifications,
  * there are many mixed case field names in the structures below.  Although
#33 lore raw

PATCH 32/37 cifs: SMB1 split: misc.c

In reply to David Howells

Split SMB1 bits from misc.c to smb1misc.c.

---
 fs/smb/client/Makefile    |   1 +
 fs/smb/client/cifsproto.h |   4 -
 fs/smb/client/misc.c      | 165 -----------------------------------
 fs/smb/client/smb1misc.c  | 177 ++++++++++++++++++++++++++++++++++++++
 fs/smb/client/smb1proto.h |   7 ++
 5 files changed, 185 insertions(+), 169 deletions(-)
 create mode 100644 fs/smb/client/smb1misc.c
fs/smb/client/Makefile +1 -0
index c51f67a5caaa..5288f9de07cd 100644
@@ -35,6 +35,7 @@ cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
 cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
 	cifssmb.o \
 	smb1debug.o \
+	smb1misc.o \
 	smb1ops.o \
 	smb1transport.o
 
fs/smb/client/cifsproto.h +0 -4
index 6cf084aeb30e..fc97c6c452d2 100644
@@ -131,7 +131,6 @@ void cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
 void cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
 					   bool mark_smb_session);
 int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session);
-bool is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv);
 bool backup_cred(struct cifs_sb_info *cifs_sb);
 bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file,
 			    bool from_readdir);
@@ -157,9 +156,6 @@ void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
 int map_smb_to_linux_error(char *buf, bool logErr);
 int map_and_check_smb_error(struct TCP_Server_Info *server,
 			    struct mid_q_entry *mid, bool logErr);
-unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
-			     const struct cifs_tcon *treeCon, int word_count
-			     /* length of fixed section (word count) in two byte units  */);
 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
 		   struct TCP_Server_Info *server,
 		   const struct nls_table *nls_cp);
fs/smb/client/misc.c +0 -165

171 lines not on this page · raw message

fs/smb/client/smb1misc.c new file +177 -0

177 lines not on this page · raw message

fs/smb/client/smb1proto.h +7 -0
index de021e17dc4b..259cfafacfab 100644
@@ -220,6 +220,13 @@ int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
 void cifs_dump_detail(void *buf, size_t buf_len,
 		      struct TCP_Server_Info *server);
 
+/*
+ * smb1misc.c
+ */
+unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
+			     const struct cifs_tcon *treeCon, int word_count);
+bool is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv);
+
 /*
  * smb1ops.c
  */
#34 lore raw

PATCH 33/37 cifs: SMB1 split: netmisc.c

In reply to David Howells

Split a variety of bits from netmisc.c into other places, notably the error table into smb1maperror.c.

---
 fs/smb/client/Makefile       |   1 +
 fs/smb/client/cifsproto.h    |   4 -
 fs/smb/client/netmisc.c      | 822 ----------------------------------
 fs/smb/client/smb1maperror.c | 825 +++++++++++++++++++++++++++++++++++
 fs/smb/client/smb1misc.c     |  12 +
 fs/smb/client/smb1proto.h    |   8 +
 6 files changed, 846 insertions(+), 826 deletions(-)
 create mode 100644 fs/smb/client/smb1maperror.c
fs/smb/client/Makefile +1 -0
index 5288f9de07cd..82ad4bccb131 100644
@@ -35,6 +35,7 @@ cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
 cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
 	cifssmb.o \
 	smb1debug.o \
+	smb1maperror.o \
 	smb1misc.o \
 	smb1ops.o \
 	smb1transport.o
fs/smb/client/cifsproto.h +0 -4
index fc97c6c452d2..884a66b6bd34 100644
@@ -148,14 +148,10 @@ int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
 			   struct cifsFileInfo **ret_file);
 int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode,
 			   struct file *file);
-unsigned int smbCalcSize(void *buf);
 int decode_negTokenInit(unsigned char *security_blob, int length,
 			struct TCP_Server_Info *server);
 int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
 void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
-int map_smb_to_linux_error(char *buf, bool logErr);
-int map_and_check_smb_error(struct TCP_Server_Info *server,
-			    struct mid_q_entry *mid, bool logErr);
 int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
 		   struct TCP_Server_Info *server,
 		   const struct nls_table *nls_cp);
fs/smb/client/netmisc.c +0 -822

834 lines not on this page · raw message

fs/smb/client/smb1maperror.c new file +825 -0

825 lines not on this page · raw message

fs/smb/client/smb1misc.c +12 -0
index d73ef87f55d0..ba56023010d8 100644
@@ -175,3 +175,15 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv)
 	cifs_dbg(FYI, "Can not process oplock break for non-existent connection\n");
 	return true;
 }
+
+/*
+ * calculate the size of the SMB message based on the fixed header
+ * portion, the number of word parameters and the data portion of the message
+ */
+unsigned int
+smbCalcSize(void *buf)
+{
+	struct smb_hdr *ptr = buf;
+	return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +
+		2 /* size of the bcc field */ + get_bcc(ptr));
+}
fs/smb/client/smb1proto.h +8 -0
index 259cfafacfab..f5760af58999 100644
@@ -220,12 +220,20 @@ int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
 void cifs_dump_detail(void *buf, size_t buf_len,
 		      struct TCP_Server_Info *server);
 
+/*
+ * smb1maperror.c
+ */
+int map_smb_to_linux_error(char *buf, bool logErr);
+int map_and_check_smb_error(struct TCP_Server_Info *server,
+			    struct mid_q_entry *mid, bool logErr);
+
 /*
  * smb1misc.c
  */
 unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
 			     const struct cifs_tcon *treeCon, int word_count);
 bool is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv);
+unsigned int smbCalcSize(void *buf);
 
 /*
  * smb1ops.c
#35 lore raw

PATCH 34/37 cifs: SMB1 split: cifsencrypt.c

In reply to David Howells

Split SMB1-specific message signing into smb1encrypt.c.

---
 fs/smb/client/Makefile      |   1 +
 fs/smb/client/cifsencrypt.c | 123 -------------------------------
 fs/smb/client/cifsproto.h   |   5 --
 fs/smb/client/smb1encrypt.c | 139 ++++++++++++++++++++++++++++++++++++
 fs/smb/client/smb1proto.h   |   9 +++
 5 files changed, 149 insertions(+), 128 deletions(-)
 create mode 100644 fs/smb/client/smb1encrypt.c
fs/smb/client/Makefile +1 -0
index 82ad4bccb131..a66e3b5b5912 100644
@@ -35,6 +35,7 @@ cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
 cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
 	cifssmb.o \
 	smb1debug.o \
+	smb1encrypt.o \
 	smb1maperror.o \
 	smb1misc.o \
 	smb1ops.o \
fs/smb/client/cifsencrypt.c +0 -123

129 lines not on this page · raw message

fs/smb/client/cifsproto.h +0 -5
index 884a66b6bd34..ba571cc7453a 100644
@@ -326,11 +326,6 @@ struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled,
 				  enum smb3_tcon_ref_trace trace);
 void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
 
-int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
-		   __u32 *pexpected_response_sequence_number);
-int cifs_verify_signature(struct smb_rqst *rqst,
-			  struct TCP_Server_Info *server,
-			  __u32 expected_sequence_number);
 int setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp);
 void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
 int calc_seckey(struct cifs_ses *ses);
fs/smb/client/smb1encrypt.c new file +139 -0

139 lines not on this page · raw message

fs/smb/client/smb1proto.h +9 -0
index f5760af58999..0f54c0740da1 100644
@@ -220,6 +220,15 @@ int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
 void cifs_dump_detail(void *buf, size_t buf_len,
 		      struct TCP_Server_Info *server);
 
+/*
+ * smb1encrypt.c
+ */
+int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
+		   __u32 *pexpected_response_sequence_number);
+int cifs_verify_signature(struct smb_rqst *rqst,
+			  struct TCP_Server_Info *server,
+			  __u32 expected_sequence_number);
+
 /*
  * smb1maperror.c
  */
#36 lore raw

PATCH 35/37 cifs: SMB1 split: sess.c

In reply to David Howells

Split SMB1-specific session setup stuff into smb1session.c.

---
 fs/smb/client/Makefile      |   1 +
 fs/smb/client/cifsproto.h   |   3 -
 fs/smb/client/sess.c        | 981 -----------------------------------
 fs/smb/client/smb1proto.h   |   7 +
 fs/smb/client/smb1session.c | 995 ++++++++++++++++++++++++++++++++++++
 5 files changed, 1003 insertions(+), 984 deletions(-)
 create mode 100644 fs/smb/client/smb1session.c
fs/smb/client/Makefile +1 -0
index a66e3b5b5912..059e56e715ad 100644
@@ -39,6 +39,7 @@ cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
 	smb1maperror.o \
 	smb1misc.o \
 	smb1ops.o \
+	smb1session.o \
 	smb1transport.o
 
 cifs-$(CONFIG_CIFS_COMPRESSION) += compress.o compress/lz77.o
fs/smb/client/cifsproto.h +0 -3
index ba571cc7453a..49ff68f3c999 100644
@@ -152,9 +152,6 @@ int decode_negTokenInit(unsigned char *security_blob, int length,
 			struct TCP_Server_Info *server);
 int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
 void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
-int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
-		   struct TCP_Server_Info *server,
-		   const struct nls_table *nls_cp);
 struct timespec64 cifs_NTtimeToUnix(__le64 ntutc);
 u64 cifs_UnixTimeToNT(struct timespec64 t);
 struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset);
fs/smb/client/sess.c +0 -981

990 lines not on this page · raw message

fs/smb/client/smb1proto.h +7 -0
index 0f54c0740da1..645f3e74fcc4 100644
@@ -250,6 +250,13 @@ unsigned int smbCalcSize(void *buf);
 extern struct smb_version_operations smb1_operations;
 extern struct smb_version_values smb1_values;
 
+/*
+ * smb1session.c
+ */
+int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
+		   struct TCP_Server_Info *server,
+		   const struct nls_table *nls_cp);
+
 /*
  * smb1transport.c
  */
fs/smb/client/smb1session.c new file +995 -0

995 lines not on this page · raw message

#37 lore raw

PATCH 36/37 cifs: SMB1 split: connect.c

In reply to David Howells

Split SMB1-specific connection management stuff to smb1ops.c and move CIFSTCon() to cifssmb.c.

---
 fs/smb/client/cifsproto.h |  20 ---
 fs/smb/client/cifssmb.c   | 140 +++++++++++++++++++++
 fs/smb/client/connect.c   | 251 --------------------------------------
 fs/smb/client/smb1ops.c   | 107 ++++++++++++++++
 fs/smb/client/smb1proto.h |   6 +
 5 files changed, 253 insertions(+), 271 deletions(-)
fs/smb/client/cifsproto.h +0 -20
index 49ff68f3c999..96d6b5325aa3 100644
@@ -291,31 +291,11 @@ int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
 int cifs_enable_signing(struct TCP_Server_Info *server,
 			bool mnt_sign_required);
 
-int CIFSTCon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
-	     struct cifs_tcon *tcon, const struct nls_table *nls_codepage);
-
-
-
-
-
-
-
 int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
 			unsigned int *num_of_nodes,
 			struct dfs_info3_param **target_nodes,
 			const struct nls_table *nls_codepage, int remap,
 			const char *searchName, bool is_unicode);
-void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
-			  struct cifs_sb_info *cifs_sb,
-			  struct smb3_fs_context *ctx);
-
-
-
-
-
-
-
-
 
 struct cifs_ses *sesInfoAlloc(void);
 void sesInfoFree(struct cifs_ses *buf_to_free);
fs/smb/client/cifssmb.c +140 -0

146 lines not on this page · raw message

fs/smb/client/connect.c +0 -251

263 lines not on this page · raw message

fs/smb/client/smb1ops.c +107 -0

113 lines not on this page · raw message

fs/smb/client/smb1proto.h +6 -0
index 645f3e74fcc4..5ccca02841a8 100644
@@ -33,6 +33,8 @@ int small_smb_init_no_tc(const int smb_command, const int wct,
 			 struct cifs_ses *ses, void **request_buf);
 int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses,
 		     struct TCP_Server_Info *server);
+int CIFSTCon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
+	     struct cifs_tcon *tcon, const struct nls_table *nls_codepage);
 int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
 int CIFSSMBEcho(struct TCP_Server_Info *server);
 int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
@@ -250,6 +252,10 @@ unsigned int smbCalcSize(void *buf);
 extern struct smb_version_operations smb1_operations;
 extern struct smb_version_values smb1_values;
 
+void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
+			  struct cifs_sb_info *cifs_sb,
+			  struct smb3_fs_context *ctx);
+
 /*
  * smb1session.c
  */
#38 lore raw

PATCH 37/37 cifs: SMB1 split: Make BCC accessors conditional

In reply to David Howells

Make the BCC accessor functions conditional.

---
 fs/smb/client/smb1proto.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/smb1proto.h +2 -2
index 5ccca02841a8..0c622b5d2555 100644
@@ -300,8 +300,6 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
 	return mid == le16_to_cpu(smb->Mid);
 }
 
-#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
-
 #define GETU16(var)  (*((__u16 *)var))	/* BB check for endian issues */
 #define GETU32(var)  (*((__u32 *)var))	/* BB check for endian issues */
 
@@ -333,4 +331,6 @@ put_bcc(__u16 count, struct smb_hdr *hdr)
 	put_unaligned_le16(count, bc_ptr);
 }
 
+#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
+
 #endif /* _SMB1PROTO_H */
Acked-by on the v1 series
#39 lore raw
In reply to David Howells
Quoted 32 lines · David Howells

Hi Steve,

Could you consider taking these patches? There are two parts to the set.

The first part cleans up the formatting of declarations in the header file. They remove the externs, (re)name the arguments in the declarations to match those in the C file and format them to wrap at 79 chars (this is configurable - search for 79 in the script), aligning all the first argument on each line with the char after the opening bracket.

I've attached the script below so that you can also run it yourself. It does all the git manipulation to generate one commit per header file changed. Run as:

	./cifs.pl fs/smb/client/*.[ch]

in the kernel source root dir.

The script can be rerun later to readjust any added changes.

Paulo has given his R-b for this subset (labelled cifs: Scripted clean up).

The second part splits the SMB1 parts of cifs protocol layer out into their own files. cifstransport.c is renamed to smb1transport.c also for consistency, though cifssmb.c is left unrenamed (I could rename that to smb1pdu.c). This is pretty much all moving stuff around and few actual code changes. There is one bugfix, though, to cifs_dump_mids().

I've left the splitting of the SMB1 parts of the cifs filesystem layer for a future set of patches as that's would involve removing embedded parts of functions and is easier to get wrong.

Quoted 6 lines

The patches can be found here also:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=cifs-cleanup

Thanks,
David

Cheers,

Enzo

Quoted 622 lines

---

	#!/usr/bin/perl -w
	use strict;
	unless (@ARGV) {
	    die "Usage: $0 <c_file1> [<c_file2> ...]\n";
	}

	# Data tracking
	my %funcs = ();		# Func name => { func prototype }
	my %headers = ();	# Header filename => { header content }
	my %c_files = ();	# C filename => { ordered func list, header pref }
	my %cmarkers = ();	# C filename marker => { header filename it's in }

	# Parse state
	my $pathname = "-";
	my $lineno = 0;

	sub error(@) {
	    print STDERR $pathname, ":", $lineno, ": ", @_, "\n";
	    exit(1);
	}

	sub pad($) {
	    # Reindent the function arguments to line the arguments up with the char
	    # after the opening bracket on the func argument list
	    my ($lines) = @_;
	    return $lines if ($#{$lines} <= 0);
	    my $has_empty = 0;
	    for (my $i = 0; $i <= $#{$lines}; $i++) {
		$lines->[$i] =~ s/^[ \t]+//;
		$has_empty = 1 if ($lines->[$i] eq "");
	    }

	    if ($has_empty) {
		my @clean = grep /.+/, @{$lines};
		$lines = \@clean;
	    }

	    my $indlen = index($lines->[0], "(");
	    return $lines if ($indlen < 0);
	    my $indent = "";
	    $indlen++;
	    $indent .= "\t" x ($indlen / 8);
	    $indent .= " " x ($indlen % 8);

	    my @padded = ();
	    my $acc = "";
	    my $len = -$indlen;
	    for (my $i = 0; $i <= $#{$lines}; $i++) {
		my $argument = $lines->[$i];
		my $arglen = length($argument);
		my $last = ($i == $#{$lines} ? 1 : 0);

		if ($i == 0 ||
		    $i == 1) {
		    $acc .= $argument;
		    $acc .= ";" if ($last);
		    $len += $arglen + $last;
		    next;
		}
		if (!$acc) {
		    $acc = $indent . $argument;
		    $acc .= ";" if ($last);
		    $len += $arglen + $last;
		    next;
		}
		if ($indlen + $len + 1 + $arglen + $last > 79) {
		    push @padded, $acc;
		    $acc = $indent . $argument;
		    $acc .= ";" if ($last);
		    $len = $arglen + $last;
		    next;
		}

		$acc .= " " . $argument;
		$acc .= ";" if ($last);
		$len += 1 + $arglen + $last;
	    }
	    push @padded, $acc if ($acc);
	    return \@padded;
	}

	sub earliest(@) {
	    my $ret = -1;
	    foreach (@_) {
		$ret = $_ if ($ret < 0 || ($_ >= 0 && $_ < $ret));
	    }
	    return $ret;
	}

	foreach my $file (@ARGV) {
	    # Open the file for reading.
	    next if $file =~ /trace[.]h$/;
	    next if $file =~ /smbdirect[.][ch]$/;
	    open my $fh, "<$file"
		or die "Could not open file '$file'";
	    $pathname = $file;
	    $lineno = 0;

	    my $filename;
	    my @file_content = ();
	    my @copy = ();

	    my $state = 0;
	    my $qual = "";
	    my $type = "";
	    my $funcname = "";
	    my @funcdef = ();
	    my $bracket = 0;
	    my $comment = 0;
	    my $smb1 = 0;
	    my $header = 0;
	    my $inline = 0;
	    my $file_marker = "";
	    my $config = "";
	    my $c_file = 0;

	    $filename = $pathname;
	    $filename =~ s!.*/!!;

	    if ($file =~ m!.h$!) {
		my %new_h_file = (
		    path    => $pathname,
		    fname   => $filename,
		    content => [],
		    );
		$header = \%new_h_file;
		$headers{$filename} = \%new_h_file;
	    } elsif ($file =~ m!.c$!) {
		my %new_c_file = (
		    path  => $pathname,
		    fname => $filename,
		    funcs => [],
		    );
		$c_file = \%new_c_file;
		$c_files{$filename} = \%new_c_file;
	    } else {
		warn("Ignoring unexpected file $file\n");
		next;
	    }

	    $smb1 = 1 if ($file =~ m!/smb1ops.c|/cifssmb.c|/cifstransport.c!);

	    foreach my $line (<$fh>) {
		$lineno++;
		chomp($line);
		push @copy, $line;
		if (!$line) {
		    # Blank line
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Handle continuation or end of block comment.  Look for C file
		# prototype insertion point markers.
		if ($comment) {
		    if ($line =~ m![*]/!) {
			if ($comment == 2 && $file_marker) {
			    $cmarkers{$file_marker} = $file_marker;
			    push @copy, "#C_MARKER " . $filename;
			    $file_marker = 0;
			}
			$comment = 0;
		    } else {
			$comment++;
			if ($comment == 2 && $line =~ m! [*] ([a-z][a-z_0-9]*[.][c])$!) {
			    $file_marker = $1;
			    print("Found file marker ", $file_marker, " in ", $filename, "\n");
			}
		    }
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Check cpp directives, particularly looking for SMB1 bits
		if ($line =~ /^[#]/) {
		    if ($header) {
			if ($line =~ /ifdef.*(CONFIG_[A-Z0-9_])/) {
			    error("multiconfig") if $config;
			    $config = $1;
			    $smb1++ if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
			} elsif ($line =~ /endif/) {
			    $smb1-- if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
			    $config = "";
			}
		    }
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Exclude interference in finding func names and return types
		if ($line =~ /^[{]/ ||
		    $line =~ /##/ ||
		    $line =~ /^[_a-z0-9A-Z]+:$/ || # goto label
		    $line =~ /^do [{]/ ||
		    $line =~ m!^//!) {
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Start of a block comment
		if ($line =~ m!^/[*]!) {
		    $comment = 1 unless ($line =~ m![*]/!);
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# End of a braced section, such as a function implementation
		if ($line =~ /^[}]/) {
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = ();
			push @file_content, @copy;
			@copy = ();
			next;
		}

		if ($line =~ /^typedef/) {
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    @funcdef = ();
		    push @file_content, @copy;
		    @copy = ();
		    next;
		}

		# Extract function qualifiers.  There may be multiple of these in more
		# or less any order.  Some of them cause the func to be skipped (e.g. inline).

		if ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
		    $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
		    error("Unexpected qualifier '$1'") if ($state != 0);
		    while ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
			   $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
			$qual .= " " if ($qual);
			$qual .= $1;
			$inline = 1 if ($1 eq "inline");
			$inline = 1 if ($1 eq "__always_inline");
			$line = substr($line, length($1));
			$line =~ s/^\s+//;
		    }
		}

		if ($state == 0) {
		    # Extract what we assume to be the return type
		    if ($line =~ /^\s/) {
			push @file_content, @copy;
			@copy = ();
			next;
		    }
		    while ($line =~ /^(unsigned|signed|bool|char|short|int|long|void|const|volatile|(struct|union|enum)\s+[_a-zA-Z][_a-zA-Z0-9]*|[*]|__init|__exit|__le16|__le32|__le64|__be16|__be32|__be64)/) {
			$type .= " " if $type;
			$type .= $1;
			$line = substr($line, length($1));
			$line =~ s/^\s+//;
		    }
		    if ($line =~ /^struct [{]/) {
			# Ignore structure definitions
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = ();
			push @file_content, @copy;
			@copy = ();
			next;
		    }
		    if (index($line, "=") >= 0) {
			# Ignore assignments
			$type = "";
			$qual = "";
			$funcname = "";
			@funcdef = "";
			push @file_content, @copy;
			@copy = ();
			next;
		    }

		    # Try and extract a function's type and name
		    while ($line =~ /(^[_a-zA-Z][_a-zA-Z0-9]*)/) {
			my $name = $1;
			$line = substr($line, length($name));
			next if ($line =~ /^[{]/);
			$line =~ s/^\s+//;

			my $ch = substr($line, 0, 1);
			last if ($ch eq "[" || $ch eq ";"); # Global variables

			if ($ch eq "(") {
			    # Found the function name
			    $state = 1;
			    $line = substr($line, 1);
			    $funcname = $name;
			    my $tmp = $qual . $type . " " . $funcname . "(";
			    $tmp =~ s/[*] /*/;
			    push @funcdef, $tmp;
			    $bracket = 1;
			    last;
			}

			if ($type) {
			    last if (index($line, ";") >= 0 && index($line, "(") == -1);
			    error("Unexpected name '$name' after '$type'");
			}

			$type .= " " if $type;
			$type .= $name;
			if ($line =~ /^(\s*[*]+)/) {
			    my $ptr = $1;
			    $type .= $ptr;
			    $line = substr($line, length($ptr));
			}
		    }
		}

		# Try and extract a function's argument list
		my $from = 0;
		if ($state == 1) {
		    while (1) {
			my $o = index($line, "(", $from);
			my $c = index($line, ")", $from);
			my $m = index($line, ",", $from);

			my $b = earliest($o, $c, $m);
			if ($b < 0) {
			    push @funcdef, $line
				unless ($line eq "");
			    last;
			}
			my $ch = substr($line, $b, 1);

			# Push the arguments separately on to the list
			if ($ch eq ",") {
			    push @funcdef, substr($line, 0, $b + 1);
			    $line = substr($line, $b + 1);
			    $from = 0;
			} elsif ($ch eq "(") {
			    # Handle brackets in the argument list (e.g. function
			    # pointers)
			    $bracket++;
			    $from = $b + 1;
			} elsif ($ch eq ")") {
			    $bracket--;
			    if ($bracket == 0) {
				push @funcdef, substr($line, 0, $b + 1);
				$line = substr($line, $b + 1);
				$state = 2;
				last;
			    }
			    $from = $b + 1;
			}
		    }
		}

		if ($state == 2) {
		    $inline = 1 if ($qual =~ /inline/);
		    #print("QUAL $qual $type $funcname $inline ", $#funcdef, "\n");
		    if (!$header &&
			$qual !~ /static/ &&
			$funcname ne "__acquires" &&
			$funcname ne "__releases" &&
			$funcname ne "module_init" &&
			$funcname ne "module_exit" &&
			$funcname ne "module_param" &&
			$funcname ne "module_param_call" &&
			$funcname ne "PROC_FILE_DEFINE" &&
			$funcname !~ /MODULE_/ &&
			$funcname !~ /DEFINE_/) {

			# Okay, we appear to have a function implementation
			my $func;

			if (exists($funcs{$funcname})) {
			    $func = $funcs{$funcname};
			    $func->{body} = pad(\@funcdef);
			} else {
			    my %new_func = (
				name => $funcname,
				cond => "",
				);
			    $func = \%new_func;
			    $funcs{$funcname} = $func;
			    $func->{body} = pad(\@funcdef);
			}
			$func->{body} = pad(\@funcdef);

			if ($funcname eq "cifs_inval_name_dfs_link_error") {
			    $func->{cond} = "#ifdef CONFIG_CIFS_DFS_UPCALL";
			} elsif ($funcname eq "cifs_listxattr") {
			    $func->{cond} = "#ifdef CONFIG_CIFS_XATTR";
			}

			push @{$c_file->{funcs}}, $func;
		    } elsif (!$header || $inline) {
			# Ignore inline function implementations and other weirdies
			push @file_content, @copy;
		    } elsif ($header && !$inline) {
			push @file_content, "#FUNCPROTO " . $funcname;

			my $func;

			if (exists($funcs{$funcname})) {
			    $func = $funcs{$funcname};
			    $func->{lineno} = $lineno;
			    $func->{pathname} = $pathname;
			} else {
			    my %new_func = (
				name => $funcname,
				cond => "",
				lineno => $lineno,
				pathname => $pathname,
				);
			    $func = \%new_func;
			    $funcs{$funcname} = $func;
			}
		    }

		    @funcdef = ();
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    $inline = 0;
		    $state = 0;
		    @copy = ();
		}
		if ($line =~ /;/) {
		    $type = "";
		    $qual = "";
		    $funcname = "";
		    @funcdef = ();
		    $state = 0;
		    push @file_content, @copy;
		    @copy = ();
		}
	    }
	    close($fh);

	    if ($header) {
		$header->{content} = \@file_content;
	    }
	}

	sub write_header($)
	{
	    my ($header) = @_;
	    my $path = $header->{path};

	    my @output = ();

	    foreach my $line (@{$header->{content}}) {
		if ($line =~ "^[#]C_MARKER (.*)") {
		    next;
		} elsif ($line =~ "^[#]FUNCPROTO ([_a-zA-Z0-9]+)") {
		    my $funcname = $1;
		    my $func = $funcs{$funcname};
		    if (!$func->{body}) {
			print($func->{pathname}, ":", $func->{lineno}, ": '", $funcname,
			      "' dead prototype\n");
			next;
		    }
		    #push @output, $line;
		    push @output, @{$func->{body}};
		} else {
		    push @output, $line;
		}
	    }

	    open my $fh, ">$path"
		or die "Could not open file '$path' for writing";
	    foreach my $f (@output) {
		print($fh $f, "\n") or die $path;
	    }
	    close($fh) or die $path;

	    print("Git $path\n");
	    if (system("git diff -s --exit-code $path") == 0) {
		print("- no changes, skipping\n");
		return;
	    }

	    if (system("git add $path") != 0) {
		die("'git add $path' failed\n");
	    }

	    open $fh, ">.commit_message"
		or die "Could not open file '.commit_message' for writing";
	    print($fh
		  qq/
	cifs: Scripted clean up $path

	Remove externs, correct argument names and reformat declarations.

	Signed-off-by: David Howells <dhowells\@redhat.com>
	cc: Steve French <sfrench\@samba.org>
	cc: Paulo Alcantara <pc\@manguebit.org>
	cc: Enzo Matsumiya <ematsumiya\@suse.de>
	cc: linux-cifs\@vger.kernel.org
	cc: linux-fsdevel\@vger.kernel.org
	cc: linux-kernel\@vger.kernel.org
	/);
	    close($fh) or die ".commit_message";

	    if (system("git commit -F .commit_message") != 0) {
		die("'git commit $path' failed\n");
	    }
	}

	foreach my $h (keys(%headers)) {
	    write_header($headers{$h});
	}

David Howells (37):
cifs: Scripted clean up fs/smb/client/cached_dir.h
cifs: Scripted clean up fs/smb/client/dfs.h
cifs: Scripted clean up fs/smb/client/cifsproto.h
cifs: Scripted clean up fs/smb/client/cifs_unicode.h
cifs: Scripted clean up fs/smb/client/netlink.h
cifs: Scripted clean up fs/smb/client/cifsfs.h
cifs: Scripted clean up fs/smb/client/dfs_cache.h
cifs: Scripted clean up fs/smb/client/dns_resolve.h
cifs: Scripted clean up fs/smb/client/cifsglob.h
cifs: Scripted clean up fs/smb/client/fscache.h
cifs: Scripted clean up fs/smb/client/fs_context.h
cifs: Scripted clean up fs/smb/client/cifs_spnego.h
cifs: Scripted clean up fs/smb/client/compress.h
cifs: Scripted clean up fs/smb/client/cifs_swn.h
cifs: Scripted clean up fs/smb/client/cifs_debug.h
cifs: Scripted clean up fs/smb/client/smb2proto.h
cifs: Scripted clean up fs/smb/client/reparse.h
cifs: Scripted clean up fs/smb/client/ntlmssp.h
cifs: SMB1 split: Rename cifstransport.c
cifs: SMB1 split: Create smb1proto.h for SMB1 declarations
cifs: SMB1 split: Separate out SMB1 decls into smb1proto.h
cifs: SMB1 split: Move some SMB1 receive bits to smb1transport.c
cifs: SMB1 split: Move some SMB1 received PDU checking bits to
smb1transport.c
cifs: SMB1 split: Add some #includes
cifs: SMB1 split: Split SMB1 protocol defs into smb1pdu.h
cifs: SMB1 split: Adjust #includes
cifs: SMB1 split: Move BCC access functions
cifs: SMB1 split: Don't return smb_hdr from cifs_{,small_}buf_get()
cifs: Fix cifs_dump_mids() to call ->dump_detail
cifs: SMB1 split: Move inline funcs
cifs: SMB1 split: cifs_debug.c
cifs: SMB1 split: misc.c
cifs: SMB1 split: netmisc.c
cifs: SMB1 split: cifsencrypt.c
cifs: SMB1 split: sess.c
cifs: SMB1 split: connect.c
cifs: SMB1 split: Make BCC accessors conditional

fs/smb/client/Makefile        |   10 +-
fs/smb/client/cached_dir.h    |   30 +-
fs/smb/client/cifs_debug.c    |   18 +-
fs/smb/client/cifs_debug.h    |    1 -
fs/smb/client/cifs_spnego.h   |    4 +-
fs/smb/client/cifs_swn.h      |   10 +-
fs/smb/client/cifs_unicode.c  |    1 -
fs/smb/client/cifs_unicode.h  |   17 +-
fs/smb/client/cifsacl.c       |    1 -
fs/smb/client/cifsencrypt.c   |  124 --
fs/smb/client/cifsfs.c        |    1 -
fs/smb/client/cifsfs.h        |  114 +-
fs/smb/client/cifsglob.h      |   29 +-
fs/smb/client/cifspdu.h       | 2377 +--------------------------------
fs/smb/client/cifsproto.h     |  780 ++++-------
fs/smb/client/cifssmb.c       |  147 +-
fs/smb/client/cifstransport.c |  263 ----
fs/smb/client/compress.h      |    3 +-
fs/smb/client/connect.c       |  252 ----
fs/smb/client/dfs.h           |    3 +-
fs/smb/client/dfs_cache.h     |   19 +-
fs/smb/client/dir.c           |    1 -
fs/smb/client/dns_resolve.h   |    4 +-
fs/smb/client/file.c          |    1 -
fs/smb/client/fs_context.c    |    1 -
fs/smb/client/fs_context.h    |   16 +-
fs/smb/client/fscache.h       |   17 +-
fs/smb/client/inode.c         |    1 -
fs/smb/client/ioctl.c         |    1 -
fs/smb/client/link.c          |    1 -
fs/smb/client/misc.c          |  302 +----
fs/smb/client/netlink.h       |    4 +-
fs/smb/client/netmisc.c       |  824 +-----------
fs/smb/client/ntlmssp.h       |   15 +-
fs/smb/client/readdir.c       |    1 -
fs/smb/client/reparse.h       |   14 +-
fs/smb/client/sess.c          |  982 --------------
fs/smb/client/smb1debug.c     |   25 +
fs/smb/client/smb1encrypt.c   |  139 ++
fs/smb/client/smb1maperror.c  |  825 ++++++++++++
fs/smb/client/smb1misc.c      |  189 +++
fs/smb/client/smb1ops.c       |  279 ++--
fs/smb/client/smb1pdu.h       | 2354 ++++++++++++++++++++++++++++++++
fs/smb/client/smb1proto.h     |  336 +++++
fs/smb/client/smb1session.c   |  995 ++++++++++++++
fs/smb/client/smb1transport.c |  561 ++++++++
fs/smb/client/smb2file.c      |    2 +-
fs/smb/client/smb2inode.c     |    2 +-
fs/smb/client/smb2pdu.c       |    2 +-
fs/smb/client/smb2proto.h     |  468 +++----
fs/smb/client/smbencrypt.c    |    1 -
fs/smb/client/transport.c     |    1 -
fs/smb/client/xattr.c         |    1 -
fs/smb/common/smb2pdu.h       |    3 +
54 files changed, 6310 insertions(+), 6262 deletions(-)

delete mode 100644 fs/smb/client/cifstransport.c
create mode 100644 fs/smb/client/smb1debug.c
create mode 100644 fs/smb/client/smb1encrypt.c
create mode 100644 fs/smb/client/smb1maperror.c
create mode 100644 fs/smb/client/smb1misc.c
create mode 100644 fs/smb/client/smb1pdu.h
create mode 100644 fs/smb/client/smb1proto.h
create mode 100644 fs/smb/client/smb1session.c
create mode 100644 fs/smb/client/smb1transport.c

#40 lore raw

I have tentatively merged the first 24 of this series to cifs-2.6.git for-next (pending testing etc) but had merge conflicts with the remainder on current mainline. I also added Enzo's Acked-by

David,
Do you have a newer/rebased version of this series that applies to current mainline? Also are there other patches you would like in for-next?

Chen,
Will we need to rebase your patch series as well? Let me know your current cifs.ko patches for 6.20-rc

Quoted 671 lines · Enzo Matsumiya
Quoted 32 lines · David Howells

Hi Steve,

Could you consider taking these patches? There are two parts to the set.

The first part cleans up the formatting of declarations in the header file. They remove the externs, (re)name the arguments in the declarations to match those in the C file and format them to wrap at 79 chars (this is configurable - search for 79 in the script), aligning all the first argument on each line with the char after the opening bracket.

I've attached the script below so that you can also run it yourself. It does all the git manipulation to generate one commit per header file changed. Run as:

      ./cifs.pl fs/smb/client/*.[ch]

in the kernel source root dir.

The script can be rerun later to readjust any added changes.

Paulo has given his R-b for this subset (labelled cifs: Scripted clean up).

The second part splits the SMB1 parts of cifs protocol layer out into their own files. cifstransport.c is renamed to smb1transport.c also for consistency, though cifssmb.c is left unrenamed (I could rename that to smb1pdu.c). This is pretty much all moving stuff around and few actual code changes. There is one bugfix, though, to cifs_dump_mids().

I've left the splitting of the SMB1 parts of the cifs filesystem layer for a future set of patches as that's would involve removing embedded parts of functions and is easier to get wrong.

Quoted 6 lines

The patches can be found here also:

https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=cifs-cleanup

Thanks,
David

Cheers,

Enzo

Quoted 622 lines

---

      #!/usr/bin/perl -w
      use strict;
      unless (@ARGV) {
          die "Usage: $0 <c_file1> [<c_file2> ...]\n";
      }

      # Data tracking
      my %funcs = ();         # Func name => { func prototype }
      my %headers = ();       # Header filename => { header content }
      my %c_files = ();       # C filename => { ordered func list, header pref }
      my %cmarkers = ();      # C filename marker => { header filename it's in }

      # Parse state
      my $pathname = "-";
      my $lineno = 0;

      sub error(@) {
          print STDERR $pathname, ":", $lineno, ": ", @_, "\n";
          exit(1);
      }

      sub pad($) {
          # Reindent the function arguments to line the arguments up with the char
          # after the opening bracket on the func argument list
          my ($lines) = @_;
          return $lines if ($#{$lines} <= 0);
          my $has_empty = 0;
          for (my $i = 0; $i <= $#{$lines}; $i++) {
              $lines->[$i] =~ s/^[ \t]+//;
              $has_empty = 1 if ($lines->[$i] eq "");
          }

          if ($has_empty) {
              my @clean = grep /.+/, @{$lines};
              $lines = \@clean;
          }

          my $indlen = index($lines->[0], "(");
          return $lines if ($indlen < 0);
          my $indent = "";
          $indlen++;
          $indent .= "\t" x ($indlen / 8);
          $indent .= " " x ($indlen % 8);

          my @padded = ();
          my $acc = "";
          my $len = -$indlen;
          for (my $i = 0; $i <= $#{$lines}; $i++) {
              my $argument = $lines->[$i];
              my $arglen = length($argument);
              my $last = ($i == $#{$lines} ? 1 : 0);

              if ($i == 0 ||
                  $i == 1) {
                  $acc .= $argument;
                  $acc .= ";" if ($last);
                  $len += $arglen + $last;
                  next;
              }
              if (!$acc) {
                  $acc = $indent . $argument;
                  $acc .= ";" if ($last);
                  $len += $arglen + $last;
                  next;
              }
              if ($indlen + $len + 1 + $arglen + $last > 79) {
                  push @padded, $acc;
                  $acc = $indent . $argument;
                  $acc .= ";" if ($last);
                  $len = $arglen + $last;
                  next;
              }

              $acc .= " " . $argument;
              $acc .= ";" if ($last);
              $len += 1 + $arglen + $last;
          }
          push @padded, $acc if ($acc);
          return \@padded;
      }

      sub earliest(@) {
          my $ret = -1;
          foreach (@_) {
              $ret = $_ if ($ret < 0 || ($_ >= 0 && $_ < $ret));
          }
          return $ret;
      }

      foreach my $file (@ARGV) {
          # Open the file for reading.
          next if $file =~ /trace[.]h$/;
          next if $file =~ /smbdirect[.][ch]$/;
          open my $fh, "<$file"
              or die "Could not open file '$file'";
          $pathname = $file;
          $lineno = 0;

          my $filename;
          my @file_content = ();
          my @copy = ();

          my $state = 0;
          my $qual = "";
          my $type = "";
          my $funcname = "";
          my @funcdef = ();
          my $bracket = 0;
          my $comment = 0;
          my $smb1 = 0;
          my $header = 0;
          my $inline = 0;
          my $file_marker = "";
          my $config = "";
          my $c_file = 0;

          $filename = $pathname;
          $filename =~ s!.*/!!;

          if ($file =~ m!.h$!) {
              my %new_h_file = (
                  path    => $pathname,
                  fname   => $filename,
                  content => [],
                  );
              $header = \%new_h_file;
              $headers{$filename} = \%new_h_file;
          } elsif ($file =~ m!.c$!) {
              my %new_c_file = (
                  path  => $pathname,
                  fname => $filename,
                  funcs => [],
                  );
              $c_file = \%new_c_file;
              $c_files{$filename} = \%new_c_file;
          } else {
              warn("Ignoring unexpected file $file\n");
              next;
          }

          $smb1 = 1 if ($file =~ m!/smb1ops.c|/cifssmb.c|/cifstransport.c!);

          foreach my $line (<$fh>) {
              $lineno++;
              chomp($line);
              push @copy, $line;
              if (!$line) {
                  # Blank line
                  push @file_content, @copy;
                  @copy = ();
                  next;
              }

              # Handle continuation or end of block comment.  Look for C file
              # prototype insertion point markers.
              if ($comment) {
                  if ($line =~ m![*]/!) {
                      if ($comment == 2 && $file_marker) {
                          $cmarkers{$file_marker} = $file_marker;
                          push @copy, "#C_MARKER " . $filename;
                          $file_marker = 0;
                      }
                      $comment = 0;
                  } else {
                      $comment++;
                      if ($comment == 2 && $line =~ m! [*] ([a-z][a-z_0-9]*[.][c])$!) {
                          $file_marker = $1;
                          print("Found file marker ", $file_marker, " in ", $filename, "\n");
                      }
                  }
                  push @file_content, @copy;
                  @copy = ();
                  next;
              }

              # Check cpp directives, particularly looking for SMB1 bits
              if ($line =~ /^[#]/) {
                  if ($header) {
                      if ($line =~ /ifdef.*(CONFIG_[A-Z0-9_])/) {
                          error("multiconfig") if $config;
                          $config = $1;
                          $smb1++ if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
                      } elsif ($line =~ /endif/) {
                          $smb1-- if ($config eq "CONFIG_CIFS_ALLOW_INSECURE_LEGACY");
                          $config = "";
                      }
                  }
                  push @file_content, @copy;
                  @copy = ();
                  next;
              }

              # Exclude interference in finding func names and return types
              if ($line =~ /^[{]/ ||
                  $line =~ /##/ ||
                  $line =~ /^[_a-z0-9A-Z]+:$/ || # goto label
                  $line =~ /^do [{]/ ||
                  $line =~ m!^//!) {
                  push @file_content, @copy;
                  @copy = ();
                  next;
              }

              # Start of a block comment
              if ($line =~ m!^/[*]!) {
                  $comment = 1 unless ($line =~ m![*]/!);
                  push @file_content, @copy;
                  @copy = ();
                  next;
              }

              # End of a braced section, such as a function implementation
              if ($line =~ /^[}]/) {
                      $type = "";
                      $qual = "";
                      $funcname = "";
                      @funcdef = ();
                      push @file_content, @copy;
                      @copy = ();
                      next;
              }

              if ($line =~ /^typedef/) {
                  $type = "";
                  $qual = "";
                  $funcname = "";
                  @funcdef = ();
                  push @file_content, @copy;
                  @copy = ();
                  next;
              }

              # Extract function qualifiers.  There may be multiple of these in more
              # or less any order.  Some of them cause the func to be skipped (e.g. inline).

              if ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
                  $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
                  error("Unexpected qualifier '$1'") if ($state != 0);
                  while ($line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)\W/ ||
                         $line =~ /^(static|extern|inline|noinline|noinline_for_stack|__always_inline)$/) {
                      $qual .= " " if ($qual);
                      $qual .= $1;
                      $inline = 1 if ($1 eq "inline");
                      $inline = 1 if ($1 eq "__always_inline");
                      $line = substr($line, length($1));
                      $line =~ s/^\s+//;
                  }
              }

              if ($state == 0) {
                  # Extract what we assume to be the return type
                  if ($line =~ /^\s/) {
                      push @file_content, @copy;
                      @copy = ();
                      next;
                  }
                  while ($line =~ /^(unsigned|signed|bool|char|short|int|long|void|const|volatile|(struct|union|enum)\s+[_a-zA-Z][_a-zA-Z0-9]*|[*]|__init|__exit|__le16|__le32|__le64|__be16|__be32|__be64)/) {
                      $type .= " " if $type;
                      $type .= $1;
                      $line = substr($line, length($1));
                      $line =~ s/^\s+//;
                  }
                  if ($line =~ /^struct [{]/) {
                      # Ignore structure definitions
                      $type = "";
                      $qual = "";
                      $funcname = "";
                      @funcdef = ();
                      push @file_content, @copy;
                      @copy = ();
                      next;
                  }
                  if (index($line, "=") >= 0) {
                      # Ignore assignments
                      $type = "";
                      $qual = "";
                      $funcname = "";
                      @funcdef = "";
                      push @file_content, @copy;
                      @copy = ();
                      next;
                  }

                  # Try and extract a function's type and name
                  while ($line =~ /(^[_a-zA-Z][_a-zA-Z0-9]*)/) {
                      my $name = $1;
                      $line = substr($line, length($name));
                      next if ($line =~ /^[{]/);
                      $line =~ s/^\s+//;

                      my $ch = substr($line, 0, 1);
                      last if ($ch eq "[" || $ch eq ";"); # Global variables

                      if ($ch eq "(") {
                          # Found the function name
                          $state = 1;
                          $line = substr($line, 1);
                          $funcname = $name;
                          my $tmp = $qual . $type . " " . $funcname . "(";
                          $tmp =~ s/[*] /*/;
                          push @funcdef, $tmp;
                          $bracket = 1;
                          last;
                      }

                      if ($type) {
                          last if (index($line, ";") >= 0 && index($line, "(") == -1);
                          error("Unexpected name '$name' after '$type'");
                      }

                      $type .= " " if $type;
                      $type .= $name;
                      if ($line =~ /^(\s*[*]+)/) {
                          my $ptr = $1;
                          $type .= $ptr;
                          $line = substr($line, length($ptr));
                      }
                  }
              }

              # Try and extract a function's argument list
              my $from = 0;
              if ($state == 1) {
                  while (1) {
                      my $o = index($line, "(", $from);
                      my $c = index($line, ")", $from);
                      my $m = index($line, ",", $from);

                      my $b = earliest($o, $c, $m);
                      if ($b < 0) {
                          push @funcdef, $line
                              unless ($line eq "");
                          last;
                      }
                      my $ch = substr($line, $b, 1);

                      # Push the arguments separately on to the list
                      if ($ch eq ",") {
                          push @funcdef, substr($line, 0, $b + 1);
                          $line = substr($line, $b + 1);
                          $from = 0;
                      } elsif ($ch eq "(") {
                          # Handle brackets in the argument list (e.g. function
                          # pointers)
                          $bracket++;
                          $from = $b + 1;
                      } elsif ($ch eq ")") {
                          $bracket--;
                          if ($bracket == 0) {
                              push @funcdef, substr($line, 0, $b + 1);
                              $line = substr($line, $b + 1);
                              $state = 2;
                              last;
                          }
                          $from = $b + 1;
                      }
                  }
              }

              if ($state == 2) {
                  $inline = 1 if ($qual =~ /inline/);
                  #print("QUAL $qual $type $funcname $inline ", $#funcdef, "\n");
                  if (!$header &&
                      $qual !~ /static/ &&
                      $funcname ne "__acquires" &&
                      $funcname ne "__releases" &&
                      $funcname ne "module_init" &&
                      $funcname ne "module_exit" &&
                      $funcname ne "module_param" &&
                      $funcname ne "module_param_call" &&
                      $funcname ne "PROC_FILE_DEFINE" &&
                      $funcname !~ /MODULE_/ &&
                      $funcname !~ /DEFINE_/) {

                      # Okay, we appear to have a function implementation
                      my $func;

                      if (exists($funcs{$funcname})) {
                          $func = $funcs{$funcname};
                          $func->{body} = pad(\@funcdef);
                      } else {
                          my %new_func = (
                              name => $funcname,
                              cond => "",
                              );
                          $func = \%new_func;
                          $funcs{$funcname} = $func;
                          $func->{body} = pad(\@funcdef);
                      }
                      $func->{body} = pad(\@funcdef);

                      if ($funcname eq "cifs_inval_name_dfs_link_error") {
                          $func->{cond} = "#ifdef CONFIG_CIFS_DFS_UPCALL";
                      } elsif ($funcname eq "cifs_listxattr") {
                          $func->{cond} = "#ifdef CONFIG_CIFS_XATTR";
                      }

                      push @{$c_file->{funcs}}, $func;
                  } elsif (!$header || $inline) {
                      # Ignore inline function implementations and other weirdies
                      push @file_content, @copy;
                  } elsif ($header && !$inline) {
                      push @file_content, "#FUNCPROTO " . $funcname;

                      my $func;

                      if (exists($funcs{$funcname})) {
                          $func = $funcs{$funcname};
                          $func->{lineno} = $lineno;
                          $func->{pathname} = $pathname;
                      } else {
                          my %new_func = (
                              name => $funcname,
                              cond => "",
                              lineno => $lineno,
                              pathname => $pathname,
                              );
                          $func = \%new_func;
                          $funcs{$funcname} = $func;
                      }
                  }

                  @funcdef = ();
                  $type = "";
                  $qual = "";
                  $funcname = "";
                  $inline = 0;
                  $state = 0;
                  @copy = ();
              }
              if ($line =~ /;/) {
                  $type = "";
                  $qual = "";
                  $funcname = "";
                  @funcdef = ();
                  $state = 0;
                  push @file_content, @copy;
                  @copy = ();
              }
          }
          close($fh);

          if ($header) {
              $header->{content} = \@file_content;
          }
      }

      sub write_header($)
      {
          my ($header) = @_;
          my $path = $header->{path};

          my @output = ();

          foreach my $line (@{$header->{content}}) {
              if ($line =~ "^[#]C_MARKER (.*)") {
                  next;
              } elsif ($line =~ "^[#]FUNCPROTO ([_a-zA-Z0-9]+)") {
                  my $funcname = $1;
                  my $func = $funcs{$funcname};
                  if (!$func->{body}) {
                      print($func->{pathname}, ":", $func->{lineno}, ": '", $funcname,
                            "' dead prototype\n");
                      next;
                  }
                  #push @output, $line;
                  push @output, @{$func->{body}};
              } else {
                  push @output, $line;
              }
          }

          open my $fh, ">$path"
              or die "Could not open file '$path' for writing";
          foreach my $f (@output) {
              print($fh $f, "\n") or die $path;
          }
          close($fh) or die $path;

          print("Git $path\n");
          if (system("git diff -s --exit-code $path") == 0) {
              print("- no changes, skipping\n");
              return;
          }

          if (system("git add $path") != 0) {
              die("'git add $path' failed\n");
          }

          open $fh, ">.commit_message"
              or die "Could not open file '.commit_message' for writing";
          print($fh
                qq/
      cifs: Scripted clean up $path

      Remove externs, correct argument names and reformat declarations.

      Signed-off-by: David Howells <dhowells\@redhat.com>
      cc: Steve French <sfrench\@samba.org>
      cc: Paulo Alcantara <pc\@manguebit.org>
      cc: Enzo Matsumiya <ematsumiya\@suse.de>
      cc: linux-cifs\@vger.kernel.org
      cc: linux-fsdevel\@vger.kernel.org
      cc: linux-kernel\@vger.kernel.org
      /);
          close($fh) or die ".commit_message";

          if (system("git commit -F .commit_message") != 0) {
              die("'git commit $path' failed\n");
          }
      }

      foreach my $h (keys(%headers)) {
          write_header($headers{$h});
      }

David Howells (37):
cifs: Scripted clean up fs/smb/client/cached_dir.h
cifs: Scripted clean up fs/smb/client/dfs.h
cifs: Scripted clean up fs/smb/client/cifsproto.h
cifs: Scripted clean up fs/smb/client/cifs_unicode.h
cifs: Scripted clean up fs/smb/client/netlink.h
cifs: Scripted clean up fs/smb/client/cifsfs.h
cifs: Scripted clean up fs/smb/client/dfs_cache.h
cifs: Scripted clean up fs/smb/client/dns_resolve.h
cifs: Scripted clean up fs/smb/client/cifsglob.h
cifs: Scripted clean up fs/smb/client/fscache.h
cifs: Scripted clean up fs/smb/client/fs_context.h
cifs: Scripted clean up fs/smb/client/cifs_spnego.h
cifs: Scripted clean up fs/smb/client/compress.h
cifs: Scripted clean up fs/smb/client/cifs_swn.h
cifs: Scripted clean up fs/smb/client/cifs_debug.h
cifs: Scripted clean up fs/smb/client/smb2proto.h
cifs: Scripted clean up fs/smb/client/reparse.h
cifs: Scripted clean up fs/smb/client/ntlmssp.h
cifs: SMB1 split: Rename cifstransport.c
cifs: SMB1 split: Create smb1proto.h for SMB1 declarations
cifs: SMB1 split: Separate out SMB1 decls into smb1proto.h
cifs: SMB1 split: Move some SMB1 receive bits to smb1transport.c
cifs: SMB1 split: Move some SMB1 received PDU checking bits to
smb1transport.c
cifs: SMB1 split: Add some #includes
cifs: SMB1 split: Split SMB1 protocol defs into smb1pdu.h
cifs: SMB1 split: Adjust #includes
cifs: SMB1 split: Move BCC access functions
cifs: SMB1 split: Don't return smb_hdr from cifs_{,small_}buf_get()
cifs: Fix cifs_dump_mids() to call ->dump_detail
cifs: SMB1 split: Move inline funcs
cifs: SMB1 split: cifs_debug.c
cifs: SMB1 split: misc.c
cifs: SMB1 split: netmisc.c
cifs: SMB1 split: cifsencrypt.c
cifs: SMB1 split: sess.c
cifs: SMB1 split: connect.c
cifs: SMB1 split: Make BCC accessors conditional

fs/smb/client/Makefile        |   10 +-
fs/smb/client/cached_dir.h    |   30 +-
fs/smb/client/cifs_debug.c    |   18 +-
fs/smb/client/cifs_debug.h    |    1 -
fs/smb/client/cifs_spnego.h   |    4 +-
fs/smb/client/cifs_swn.h      |   10 +-
fs/smb/client/cifs_unicode.c  |    1 -
fs/smb/client/cifs_unicode.h  |   17 +-
fs/smb/client/cifsacl.c       |    1 -
fs/smb/client/cifsencrypt.c   |  124 --
fs/smb/client/cifsfs.c        |    1 -
fs/smb/client/cifsfs.h        |  114 +-
fs/smb/client/cifsglob.h      |   29 +-
fs/smb/client/cifspdu.h       | 2377 +--------------------------------
fs/smb/client/cifsproto.h     |  780 ++++-------
fs/smb/client/cifssmb.c       |  147 +-
fs/smb/client/cifstransport.c |  263 ----
fs/smb/client/compress.h      |    3 +-
fs/smb/client/connect.c       |  252 ----
fs/smb/client/dfs.h           |    3 +-
fs/smb/client/dfs_cache.h     |   19 +-
fs/smb/client/dir.c           |    1 -
fs/smb/client/dns_resolve.h   |    4 +-
fs/smb/client/file.c          |    1 -
fs/smb/client/fs_context.c    |    1 -
fs/smb/client/fs_context.h    |   16 +-
fs/smb/client/fscache.h       |   17 +-
fs/smb/client/inode.c         |    1 -
fs/smb/client/ioctl.c         |    1 -
fs/smb/client/link.c          |    1 -
fs/smb/client/misc.c          |  302 +----
fs/smb/client/netlink.h       |    4 +-
fs/smb/client/netmisc.c       |  824 +-----------
fs/smb/client/ntlmssp.h       |   15 +-
fs/smb/client/readdir.c       |    1 -
fs/smb/client/reparse.h       |   14 +-
fs/smb/client/sess.c          |  982 --------------
fs/smb/client/smb1debug.c     |   25 +
fs/smb/client/smb1encrypt.c   |  139 ++
fs/smb/client/smb1maperror.c  |  825 ++++++++++++
fs/smb/client/smb1misc.c      |  189 +++
fs/smb/client/smb1ops.c       |  279 ++--
fs/smb/client/smb1pdu.h       | 2354 ++++++++++++++++++++++++++++++++
fs/smb/client/smb1proto.h     |  336 +++++
fs/smb/client/smb1session.c   |  995 ++++++++++++++
fs/smb/client/smb1transport.c |  561 ++++++++
fs/smb/client/smb2file.c      |    2 +-
fs/smb/client/smb2inode.c     |    2 +-
fs/smb/client/smb2pdu.c       |    2 +-
fs/smb/client/smb2proto.h     |  468 +++----
fs/smb/client/smbencrypt.c    |    1 -
fs/smb/client/transport.c     |    1 -
fs/smb/client/xattr.c         |    1 -
fs/smb/common/smb2pdu.h       |    3 +
54 files changed, 6310 insertions(+), 6262 deletions(-)

delete mode 100644 fs/smb/client/cifstransport.c
create mode 100644 fs/smb/client/smb1debug.c
create mode 100644 fs/smb/client/smb1encrypt.c
create mode 100644 fs/smb/client/smb1maperror.c
create mode 100644 fs/smb/client/smb1misc.c
create mode 100644 fs/smb/client/smb1pdu.h
create mode 100644 fs/smb/client/smb1proto.h
create mode 100644 fs/smb/client/smb1session.c
create mode 100644 fs/smb/client/smb1transport.c

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): CAH2r5msqwTqvCzpozKz_SPZsB-qP3RV_pfXZxZwMKMXWfmJHDg@mail.gmail.com

#43 lore raw

Conflicts have been resolved. Please see the last five patches in the GitHub repository tag smb2maperror: https://github.com/chenxiaosonggithub/linux/commits/smb2maperror/

smb/client: introduce KUnit test to check search result of
smb2_error_map_table
smb/client: use bsearch() to find target in smb2_error_map_table smb/client: check whether smb2_error_map_table is sorted in ascending
order
cifs: Autogenerate SMB2 error mapping table
cifs: Label SMB2 statuses with errors

Thanks,
ChenXiaoSong <[email protected]>

Quoted 1 line · Steve French

Kernel branch would be good

#44 lore raw
In reply to Steve French
Quoted 7 lines · Steve French

I have tentatively merged the first 24 of this series to cifs-2.6.git for-next (pending testing etc) but had merge conflicts with the remainder on current mainline. I also added Enzo's Acked-by

David,
Do you have a newer/rebased version of this series that applies to current mainline?

I can make one.

Quoted 1 line

Also are there other patches you would like in for-next?

Not right at the moment.

Quoted 3 lines

Chen,
Will we need to rebase your patch series as well? Let me know your current cifs.ko patches for 6.20-rc

Chen's patches will conflict with mine. Do you want be to base on top of his patches, or would you like his patches on top of these?

David