From patchwork Wed Sep 7 13:45:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Aur=C3=A9lien_Aptel?= X-Patchwork-Id: 9319303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8FF3C6077F for ; Wed, 7 Sep 2016 13:46:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C0CC292EE for ; Wed, 7 Sep 2016 13:46:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FC02292F5; Wed, 7 Sep 2016 13:46:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC8CC292EE for ; Wed, 7 Sep 2016 13:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754227AbcIGNqm (ORCPT ); Wed, 7 Sep 2016 09:46:42 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:44002 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751593AbcIGNql (ORCPT ); Wed, 7 Sep 2016 09:46:41 -0400 Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Wed, 07 Sep 2016 15:46:39 +0200 Received: from localhost (nwb-a10-snat.microfocus.com [10.120.13.202]) by nwb-ext-pat.microfocus.com with ESMTP (TLS encrypted); Wed, 07 Sep 2016 14:46:16 +0100 From: Aurelien Aptel To: linux-cifs@vger.kernel.org Cc: Aurelien Aptel Subject: [PATCH v1 1/1] fs/cifs/dir.c: use correct path separators Date: Wed, 7 Sep 2016 15:45:52 +0200 Message-Id: <1473255952-27579-1-git-send-email-aaptel@suse.com> X-Mailer: git-send-email 2.1.4 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a prefix path needs to be added, current code hardcodes the initial path separator to backslash. Use CIFS_DIR_SEP instead and properly convert path separator in the prefix path. CIFS_MOUNT_USE_PREFIX_PATH is rarely needed (Windows shares with very specific ACL or buggy mount call AFAIK) which explains why the backsplash wasn't a big issue. Signed-off-by: Aurelien Aptel --- fs/cifs/dir.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 4716c54..c85a8bb 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -160,13 +160,15 @@ cifs_bp_rename_retry: if (pplen) { int i; + char oldsep = dirsep == '/' ? '\\' : '/'; cifs_dbg(FYI, "using cifs_sb prepath <%s>\n", cifs_sb->prepath); + + full_path[dfsplen] = dirsep; memcpy(full_path+dfsplen+1, cifs_sb->prepath, pplen-1); - full_path[dfsplen] = '\\'; - for (i = 0; i < pplen-1; i++) - if (full_path[dfsplen+1+i] == '/') - full_path[dfsplen+1+i] = CIFS_DIR_SEP(cifs_sb); + for (i = 1; i < pplen; i++) + if (full_path[dfsplen+i] == oldsep) + full_path[dfsplen+i] = dirsep; } if (dfsplen) {