From patchwork Fri Oct 29 10:51:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 290142 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9TApmle011415 for ; Fri, 29 Oct 2010 10:51:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760501Ab0J2Kvs (ORCPT ); Fri, 29 Oct 2010 06:51:48 -0400 Received: from cantor.suse.de ([195.135.220.2]:55900 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757167Ab0J2Kvs (ORCPT ); Fri, 29 Oct 2010 06:51:48 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 11034959EE; Fri, 29 Oct 2010 12:51:46 +0200 (CEST) Message-ID: <4CCAA73D.80009@suse.de> Date: Fri, 29 Oct 2010 16:21:41 +0530 From: Suresh Jayaraman User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100714 SUSE/3.0.6 Thunderbird/3.0.6 MIME-Version: 1.0 To: Jeff Layton Cc: Matt Mackall , linux-cifs@vger.kernel.org Subject: Re: Strange hardlink behavior with CIFS References: <1287428685.16450.282.camel@calx> <4CBD6843.3060702@suse.de> <1288200686.3764.55.camel@calx> <20101027163230.28591971@tlielax.poochiereds.net> <4CC959AC.10301@suse.de> <20101028074650.3e035241@tlielax.poochiereds.net> In-Reply-To: <20101028074650.3e035241@tlielax.poochiereds.net> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Oct 2010 10:51:49 +0000 (UTC) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index f259e4d..bdb508f 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -558,6 +558,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_NLINK_NOT_SET 0x10 /* number of hardlinks unknown */ struct cifs_fattr { u32 cf_flags; diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 2f2632b..6a5455f 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1326,7 +1326,7 @@ openRetry: /* the file_info buf is endian converted by caller */ pfile_info->AllocationSize = pSMBr->AllocationSize; pfile_info->EndOfFile = pSMBr->EndOfFile; - pfile_info->NumberOfLinks = cpu_to_le32(1); + pfile_info->NumberOfLinks = 0; /* not known */ pfile_info->DeletePending = 0; } } diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 39869c3..7ab9a62 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -128,7 +128,8 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) inode->i_mtime = fattr->cf_mtime; inode->i_ctime = fattr->cf_ctime; inode->i_rdev = fattr->cf_rdev; - inode->i_nlink = fattr->cf_nlink; + if (!(fattr->cf_flags & CIFS_FATTR_NLINK_NOT_SET)) + inode->i_nlink = fattr->cf_nlink; inode->i_uid = fattr->cf_uid; inode->i_gid = fattr->cf_gid; @@ -531,7 +532,10 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, fattr->cf_mode &= ~(S_IWUGO); } - fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks); + if (info->NumberOfLinks) + fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks); + else + fattr->cf_flags |= CIFS_FATTR_NLINK_NOT_SET; fattr->cf_uid = cifs_sb->mnt_uid; fattr->cf_gid = cifs_sb->mnt_gid;