From patchwork Wed Oct 10 15:11:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 1574341 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8D7A3DFB34 for ; Wed, 10 Oct 2012 15:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932264Ab2JJPBd (ORCPT ); Wed, 10 Oct 2012 11:01:33 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:32848 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932259Ab2JJPBc (ORCPT ); Wed, 10 Oct 2012 11:01:32 -0400 Received: by mail-oa0-f46.google.com with SMTP id h16so575710oag.19 for ; Wed, 10 Oct 2012 08:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=NPKB5FDC2/+/+mFFpLWmkePVrlLOujLuO9q0jupja10=; b=ow1MsUPCCjqWx4KvCuCzdkW/CKp0glJ/P6oeo+GBsXz1gtcuuMzpTNAvVDZf3kTFzr 2jPOrDUYLsVgkTaCUAt5lBDiTa1KXpwQAbbRrujiP37VLRgl/FJu08w6L1kMrvPsEHgN Yilj81wODfByKuLi8nX5ULSGNQI35Ew35ACl4nj9ruFtjQCU8gCHU+g78dQblKKkM99T EM8JesPbTRW4qnftRP0yH1/WniLeMI8vFzZVFL6Y8l/lYWRvYnCGYMvqElHUUgojIgMk T/X1t/eWW8BtaLiCJj1wKu3jlrf1ruWe2wBcwcrU1q8tlPMSpKef76vndax5kbHGuijZ UHVQ== Received: by 10.182.54.103 with SMTP id i7mr5805561obp.62.1349881291475; Wed, 10 Oct 2012 08:01:31 -0700 (PDT) Received: from localhost ([32.97.110.50]) by mx.google.com with ESMTPS id fo6sm1377690obc.20.2012.10.10.08.01.30 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 08:01:30 -0700 (PDT) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar Subject: [PATCH v3] cifs: Add support of Alternate Data Streams Date: Wed, 10 Oct 2012 10:11:46 -0500 Message-Id: <1349881906-9791-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.6.0.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Shirish Pargaonkar Add support of Alternate Data Streams (ads). The generic access flags that cifs client currently employs are sufficient for alternate data streams as well (MS-CIFS 2.2.4.64.1). The stream file and stream type are specified using : after the file name, so that is used to differentiate between a regular file and its alternate data streams and stream types. Since they all have the same file id, each path name, file name:stream name:stream type, has a separate inode with that same file id but a distinct private data (path name) in that inode to distinguish them. This scheme applies only to non-posix compliant servers such as Windows. One operation that does not work is Rename (0x7). Signed-off-by: Shirish Pargaonkar --- fs/cifs/cifsfs.c | 1 + fs/cifs/cifsglob.h | 2 ++ fs/cifs/inode.c | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index e7931cc..3068992 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -264,6 +264,7 @@ cifs_evict_inode(struct inode *inode) { truncate_inode_pages(&inode->i_data, 0); clear_inode(inode); + kfree(inode->i_private); cifs_fscache_release_inode_cookie(inode); } diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index f5af252..26d65c7 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1251,6 +1251,7 @@ struct dfs_info3_param { #define CIFS_FATTR_DELETE_PENDING 0x2 #define CIFS_FATTR_NEED_REVAL 0x4 #define CIFS_FATTR_INO_COLLISION 0x8 +#define CIFS_FATTR_ALTDATASTR 0x10 struct cifs_fattr { u32 cf_flags; @@ -1268,6 +1269,7 @@ struct cifs_fattr { struct timespec cf_atime; struct timespec cf_mtime; struct timespec cf_ctime; + char *cf_private; }; static inline void free_dfs_info_param(struct dfs_info3_param *param) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index afdff79..93b010b 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -619,6 +619,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, struct cifs_fattr fattr; struct cifs_search_info *srchinf = NULL; + fattr.cf_private = NULL; tlink = cifs_sb_tlink(cifs_sb); if (IS_ERR(tlink)) return PTR_ERR(tlink); @@ -746,14 +747,34 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, } if (!*inode) { + if (strstr(full_path, ":")) { + fattr.cf_private = kstrdup(full_path, GFP_KERNEL); + if (!fattr.cf_private) { + rc = -ENOMEM; + goto cgii_exit; + } + fattr.cf_flags |= CIFS_FATTR_ALTDATASTR; + } + *inode = cifs_iget(sb, &fattr); - if (!*inode) + if (*inode) { + if (strstr(full_path, ":") && + !((*inode)->i_flags & S_PRIVATE)) { + (*inode)->i_private = kstrdup(fattr.cf_private, + GFP_KERNEL); + if ((*inode)->i_private) + (*inode)->i_flags |= S_PRIVATE; + else + rc = -ENOMEM; + } + } else rc = -ENOMEM; } else { cifs_fattr_to_inode(*inode, &fattr); } cgii_exit: + kfree(fattr.cf_private); kfree(buf); cifs_put_tlink(tlink); return rc; @@ -784,6 +805,16 @@ cifs_find_inode(struct inode *inode, void *opaque) if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) fattr->cf_flags |= CIFS_FATTR_INO_COLLISION; + /* looking for an inode of a alternate data stream (full pathname) */ + if (fattr->cf_flags & CIFS_FATTR_ALTDATASTR) { + if (!(inode->i_flags & S_PRIVATE)) { + return 0; + } else { + if (strcmp(inode->i_private, fattr->cf_private)) + return 0; + } + } + return 1; }