From patchwork Mon Oct 8 10:47:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1565091 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E95DC40135 for ; Mon, 8 Oct 2012 10:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672Ab2JHKrM (ORCPT ); Mon, 8 Oct 2012 06:47:12 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:44318 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750833Ab2JHKrL (ORCPT ); Mon, 8 Oct 2012 06:47:11 -0400 Received: by mail-qc0-f174.google.com with SMTP id d3so2736380qch.19 for ; Mon, 08 Oct 2012 03:47:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=kvZb81FQUH97DOXSNE/DP8C6xp9wLj1Qq7o3a/17KdI=; b=lhZRrifxpQg45yIG1ZcBTQQcpXv9cyILPOBUK9XLWPRBzjASLHbusZdUI2PRchAOBi L0XOj3KcTePaUzQ8A5g4H4YKnleDhG73RtsEDVqj8Zf8jnT+PyVO8CD0YpWYUdV6d0Wy hsuuNJVlizMsJx1U+u6xpiOc+bH6dEFoeK98+JPoQiVmolKDfQpMRcZveo6pNdCOIHRw ebLz83xXbjkhAR/LnM5G/ejcar54Jn4cXFJ5c69japvjNPZt8f/Gxxk6yex9lhr6aQD2 02i01UvR5Z7ko0fixodXzYhlZR0VjGvp4o87DcCJxwH0O9xndssnHc5XCBvAh8NgqUz3 Q93A== Received: by 10.229.136.132 with SMTP id r4mr6660197qct.95.1349693230683; Mon, 08 Oct 2012 03:47:10 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id z9sm17463732qeg.9.2012.10.08.03.47.08 (version=SSLv3 cipher=OTHER); Mon, 08 Oct 2012 03:47:09 -0700 (PDT) From: Jeff Layton To: linux-cifs@vger.kernel.org Cc: PTrenholme@gmail.com Subject: [PATCH] mount.cifs: implement the "nofail" option Date: Mon, 8 Oct 2012 06:47:04 -0400 Message-Id: <1349693224-17065-1-git-send-email-jlayton@samba.org> X-Mailer: git-send-email 1.7.11.4 X-Gm-Message-State: ALoCoQkALrFTl1pyyZf2cXvGb4IYLuzZO4WQfyI9HIfVDxoPKAbCRCWjf+bio5mLPJjXTd/M+5aG Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The mount(8) manpage lists this as a fs-independent option: nofail: Do not report errors for this device if it does not exist. Implement that in mount.cifs by not returning an error if we were unable to find a suitable address for the mount attempt. Reported-by: Peter Trenholme Signed-off-by: Jeff Layton --- mount.cifs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mount.cifs.c b/mount.cifs.c index 7ee859b..756fce2 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -159,6 +159,7 @@ #define OPT_CRUID 29 #define OPT_BKUPUID 30 #define OPT_BKUPGID 31 +#define OPT_NOFAIL 32 #define MNT_TMP_FILE "/.mtab.cifs.XXXXXX" @@ -178,6 +179,7 @@ struct parsed_mount_info { unsigned int fakemnt:1; unsigned int nomtab:1; unsigned int verboseflag:1; + unsigned int nofail:1; }; const char *thisprogram; @@ -805,6 +807,8 @@ static int parse_opt_token(const char *token) return OPT_BKUPUID; if (strncmp(token, "backupgid", 9) == 0) return OPT_BKUPGID; + if (strncmp(token, "nofail", 6) == 0) + return OPT_NOFAIL; return OPT_ERROR; } @@ -1177,6 +1181,9 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) bkupgid = gr->gr_gid; goto nocopy; + case OPT_NOFAIL: + parsed_info->nofail = 1; + goto nocopy; } /* check size before copying option to buffer */ @@ -2119,7 +2126,7 @@ int main(int argc, char **argv) mount_retry: if (!currentaddress) { fprintf(stderr, "Unable to find suitable address.\n"); - rc = EX_FAIL; + rc = parsed_info->nofail ? 0 : EX_FAIL; goto mount_exit; } strlcpy(options, "ip=", options_size);