From patchwork Fri Mar 26 14:25:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 48635 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by ozlabs.org (Postfix) with ESMTP id 1E386B7CED for ; Sat, 27 Mar 2010 01:25:51 +1100 (EST) Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 20D1F46660; Fri, 26 Mar 2010 08:25:51 -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=-9.9 required=3.8 tests=BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_NEUTRAL 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 mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by lists.samba.org (Postfix) with ESMTP id 9D43546643 for ; Fri, 26 Mar 2010 08:25:43 -0600 (MDT) Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2QEPg4D005341 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Mar 2010 10:25:42 -0400 Received: from localhost.localdomain (vpn-10-105.rdu.redhat.com [10.11.10.105]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2QEPdCY026868 for ; Fri, 26 Mar 2010 10:25:42 -0400 From: Jeff Layton To: linux-cifs-client@lists.samba.org Date: Fri, 26 Mar 2010 10:25:26 -0400 Message-Id: <1269613542-6402-4-git-send-email-jlayton@samba.org> In-Reply-To: <1269613542-6402-1-git-send-email-jlayton@samba.org> References: <1269613542-6402-1-git-send-email-jlayton@samba.org> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Subject: [linux-cifs-client] [PATCH 03/19] mount.cifs: make parse_options return proper mount error codes 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: , MIME-Version: 1.0 Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org From: Jeff Layton Signed-off-by: Jeff Layton --- mount.cifs.c | 33 +++++++++++++++++---------------- 1 files changed, 17 insertions(+), 16 deletions(-) diff --git a/mount.cifs.c b/mount.cifs.c index d282ebc..c0cc13f 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -541,7 +541,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) goto nocopy; } else { fprintf(stderr, "username specified with no parameter\n"); - return 1; /* needs_arg; */ + return EX_USAGE; } } else { if (strnlen(value, 260) < 260) { @@ -573,7 +573,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) domain_name = check_for_domain(&value); } else { fprintf(stderr, "username too long\n"); - return 1; + return EX_USAGE; } } } else if (strncmp(data, "pass", 4) == 0) { @@ -589,13 +589,13 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) mountpassword = strndup(value, MOUNT_PASSWD_SIZE); if (!mountpassword) { fprintf(stderr, "mount.cifs error: %s", strerror(ENOMEM)); - return 1; + return EX_USAGE; } got_password = 1; } } else { fprintf(stderr, "password too long\n"); - return 1; + return EX_USAGE; } goto nocopy; } else if (strncmp(data, "sec", 3) == 0) { @@ -613,14 +613,14 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) got_ip = 1; } else { fprintf(stderr, "ip address too long\n"); - return 1; + return EX_USAGE; } } else if ((strncmp(data, "unc", 3) == 0) || (strncmp(data, "target", 6) == 0) || (strncmp(data, "path", 4) == 0)) { if (!value || !*value) { fprintf(stderr, "invalid path to network resource\n"); - return 1; /* needs_arg; */ + return EX_USAGE; /* needs_arg; */ } else if(strnlen(value,5) < 5) { fprintf(stderr, "UNC name too short"); } @@ -634,7 +634,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) got_unc = 1; } else if (strncmp(value, "\\\\", 2) != 0) { fprintf(stderr, "UNC Path does not begin with // or \\\\ \n"); - return 1; + return EX_USAGE; } else { if(got_unc) fprintf(stderr, "unc name specified twice, ignoring second\n"); @@ -643,7 +643,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) } } else { fprintf(stderr, "CIFS: UNC name too long\n"); - return 1; + return EX_USAGE; } } else if ((strncmp(data, "dom" /* domain */, 3) == 0) || (strncmp(data, "workg", 5) == 0)) { @@ -652,13 +652,13 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) and "WORKGRP" etc. */ if (!value || !*value) { fprintf(stderr, "CIFS: invalid domain name\n"); - return 1; /* needs_arg; */ + return EX_USAGE; } if (strnlen(value, DOMAIN_SIZE+1) < DOMAIN_SIZE+1) { got_domain = 1; } else { fprintf(stderr, "domain name too long\n"); - return 1; + return EX_USAGE; } } else if (strncmp(data, "cred", 4) == 0) { if (value && *value) { @@ -670,7 +670,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) } } else { fprintf(stderr, "invalid credential file name specified\n"); - return 1; + return EX_USAGE; } } else if (strncmp(data, "uid", 3) == 0) { if (value && *value) { @@ -708,7 +708,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) } else if (strcmp(data, "file_mode") == 0 || strcmp(data, "fmask")==0) { if (!value || !*value) { fprintf(stderr, "Option '%s' requires a numerical argument\n", data); - return 1; + return EX_USAGE; } if (value[0] != '0') { @@ -722,7 +722,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) } else if (strcmp(data, "dir_mode") == 0 || strcmp(data, "dmask")==0) { if (!value || !*value) { fprintf(stderr, "Option '%s' requires a numerical argument\n", data); - return 1; + return EX_USAGE; } if (value[0] != '0') { @@ -1379,9 +1379,10 @@ int main(int argc, char ** argv) goto mount_exit; } - if (orgoptions && parse_options(orgoptions, parsed_info)) { - rc = EX_USAGE; - goto mount_exit; + if (orgoptions) { + rc = parse_options(orgoptions, parsed_info); + if (rc) + goto mount_exit; } if (getuid()) {