[ntfs-3g/f18] add junction point fix (bz849332)

Tom Callaway spot at fedoraproject.org
Mon Aug 20 01:17:01 UTC 2012


commit 6b61de232cf0dce1b1ccaa7f376fd91d63adac10
Author: Tom Callaway <spot at fedoraproject.org>
Date:   Sun Aug 19 20:17:33 2012 -0500

    add junction point fix (bz849332)

 ntfs-3g-junction-point-fix.patch |  187 ++++++++++++++++++++++++++++++++++++++
 ntfs-3g.spec                     |    7 +-
 2 files changed, 193 insertions(+), 1 deletions(-)
---
diff --git a/ntfs-3g-junction-point-fix.patch b/ntfs-3g-junction-point-fix.patch
new file mode 100644
index 0000000..90c72ae
--- /dev/null
+++ b/ntfs-3g-junction-point-fix.patch
@@ -0,0 +1,187 @@
+--- ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/dir.c.ref	2012-08-18 09:46:22.000000000 +0200
++++ ntfs-3g_ntfsprogs-2012.1.15/libntfs-3g/dir.c	2012-08-18 11:07:57.000000000 +0200
+@@ -867,6 +867,83 @@
+ 	INDEX_TYPE_ALLOCATION,	/* index allocation */
+ } INDEX_TYPE;
+ 
++/*
++ *		Decode Interix file types
++ *
++ *	Non-Interix types are returned as plain files, because a
++ *	Windows user may force patterns very similar to Interix.
++ */
++
++static u32 ntfs_interix_types(ntfs_inode *ni)
++{
++	ntfs_attr *na;
++	u32 dt_type;
++	le64 magic;
++
++	dt_type = NTFS_DT_UNKNOWN;
++	na = ntfs_attr_open(ni, AT_DATA, NULL, 0);
++	if (na) {
++		/* Unrecognized patterns (eg HID + SYST) are plain files */
++		dt_type = NTFS_DT_REG;
++		if (na->data_size <= 1) {
++			if (!(ni->flags & FILE_ATTR_HIDDEN))
++				dt_type = (na->data_size ?
++						NTFS_DT_SOCK : NTFS_DT_FIFO);
++		} else {
++			if ((na->data_size >= (s64)sizeof(magic))
++			    && (ntfs_attr_pread(na, 0, sizeof(magic), &magic)
++				== sizeof(magic))) {
++				if (magic == INTX_SYMBOLIC_LINK)
++					dt_type = NTFS_DT_LNK;
++				else if (magic == INTX_BLOCK_DEVICE)
++					dt_type = NTFS_DT_BLK;
++				else if (magic == INTX_CHARACTER_DEVICE)
++					dt_type = NTFS_DT_CHR;
++			}
++		}
++		ntfs_attr_close(na);
++	}
++	return (dt_type);
++}
++
++/*
++ *		Decode file types
++ *
++ *	Better only use for Interix types and junctions,
++ *	unneeded complexity when used for plain files or directories
++ *
++ *	Error cases are logged and returned as unknown.
++ */
++
++static u32 ntfs_dir_entry_type(ntfs_inode *dir_ni, MFT_REF mref, FILE_ATTR_FLAGS attributes)
++{
++	ntfs_inode *ni;
++	u32 dt_type;
++
++	dt_type = NTFS_DT_UNKNOWN;
++	ni = ntfs_inode_open(dir_ni->vol, mref);
++	if (ni) {
++		if ((attributes & FILE_ATTR_REPARSE_POINT)
++		    && ntfs_possible_symlink(ni))
++			dt_type = NTFS_DT_LNK;
++		else
++			if ((attributes & FILE_ATTR_SYSTEM)
++			   && !(attributes & FILE_ATTR_I30_INDEX_PRESENT))
++				dt_type = ntfs_interix_types(ni);
++			else
++				dt_type = (attributes
++						& FILE_ATTR_I30_INDEX_PRESENT
++					? NTFS_DT_DIR : NTFS_DT_REG);
++		if (ntfs_inode_close(ni)) {
++				 /* anything special to do ? */
++		}
++	}
++	if (dt_type == NTFS_DT_UNKNOWN)
++		ntfs_log_error("Could not decode the type of inode %lld\n",
++				(long long)MREF(mref));
++	return (dt_type);
++}
++
+ /**
+  * ntfs_filldir - ntfs specific filldir method
+  * @dir_ni:	ntfs inode of current directory
+@@ -901,19 +978,23 @@
+ 				dir_ni->vol->mft_record_size;
+ 	else /* if (index_type == INDEX_TYPE_ROOT) */
+ 		*pos = (u8*)ie - (u8*)iu.ir;
++	mref = le64_to_cpu(ie->indexed_file);
++        metadata = (MREF(mref) != FILE_root) && (MREF(mref) < FILE_first_user);
+ 	/* Skip root directory self reference entry. */
+ 	if (MREF_LE(ie->indexed_file) == FILE_root)
+ 		return 0;
+-	if (ie->key.file_name.file_attributes & FILE_ATTR_I30_INDEX_PRESENT)
++	if ((ie->key.file_name.file_attributes
++		     & (FILE_ATTR_REPARSE_POINT | FILE_ATTR_SYSTEM))
++	    && !metadata)
++		dt_type = ntfs_dir_entry_type(dir_ni, mref,
++					ie->key.file_name.file_attributes);
++	else if (ie->key.file_name.file_attributes
++		     & FILE_ATTR_I30_INDEX_PRESENT)
+ 		dt_type = NTFS_DT_DIR;
+-	else if (fn->file_attributes & FILE_ATTR_SYSTEM)
+-		dt_type = NTFS_DT_UNKNOWN;
+ 	else
+ 		dt_type = NTFS_DT_REG;
+ 
+ 		/* return metadata files and hidden files if requested */
+-	mref = le64_to_cpu(ie->indexed_file);
+-        metadata = (MREF(mref) != FILE_root) && (MREF(mref) < FILE_first_user);
+         if ((!metadata && (NVolShowHidFiles(dir_ni->vol)
+ 				|| !(fn->file_attributes & FILE_ATTR_HIDDEN)))
+             || (NVolShowSysFiles(dir_ni->vol) && (NVolShowHidFiles(dir_ni->vol)
+--- ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.c.ref	2012-08-18 09:44:57.000000000 +0200
++++ ntfs-3g_ntfsprogs-2012.1.15/src/ntfs-3g.c	2012-08-18 09:47:41.000000000 +0200
+@@ -1017,10 +1017,30 @@
+ 	} else {
+ 		struct stat st = { .st_ino = MREF(mref) };
+ 		 
+-		if (dt_type == NTFS_DT_REG)
+-			st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
+-		else if (dt_type == NTFS_DT_DIR)
++		switch (dt_type) {
++		case NTFS_DT_DIR :
+ 			st.st_mode = S_IFDIR | (0777 & ~ctx->dmask); 
++			break;
++		case NTFS_DT_LNK :
++			st.st_mode = S_IFLNK | 0777;
++			break;
++		case NTFS_DT_FIFO :
++			st.st_mode = S_IFIFO;
++			break;
++		case NTFS_DT_SOCK :
++			st.st_mode = S_IFSOCK;
++			break;
++		case NTFS_DT_BLK :
++			st.st_mode = S_IFBLK;
++			break;
++		case NTFS_DT_CHR :
++			st.st_mode = S_IFCHR;
++			break;
++		default : /* unexpected types shown as plain files */
++		case NTFS_DT_REG :
++			st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
++			break;
++		}
+ 		
+ #if defined(__APPLE__) || defined(__DARWIN__)
+ 		/* 
+--- ntfs-3g_ntfsprogs-2012.1.15/src/lowntfs-3g.c.ref	2012-08-18 09:44:57.000000000 +0200
++++ ntfs-3g_ntfsprogs-2012.1.15/src/lowntfs-3g.c	2012-08-18 09:47:41.000000000 +0200
+@@ -920,10 +920,30 @@
+ 	if (MREF(mref) > 1) {
+ 		struct stat st = { .st_ino = MREF(mref) };
+ 		 
+-		if (dt_type == NTFS_DT_REG)
+-			st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
+-		else if (dt_type == NTFS_DT_DIR)
++		switch (dt_type) {
++		case NTFS_DT_DIR :
+ 			st.st_mode = S_IFDIR | (0777 & ~ctx->dmask); 
++			break;
++		case NTFS_DT_LNK :
++			st.st_mode = S_IFLNK | 0777;
++			break;
++		case NTFS_DT_FIFO :
++			st.st_mode = S_IFIFO;
++			break;
++		case NTFS_DT_SOCK :
++			st.st_mode = S_IFSOCK;
++			break;
++		case NTFS_DT_BLK :
++			st.st_mode = S_IFBLK;
++			break;
++		case NTFS_DT_CHR :
++			st.st_mode = S_IFCHR;
++			break;
++		default : /* unexpected types shown as plain files */
++		case NTFS_DT_REG :
++			st.st_mode = S_IFREG | (0777 & ~ctx->fmask);
++			break;
++		}
+ 	        
+ #if defined(__APPLE__) || defined(__DARWIN__)
+ 		/* 
diff --git a/ntfs-3g.spec b/ntfs-3g.spec
index b3ecb67..2578eb1 100644
--- a/ntfs-3g.spec
+++ b/ntfs-3g.spec
@@ -8,7 +8,7 @@
 Name:		ntfs-3g
 Summary:	Linux NTFS userspace driver
 Version:	2012.1.15
-Release:	2%{?dist}
+Release:	3%{?dist}
 License:	GPLv2+
 Group:		System Environment/Base
 Source0:	http://tuxera.com/opensource/%{name}_ntfsprogs-%{version}%{?subver}.tgz
@@ -26,6 +26,7 @@ Provides:	ntfsprogs-fuse = %{epoch}:%{version}-%{release}
 Obsoletes:	ntfsprogs-fuse
 Provides:	fuse-ntfs-3g = %{epoch}:%{version}-%{release}
 Patch0:		ntfs-3g_ntfsprogs-2011.10.9-RC-ntfsck-unsupported-return-0.patch
+Patch1:		ntfs-3g-junction-point-fix.patch
 
 %description
 NTFS-3G is a stable, open source, GPL licensed, POSIX, read/write NTFS 
@@ -67,6 +68,7 @@ included utilities see man 8 ntfsprogs after installation).
 %prep
 %setup -q -n %{name}_ntfsprogs-%{version}%{?subver}
 %patch0 -p1 -b .unsupported
+%patch1 -p1 -b .junction-fix
 
 %build
 CFLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
@@ -168,6 +170,9 @@ cp -a %{SOURCE1} %{buildroot}%{_datadir}/hal/fdi/policy/10osvendor/
 %{_mandir}/man8/ntfs[^m][^o]*.8*
 
 %changelog
+* Sun Aug 19 2012 Tom Callaway <spot at fedoraproject.org> - 2:2012.1.15-3
+- apply upstream fix for junction points (bz849332)
+
 * Fri Jul 20 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2:2012.1.15-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
 


More information about the scm-commits mailing list