From patchwork Mon Feb 16 01:18:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 5830971 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8448F9F30C for ; Mon, 16 Feb 2015 01:19:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05D882017E for ; Mon, 16 Feb 2015 01:19:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A16D201B9 for ; Mon, 16 Feb 2015 01:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754817AbbBPBTX (ORCPT ); Sun, 15 Feb 2015 20:19:23 -0500 Received: from cantor2.suse.de ([195.135.220.15]:57312 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752022AbbBPBTE (ORCPT ); Sun, 15 Feb 2015 20:19:04 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0D090AB08; Mon, 16 Feb 2015 01:19:03 +0000 (UTC) Date: Mon, 16 Feb 2015 12:18:56 +1100 From: NeilBrown To: Steve Dickson , NFS Subject: [PATCH - nfs-utils] mountd: fix next_mnt handling for "/" Message-ID: <20150216121856.7efe2237@notabene.brown> X-Mailer: Claws Mail 3.10.1-162-g4d0ed6 (GTK+ 2.24.25; x86_64-suse-linux-gnu) MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the (exported) path passed to next_mnt() is simply "/", next_mnt() will not report any children, as none start with "/" followed by a '/'. So make a special case for strlen(p)==1. In that case, return all children. This gives correct handling if only "/" is exported. Signed-off-by: NeilBrown diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index c23d384d24eb..ac36b6d9f21e 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -377,6 +377,7 @@ static char *next_mnt(void **v, char *p) } else f = *v; while ((me = getmntent(f)) != NULL && + l > 1 && (strncmp(me->mnt_dir, p, l) != 0 || me->mnt_dir[l] != '/')) ;