From patchwork Fri May 7 17:26:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 97774 Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o47HQN4J009359 for ; Fri, 7 May 2010 17:26:59 GMT Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 7F1BFACFAB; Fri, 7 May 2010 11:26:24 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.8 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mail-qy0-f184.google.com (mail-qy0-f184.google.com [209.85.221.184]) by lists.samba.org (Postfix) with ESMTP id EB23CAC018 for ; Fri, 7 May 2010 11:26:17 -0600 (MDT) Received: by qyk14 with SMTP id 14so2151037qyk.17 for ; Fri, 07 May 2010 10:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=/SZJEi3/MsmgAkaAb5NOjLJe/NYGIoTq0EVQ+mDVyxs=; b=g8O+EWHCPosuMEJoYzs4HI3rT87l0Po1p0UGUKAj4NVDaUnSKPXQK73EUYlKuFY8QZ knpNL1D+qOlWGcWDzpIG5YOv+6Qu5QC+MVtgNozaVgIcirgVYj6fWUpbPMGtjD4vZRBW TjqrbqTJtpzstvioZMGhQZoMdCoFpW0929dvw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=xyNt9Ft+Or50eKelw4SrGPkEHlc9Rv4wyzkZTaup23sJf3dWN9PKXXoB3C7lcQipqA PslVCQqoX/4UWZEqH6lrmo43wCXb6j+ReJIvKRgcGBWBVouXw68bjB2yt9otPsVN2ac4 6MWPal9erBqJGmqak1Z6SVheVgaQUyJL1YMqQ= MIME-Version: 1.0 Received: by 10.224.64.161 with SMTP id e33mr124927qai.299.1273253175809; Fri, 07 May 2010 10:26:15 -0700 (PDT) Received: by 10.229.38.137 with HTTP; Fri, 7 May 2010 10:26:15 -0700 (PDT) Date: Fri, 7 May 2010 12:26:15 -0500 Message-ID: From: Steve French To: linux-cifs-client@lists.samba.org Cc: Jeff Layton Subject: [linux-cifs-client] [PATCH] build mount.smb2 from mount.cifs X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 07 May 2010 17:26:59 +0000 (UTC) diff --git a/mount.cifs.c b/mount.cifs.c index c4eb59a..02ba4ef 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -1,6 +1,6 @@ /* * Mount helper utility for Linux CIFS VFS (virtual filesystem) client - * Copyright (C) 2003,2008 Steve French (sfrench@us.ibm.com) + * Copyright (C) 2003,2010 Steve French (sfrench@us.ibm.com) * Copyright (C) 2008 Jeremy Allison (jra@samba.org) * Copyright (C) 2010 Jeff Layton (jlayton@samba.org) * @@ -147,8 +147,9 @@ struct parsed_mount_info { unsigned int verboseflag:1; }; -const char *thisprogram; +char *thisprogram; /* the basename of the program */ const char *cifs_fstype = "cifs"; +const char *smb2_fstype = "smb2"; static int parse_unc(const char *unc_name, struct parsed_mount_info *parsed_info); @@ -257,6 +258,52 @@ static int mount_cifs_usage(FILE * stream) return 0; } +static int mount_smb2_usage(FILE *stream) +{ + fprintf(stream, "\nUsage: %s -o \n", + thisprogram); + fprintf(stream, "\nMount the remote target, specified as a UNC name,"); + fprintf(stream, " to a local directory.\n\nOptions:\n"); + fprintf(stream, "\tuser=\n\tpass=\n\tdom=\n"); + fprintf(stream, "\nLess commonly used options:"); + fprintf(stream, + "\n\tcredentials=,guest,perm,noperm,rw,ro,"); + fprintf(stream, + "\n\tsep=,iocharset=,exec,noexec"); + fprintf(stream, + "\n\tnolock,directio,sec=,sign"); + fprintf(stream, + "\n\tuid=,gid=,dir_mode=,file_mode="); + fprintf(stream, "\n\nRarely used options:"); + fprintf(stream, + "\n\tport=,rsize=,wsize=,unc=,ip=,"); + fprintf(stream, + "\n\tdev,nodev,hard,soft,intr,"); + fprintf(stream, + "\n\tnointr,ignorecase,noacl,prefixpath=,nobrl"); + fprintf(stream, + "\n\nOptions are described in more detail in the manual page"); + fprintf(stream, "\n\tman 8 mount.smb2\n"); + fprintf(stream, "\nTo display the version number of the mount helper:"); + fprintf(stream, "\n\tmount.smb2 -V\n"); + + if (stream == stderr) + return EX_USAGE; + return 0; +} + +static int mount_usage(FILE *stream) +{ + int rc; + + if (strcmp(thisprogram, "mount.smb2") == 0) + rc = mount_smb2_usage(stream); + else + rc = mount_cifs_usage(stream); + + return rc; +} + /* * CIFS has to "escape" commas in the password field so that they don't * end up getting confused for option delimiters. Copy password into pw @@ -1283,7 +1330,7 @@ static int check_mtab(const char *progname, const char *devname, } static int -add_mtab(char *devname, char *mountpoint, unsigned long flags) +add_mtab(char *devname, char *mountpoint, unsigned long flags, const char *fstype) { int rc = 0; uid_t uid; @@ -1342,7 +1389,8 @@ add_mtab(char *devname, char *mountpoint, unsigned long flags) mountent.mnt_fsname = devname; mountent.mnt_dir = mountpoint; - mountent.mnt_type = (char *)(void *)cifs_fstype; + + mountent.mnt_type = (char *)(void *)fstype; mountent.mnt_opts = (char *)calloc(MTAB_OPTIONS_LEN, 1); if (mountent.mnt_opts) { if (flags & MS_RDONLY) @@ -1529,6 +1577,7 @@ int main(int argc, char **argv) size_t dev_len; struct parsed_mount_info *parsed_info = NULL; pid_t pid; + char *fstype; rc = check_setuid(); if (rc) @@ -1543,11 +1592,11 @@ int main(int argc, char **argv) textdomain(PACKAGE); */ if (!argc || !argv) { - rc = mount_cifs_usage(stderr); + rc = mount_usage(stderr, argv[0]); goto mount_exit; } - thisprogram = argv[0]; + thisprogram = basename(argv[0]); if (thisprogram == NULL) thisprogram = "mount.cifs"; @@ -1569,7 +1618,7 @@ int main(int argc, char **argv) switch (c) { case '?': case 'h': /* help */ - rc = mount_cifs_usage(stdout); + rc = mount_usage(stdout, argv[0]); goto mount_exit; case 'n': ++parsed_info->nomtab; @@ -1598,13 +1647,13 @@ int main(int argc, char **argv) break; default: fprintf(stderr, "unknown command-line option: %c\n", c); - rc = mount_cifs_usage(stderr); + rc = mount_usage(stderr, argv[0]); goto mount_exit; } } if (argc < 3 || argv[optind] == NULL || argv[optind + 1] == NULL) { - rc = mount_cifs_usage(stderr); + rc = mount_usage(stderr, argv[0]); goto mount_exit; } @@ -1721,8 +1770,8 @@ mount_retry: } if (parsed_info->verboseflag) - fprintf(stderr, "mount.cifs kernel mount options: %s", - options); + fprintf(stderr, "%s kernel mount options: %s", + progname, options); if (parsed_info->got_password) { /* @@ -1742,8 +1791,13 @@ mount_retry: if (rc) goto mount_exit; + if (strcmp(progname, "mount.smb2") == 0) + fstype = smb2_fstype; + else + fstype = cifs_fstype; + if (!parsed_info->fakemnt - && mount(dev_name, ".", cifs_fstype, parsed_info->flags, options)) { + && mount(dev_name, ".", fstype, parsed_info->flags, options)) { switch (errno) { case ECONNREFUSED: case EHOSTUNREACH: @@ -1756,7 +1810,7 @@ mount_retry: goto mount_retry; case ENODEV: fprintf(stderr, - "mount error: cifs filesystem not supported by the system\n"); + "mount error: %s filesystem not supported by the system\n", fstype); break; case ENXIO: if (!already_uppercased && @@ -1772,14 +1826,15 @@ mount_retry: fprintf(stderr, "mount error(%d): %s\n", errno, strerror(errno)); fprintf(stderr, - "Refer to the mount.cifs(8) manual page (e.g. man " - "mount.cifs)\n"); + "Refer to the %s(8) manual page (e.g. man " + "%s)\n", progname, progname); rc = EX_FAIL; goto mount_exit; } - if (!parsed_info->nomtab) - rc = add_mtab(dev_name, mountpoint, parsed_info->flags); + if (!parsed_info->nomtab) { + rc = add_mtab(dev_name, mountpoint, parsed_info->flags, fstype); + } mount_exit: if (parsed_info) {