Compare commits

..

25 Commits

Author SHA1 Message Date
Erik Larsson 75dcdc2cf3 unistr.c: Fix use-after-free in 'ntfs_uppercase_mbs'.
If 'utf8_to_unicode' throws an error due to an invalid UTF-8 sequence,
then 'n' will be less than 0 and the loop will terminate without storing
anything in '*t'. After the loop the uppercase string's allocation is
freed, however after it is freed it is unconditionally accessed through
'*t', which points into the freed allocation, for the purpose of NULL-
terminating the string. This leads to a use-after-free.
Fixed by only NULL-terminating the string when no error has been thrown.

Thanks for Jeffrey Bencteux for reporting this issue:
https://github.com/tuxera/ntfs-3g/issues/84
2023-06-13 17:47:15 +03:00
Erik Larsson 6b3f096069 ntfsprogs/Makefile.am: Only install manpages for 'extras' when enabled.
We used to always install all the manpages, but some are specific to the
'extras' enabled with the configure option '--enable-extras'.
Fixed by only installing the 'extras' manpages when '--enable-extras' is
active.

Also since this commit touches the list of manpages a bit of cleanup was
done to make sure there's only one manpage per line (helps to minimize
diffs) and also that the manpages are sorted in alphabetical order in
ntfsprogs/Makefile.am to avoid future confusion.

Thanks to user 'opty77' for reporting this issue:
https://github.com/tuxera/ntfs-3g/issues/82
2023-05-28 08:21:34 +03:00
Erik Larsson 233658e5a1 attrib.c: Fix another instance of errno not being set on error. 2023-05-19 12:20:54 +03:00
Erik Larsson 1565b01e21 mft.c: Fix broken free MFT records accounting during bitmap extension.
When the bitmap needs extending, 'vol->free_mft_records' is incremented
by 8*8=64 records. This is due to the bitmap's initialized area being
extended 8 bytes at a time.
However the way 'vol->free_mft_records' is being initialized is that all
the bits that are currently allocated to the MFT bitmap are already
taken into account at initialization time. This leads to a value for
'vol->free_mft_records' that is larger than the actual available number
of MFT records.

For example if there are 20 used MFT records and the bitmap has a 4096
byte allocation where 16 bytes are initialized, the number of free MFT
records are ((8 * 16) - 20) + (8 * (4096 - 16)) = 32748 records
available.
If we now expand the bitmap by 8 initialized bytes, we'd be adding 64
MFT entries according to the logic in the function
'ntfs_mft_bitmap_extend_initialized'.
However we are expanding it within the bounds of the existing allocation
where there is (4096 - 16) bytes free, so they shouldn't be added at all
at this stage.

The result is that our internal accounting is that we have 32748 + 64 =
32812 available MFT records, but in reality we will have 32748 records
available all the time until we expand the allocation beyond 4096 bytes.

Fixed by incrementing 'vol->free_mft_records' when the allocation is
expanded, not when the initialized size is.
2023-05-09 11:25:10 +03:00
Erik Larsson 241ddb3860 index.c: Fix crash when a reparse tag cannot be found in the index.
When 'remove_reparse_index', called by 'ntfs_delete_reparse_index',
fails to look up a reparse key in the index, it leaves the
'ntfs_index_context' without a populated 'INDEX_BLOCK *ib' field.

This causes 'remove_reparse_index' to fail but the index entry is then
marked dirty unconditionally in 'ntfs_index_entry_mark_dirty', called by
'ntfs_delete_reparse_index', even though 'ib' may be NULL.

The following 'ntfs_index_ctx_put' call then starts to write out the
dirty 'INDEX_BLOCK', which causes a crash.

Fixed by only marking the index block dirty in if it's non-NULL.

Thanks to Stephen Greenham <sg@solarisfire.com> for reporting this issue
and providing debug information.
2023-05-03 10:44:57 +02:00
Erik Larsson 01b9bddc0c attrib.c: Fix errno not being set on NULL character in attribute name.
This is an error condition as we jump to err_out, but there's no errno
value set to accompany it. Fixed by setting EIO.
2023-05-03 09:57:34 +02:00
Erik Larsson e73d481a76 mkntfs.c: Enable microsecond-precision volume creation time.
Previously the creation time was filled in with seconds (obtained using
time(NULL)) but the microsecond part was left zeroed. Fixed by using
gettimeofday when available.
2022-12-12 18:51:12 +02:00
Sam James 71ecccf279 configure.ac: fix bashism in fuse check
configure scripts need to be runnable with a POSIX-compliant /bin/sh.

On many (but not all!) systems, /bin/sh is provided by Bash, so errors
like this aren't spotted. Notably Debian defaults to /bin/sh provided
by dash which doesn't tolerate such bashisms as '=='.

This retains compatibility with bash.

Fixes configure warnings/errors like:
```
checking Windows OS... no
./configure: 13360: test: xinternal: unexpected operator
checking for pthread_create in -lpthread... yes
checking Solaris OS... no
```

Signed-off-by: Sam James <sam@gentoo.org>
2022-11-08 13:54:36 +02:00
Jean-Pierre André 78414d9361 Configured for version 2022.10.3 2022-10-03 11:10:36 +02:00
Jean-Pierre André 76c3a799a9 Avoided merging runlists with no runs
Runlists with no runs are tolerated though not expected. However merging
such runlists is problematic as there is no significant vcn to examine.
So avoid merging them, and just return the other runlist.
2022-09-14 08:31:31 +02:00
Jean-Pierre André 18bfc67611 Rejected zero-sized runs
A zero-size run is the universal way to indentify the end of a runlist,
so we must reject zero-sized runs when decompressing a runlist. A
zero-size data run is an error, and a zero-size hole is simply ignored.
2022-09-14 08:29:58 +02:00
Jean-Pierre André 875a1d4e90 Configured for version 2022.5.17
This is a security release. The soname is unchanged as no API has changed.
2022-05-17 08:34:26 +02:00
Jean-Pierre André fb28eef6f1 Hardened the checking of directory offset requested by a readdir
When asked for the next directory entries, make sure the chunk offset
is within valid values, otherwise return no more entries in chunk.
2022-05-10 10:48:18 +02:00
Jean-Pierre André 7f81935f32 Returned an error code when the --help or --version options are used
Accepting --help or --version options may leave the ntfs-3g process in an
unclean state, so reject them while processing options. Also reject
them in libfuse-lite.
2022-05-10 10:44:34 +02:00
Jean-Pierre André bce5734a75 Fixed operation on little endian data
Forcing an even usa_of, in a recent security patch, must be made on cpu
endian data.
2022-05-10 10:40:17 +02:00
Jean-Pierre André 96412e28e5 Fixed possible out-of-buffer condition in ntfsck
A bad usa_count could lead to an out-of-buffer condition. Just avoid
the issue and report the error, still not fix it.
2022-05-10 10:30:24 +02:00
Jean-Pierre André 5ce8941bf4 Made sure there is no null character in an attribute name (bis)
When copying an attribute name which contains a null, it is truncated
and this may lead to accessing non-allocated bytes when relying on the
expected name length. Such (illegal) names must therefore be rejected.
2021-11-05 08:41:20 +01:00
Jean-Pierre André 6efc1305c1 Made sure the client log data does not overflow from restart page
Strengthen the consistency check of the length of restart pages, and
check that log client records are within such a restart page.
2021-10-20 09:53:28 +02:00
Jean-Pierre André 60717a846d Avoided allocating and reading an attribute beyond its full size
Before reading a full attribute value for internal use, its expected
length has been checked to be < 0x40000. However the allocated size
in the runlist may be much bigger as a consequence of a bug or malice.
To prevent malloc'ing excessive size, restrict the size of the last
run to read to the needed length.
2021-09-21 10:56:06 +02:00
Jean-Pierre André 838b6e35b4 Made sure there is no null character in an attribute name
When copying an attribute name which contains a null, it is truncated
and this may lead to accessing non-allocated bytes when relying on the
expected name length. Such names must therefore be rejected.
2021-09-21 10:54:50 +02:00
Jean-Pierre André a8818cf779 Used a default usn when the former one cannot be retrieved
When creating a new MFT record, the former seq_no and usn are retrieved
to avoid the new one to be mistaken for the former one.
This may not be possible when the record is used for the first time
or after some bad error. In such situation use default values.
2021-09-21 10:53:16 +02:00
Jean-Pierre André 92b9fbc6fe Updated the urls present in the ntfsprogs manuals
The urls now point at Github
2021-08-30 10:42:14 +02:00
Jean-Pierre André 399ba862c9 Updated the urls present in ntfs-3g code
The urls now point at Github
2021-08-30 09:27:33 +02:00
Jean-Pierre André 84739d9e4d Updated the ntfs-3g manual
Reordered the options alphabetically and updated the urls.
2021-08-30 09:20:48 +02:00
Jean-Pierre André 88c4a19c5a Updated the README
Added a recommendation to use ntfs-3g packaged by a distribution, and
inserted a link to the Wiki.
2021-08-25 08:50:03 +02:00
78 changed files with 2167 additions and 2644 deletions

11
README
View File

@ -24,7 +24,7 @@ available in Windows 10 can also be read through a plugin.
News, support answers, problem submission instructions, support and discussion
forums, and other information are available on the project web site at
https://github.com/tuxera/ntfs-3g
https://github.com/tuxera/ntfs-3g/wiki
The project has been funded, supported and maintained since 2008 by Tuxera:
@ -47,8 +47,13 @@ See the included file COPYING.LIB.
QUICK INSTALLATION
==================
Linux: Make sure you have the basic development tools and the kernel includes
the FUSE kernel module. Then unpack the source tarball and type:
Most distributions have an up-to-date NTFS-3G package ready for use, and
the recommended way is to install it.
If you need some specific customization, you can compile and install from
the released source code. Make sure you have the basic development tools
and the kernel includes the FUSE kernel module. Then unpack the source
tarball and type:
./configure
make

View File

@ -24,7 +24,7 @@
# Autoconf
AC_PREREQ(2.59)
AC_INIT([ntfs-3g],[2021.8.22],[ntfs-3g-devel@lists.sf.net])
AC_INIT([ntfs-3g],[2022.10.3],[ntfs-3g-devel@lists.sf.net])
LIBNTFS_3G_VERSION="89"
AC_CONFIG_SRCDIR([src/ntfs-3g.c])
@ -228,7 +228,7 @@ esac
if test "x${enable_ntfs_3g}" != "xyes"; then
with_fuse="none"
elif test "x${with_fuse}" == "x"; then
elif test "x${with_fuse}" = "x"; then
AC_MSG_CHECKING([fuse compatibility])
case "${target_os}" in
linux*|solaris*)

View File

@ -47,35 +47,35 @@
/* flags which are set to mean exec, write or read */
#define FILE_READ (FILE_READ_DATA)
#define FILE_WRITE le32_or(FILE_WRITE_DATA, le32_or(FILE_APPEND_DATA, \
le32_or(READ_CONTROL, le32_or(FILE_WRITE_ATTRIBUTES, FILE_WRITE_EA))))
#define FILE_WRITE (FILE_WRITE_DATA | FILE_APPEND_DATA \
| READ_CONTROL | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA)
#define FILE_EXEC (FILE_EXECUTE)
#define DIR_READ FILE_LIST_DIRECTORY
#define DIR_WRITE le32_or(FILE_ADD_FILE, le32_or(FILE_ADD_SUBDIRECTORY, le32_or(FILE_DELETE_CHILD, \
le32_or(READ_CONTROL, le32_or(FILE_WRITE_ATTRIBUTES, FILE_WRITE_EA)))))
#define DIR_WRITE (FILE_ADD_FILE | FILE_ADD_SUBDIRECTORY | FILE_DELETE_CHILD \
| READ_CONTROL | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA)
#define DIR_EXEC (FILE_TRAVERSE)
/* flags tested for meaning exec, write or read */
/* tests for write allow for interpretation of a sticky bit */
#define FILE_GREAD le32_or(FILE_READ_DATA, GENERIC_READ)
#define FILE_GWRITE le32_or(FILE_WRITE_DATA, le32_or(FILE_APPEND_DATA, GENERIC_WRITE))
#define FILE_GEXEC le32_or(FILE_EXECUTE, GENERIC_EXECUTE)
#define DIR_GREAD le32_or(FILE_LIST_DIRECTORY, GENERIC_READ)
#define DIR_GWRITE le32_or(FILE_ADD_FILE, le32_or(FILE_ADD_SUBDIRECTORY, GENERIC_WRITE))
#define DIR_GEXEC le32_or(FILE_TRAVERSE, GENERIC_EXECUTE)
#define FILE_GREAD (FILE_READ_DATA | GENERIC_READ)
#define FILE_GWRITE (FILE_WRITE_DATA | FILE_APPEND_DATA | GENERIC_WRITE)
#define FILE_GEXEC (FILE_EXECUTE | GENERIC_EXECUTE)
#define DIR_GREAD (FILE_LIST_DIRECTORY | GENERIC_READ)
#define DIR_GWRITE (FILE_ADD_FILE | FILE_ADD_SUBDIRECTORY | GENERIC_WRITE)
#define DIR_GEXEC (FILE_TRAVERSE | GENERIC_EXECUTE)
/* standard owner (and administrator) rights */
#define OWNER_RIGHTS le32_or(DELETE, le32_or(READ_CONTROL, le32_or(WRITE_DAC, le32_or(WRITE_OWNER, \
le32_or(SYNCHRONIZE, \
le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_WRITE_ATTRIBUTES, \
le32_or(FILE_READ_EA, FILE_WRITE_EA))))))))
#define OWNER_RIGHTS (DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER \
| SYNCHRONIZE \
| FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES \
| FILE_READ_EA | FILE_WRITE_EA)
/* standard world rights */
#define WORLD_RIGHTS le32_or(READ_CONTROL, le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_READ_EA, \
SYNCHRONIZE)))
#define WORLD_RIGHTS (READ_CONTROL | FILE_READ_ATTRIBUTES | FILE_READ_EA \
| SYNCHRONIZE)
/* inheritance flags for files and directories */

View File

@ -52,8 +52,6 @@
#include <sys/param.h>
#endif
#include "types.h"
#ifndef __BYTE_ORDER
# if defined(_BYTE_ORDER)
# define __BYTE_ORDER _BYTE_ORDER
@ -190,8 +188,6 @@
#endif
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
/* Unsigned from LE to CPU conversion. */
#define le16_to_cpu(x) (u16)__le16_to_cpu((u16)(x))
@ -306,325 +302,4 @@
#define const_cpu_to_sbe32(x) ((sbe32) __constant_cpu_to_be32((u32) x))
#define const_cpu_to_sbe64(x) ((sbe64) __constant_cpu_to_be64((u64) x))
#define le16_eq(a, b) ((a) == (b))
#define le32_eq(a, b) ((a) == (b))
#define le64_eq(a, b) ((a) == (b))
#define sle16_eq(a, b) ((a) == (b))
#define sle64_eq(a, b) ((a) == (b))
#define be16_eq(a, b) ((a) == (b))
#define be32_eq(a, b) ((a) == (b))
#define le16_cmpz(a) (!(a))
#define le32_cmpz(a) (!(a))
#define le64_cmpz(a) (!(a))
#define sle64_cmpz(a) (!(a))
#define be16_cmpz(a) (!(a))
#define le16_andz(a, b) (!((a) & (b)))
#define le32_andz(a, b) (!((a) & (b)))
#define le16_and(a, b) ((a) & (b))
#define le32_and(a, b) ((a) & (b))
#define le64_and(a, b) ((a) & (b))
#define le16_or(a, b) ((a) | (b))
#define le32_or(a, b) ((a) | (b))
#define le64_or(a, b) ((a) | (b))
#define le16_xor(a, b) ((a) ^ (b))
#define le32_xor(a, b) ((a) ^ (b))
#define le64_xor(a, b) ((a) ^ (b))
#define le16_not(a) (~(a))
#define le32_not(a) (~(a))
#define le64_not(a) (~(a))
#else
/* Unsigned from LE to CPU conversion. */
static inline u16 le16_to_cpu(le16 x) { return (u16) __le16_to_cpu(x.value); }
static inline u32 le32_to_cpu(le32 x) { return (u32) __le32_to_cpu(x.value); }
static inline u64 le64_to_cpu(le64 x) { return (u64) __le64_to_cpu(x.value); }
static inline u16 le16_to_cpup(const le16 *x) {
return (u16) __le16_to_cpu(x->value);
}
static inline u32 le32_to_cpup(const le32 *x) {
return (u32) __le32_to_cpu(x->value);
}
static inline u64 le64_to_cpup(const le64 *x) {
return (u64) __le64_to_cpu(x->value);
}
/* Signed from LE to CPU conversion. */
static inline s16 sle16_to_cpu(sle16 x) { return (s16) __le16_to_cpu(x.value); }
static inline s32 sle32_to_cpu(sle32 x) { return (s32) __le32_to_cpu(x.value); }
static inline s64 sle64_to_cpu(sle64 x) { return (s64) __le64_to_cpu(x.value); }
static inline s16 sle16_to_cpup(const sle16 *x) {
return (s16) __le16_to_cpu(x->value);
}
static inline s32 sle32_to_cpup(const sle32 *x) {
return (s32) __le32_to_cpu(x->value);
}
static inline s64 sle64_to_cpup(const sle64 *x) {
return (s64) __le64_to_cpu(x->value);
}
/* Unsigned from CPU to LE conversion. */
static inline le16 cpu_to_le16(u16 x) {
le16 leval; leval.value = __cpu_to_le16(x); return leval;
}
static inline le32 cpu_to_le32(u32 x) {
le32 leval; leval.value = __cpu_to_le32(x); return leval;
}
static inline le64 cpu_to_le64(u64 x) {
le64 leval; leval.value = __cpu_to_le64(x); return leval;
}
static inline le16 cpu_to_le16p(const u16 *x) {
le16 leval; leval.value = __cpu_to_le16(*x); return leval;
}
static inline le32 cpu_to_le32p(const u32 *x) {
le32 leval; leval.value = __cpu_to_le32(*x); return leval;
}
static inline le64 cpu_to_le64p(const u64 *x) {
le64 leval; leval.value = __cpu_to_le64(*x); return leval;
}
/* Signed from CPU to LE conversion. */
static inline sle16 cpu_to_sle16(s16 x) {
sle16 leval; leval.value = __cpu_to_le16(x); return leval;
}
static inline sle32 cpu_to_sle32(s32 x) {
sle32 leval; leval.value = __cpu_to_le32(x); return leval;
}
static inline sle64 cpu_to_sle64(s64 x) {
sle64 leval; leval.value = __cpu_to_le64(x); return leval;
}
static inline sle16 cpu_to_sle16p(const s16 *x) {
sle16 leval; leval.value = __cpu_to_le16(*x); return leval;
}
static inline sle32 cpu_to_sle32p(const s32 *x) {
sle32 leval; leval.value = __cpu_to_le32(*x); return leval;
}
static inline sle64 cpu_to_sle64p(const s64 *x) {
sle64 leval; leval.value = __cpu_to_le64(*x); return leval;
}
/* Unsigned from BE to CPU conversion. */
static inline u16 be16_to_cpu(be16 x) { return (u16) __be16_to_cpu(x.value); }
static inline u32 be32_to_cpu(be32 x) { return (u32) __be32_to_cpu(x.value); }
static inline u64 be64_to_cpu(be64 x) { return (u64) __be64_to_cpu(x.value); }
static inline u16 be16_to_cpup(const be16 *x) {
return (u16) __be16_to_cpu(x->value);
}
static inline u32 be32_to_cpup(const be32 *x) {
return (u32) __be32_to_cpu(x->value);
}
static inline u64 be64_to_cpup(const be64 *x) {
return (u64) __be64_to_cpu(x->value);
}
/* Signed from BE to CPU conversion. */
static inline s16 sbe16_to_cpu(sbe16 x) { return (s16) __be16_to_cpu(x.value); }
static inline s32 sbe32_to_cpu(sbe32 x) { return (s32) __be32_to_cpu(x.value); }
static inline s64 sbe64_to_cpu(sbe64 x) { return (s64) __be64_to_cpu(x.value); }
static inline s16 sbe16_to_cpup(const sbe16 *x) {
return (s16) __be16_to_cpu(x->value);
}
static inline s32 sbe32_to_cpup(const sbe32 *x) {
return (s32) __be32_to_cpu(x->value);
}
static inline s64 sbe64_to_cpup(const sbe64 *x) {
return (s64) __be64_to_cpu(x->value);
}
/* Unsigned from CPU to BE conversion. */
static inline be16 cpu_to_be16(u16 x) {
be16 beval; beval.value = __cpu_to_be16(x); return beval;
}
static inline be32 cpu_to_be32(u32 x) {
be32 beval; beval.value = __cpu_to_be32(x); return beval;
}
static inline be64 cpu_to_be64(u64 x) {
be64 beval; beval.value = __cpu_to_be64(x); return beval;
}
static inline be16 cpu_to_be16p(const u16 *x) {
be16 beval; beval.value = __cpu_to_be16(*x); return beval;
}
static inline be32 cpu_to_be32p(const u32 *x) {
be32 beval; beval.value = __cpu_to_be32(*x); return beval;
}
static inline be64 cpu_to_be64p(const u64 *x) {
be64 beval; beval.value = __cpu_to_be64(*x); return beval;
}
/* Signed from CPU to BE conversion. */
static inline sbe16 cpu_to_sbe16(s16 x) {
sbe16 beval; beval.value = __cpu_to_be16(x); return beval;
}
static inline sbe32 cpu_to_sbe32(s32 x) {
sbe32 beval; beval.value = __cpu_to_be32(x); return beval;
}
static inline sbe64 cpu_to_sbe64(s64 x) {
sbe64 beval; beval.value = __cpu_to_be64(x); return beval;
}
static inline sbe16 cpu_to_sbe16p(const s16 *x) {
sbe16 beval; beval.value = __cpu_to_be16(*x); return beval;
}
static inline sbe32 cpu_to_sbe32p(const s32 *x) {
sbe32 beval; beval.value = __cpu_to_be32(*x); return beval;
}
static inline sbe64 cpu_to_sbe64p(const s64 *x) {
sbe64 beval; beval.value = __cpu_to_be64(*x); return beval;
}
/* Constant endianness conversion defines. */
#define const_le16_to_cpu(x) ((u16) __constant_le16_to_cpu((u16)(x.value)))
#define const_le32_to_cpu(x) ((u32) __constant_le32_to_cpu((u32)(x.value)))
#define const_le64_to_cpu(x) ((u64) __constant_le64_to_cpu((u64)(x.value)))
#define const_cpu_to_le16(x) ((le16)(u16) __constant_cpu_to_le16((u16)(x)))
#define const_cpu_to_le32(x) ((le32) __constant_cpu_to_le32((u32)(x)))
#define const_cpu_to_le64(x) ((le64) __constant_cpu_to_le64((u64)(x)))
#define const_sle16_to_cpu(x) ((s16) __constant_le16_to_cpu((u16)(x.value)))
#define const_sle32_to_cpu(x) ((s32) __constant_le32_to_cpu((u32)(x.value)))
#define const_sle64_to_cpu(x) ((s64) __constant_le64_to_cpu((u64)(x.value)))
#define const_cpu_to_sle16(x) ((sle16)(u16) __constant_cpu_to_le16((u16)(x)))
#define const_cpu_to_sle32(x) ((sle32) __constant_cpu_to_le32((u32)(x)))
#define const_cpu_to_sle64(x) ((sle64) __constant_cpu_to_le64((u64)(x)))
#define const_be16_to_cpu(x) ((u16) __constant_be16_to_cpu((u16)(x.value)))
#define const_be32_to_cpu(x) ((u32) __constant_be32_to_cpu((u32)(x.value)))
#define const_be64_to_cpu(x) ((s64) __constant_be64_to_cpu((u64)(x.value)))
#define const_cpu_to_be16(x) ((be16)(u16) __constant_cpu_to_be16((u16)(x)))
#define const_cpu_to_be32(x) ((be32) __constant_cpu_to_be32((u32)(x)))
#define const_cpu_to_be64(x) ((be64) __constant_cpu_to_be64((u64)(x)))
#define const_sbe16_to_cpu(x) ((s16) __constant_be16_to_cpu((u16)(x.value)))
#define const_sbe32_to_cpu(x) ((s32) __constant_be32_to_cpu((u32)(x.value)))
#define const_sbe64_to_cpu(x) ((s64) __constant_be64_to_cpu((u64)(x.value)))
#define const_cpu_to_sbe16(x) ((sbe16)(u16) __constant_cpu_to_be16((u16)(x)))
#define const_cpu_to_sbe32(x) ((sbe32) __constant_cpu_to_be32((u32)(x)))
#define const_cpu_to_sbe64(x) ((sbe64) __constant_cpu_to_be64((u64)(x)))
static inline int le16_eq(le16 a, le16 b) { return (a.value == b.value); }
static inline int le32_eq(le32 a, le32 b) { return (a.value == b.value); }
static inline int le64_eq(le64 a, le64 b) { return (a.value == b.value); }
static inline int sle16_eq(sle16 a, sle16 b) { return (a.value == b.value); }
static inline int sle64_eq(sle64 a, sle64 b) { return (a.value == b.value); }
static inline int be16_eq(be16 a, be16 b) { return (a.value == b.value); }
static inline int be32_eq(be32 a, be32 b) { return (a.value == b.value); }
static inline int le16_cmpz(le16 a) { return !a.value; }
static inline int le32_cmpz(le32 a) { return !a.value; }
static inline int le64_cmpz(le64 a) { return !a.value; }
static inline int sle64_cmpz(sle64 a) { return !a.value; }
static inline int be16_cmpz(be16 a) { return !a.value; }
static inline int le16_andz(le16 a, le16 b) { return !(a.value & b.value); }
static inline int le32_andz(le32 a, le32 b) { return !(a.value & b.value); }
static inline le16 le16_and(le16 a, le16 b)
{
return (le16) ((u16) (a.value & b.value));
}
static inline le32 le32_and(le32 a, le32 b)
{
return (le32) (a.value & b.value);
}
static inline le64 le64_and(le64 a, le64 b)
{
return (le64) (a.value & b.value);
}
static inline le16 le16_or(le16 a, le16 b)
{
return (le16) ((u16) (a.value | b.value));
}
static inline le32 le32_or(le32 a, le32 b)
{
return (le32) (a.value | b.value);
}
static inline le64 le64_or(le64 a, le64 b)
{
return (le64) (a.value | b.value);
}
static inline le16 le16_xor(le16 a, le16 b)
{
return (le16) ((u16) (a.value ^ b.value));
}
static inline le32 le32_xor(le32 a, le32 b)
{
return (le32) (a.value ^ b.value);
}
static inline le64 le64_xor(le64 a, le64 b)
{
return (le64) (a.value ^ b.value);
}
static inline le16 le16_not(le16 a) { return (le16) ((u16) (~a.value)); }
static inline le32 le32_not(le32 a) { return (le32) (~a.value); }
static inline le64 le64_not(le64 a) { return (le64) (~a.value); }
#endif /* !ENABLE_STRICT_ENDIANNESS_CHECKING ... */
#endif /* defined _NTFS_ENDIANS_H */

View File

@ -100,13 +100,7 @@ typedef struct {
* Magic identifiers present at the beginning of all ntfs record containing
* records (like mft records for example).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 NTFS_RECORD_TYPES;
static const le32
#else
typedef enum {
#endif
/* Found in $MFT/$DATA. */
magic_FILE = const_cpu_to_le32(0x454c4946), /* Mft entry. */
magic_INDX = const_cpu_to_le32(0x58444e49), /* Index buffer. */
@ -131,18 +125,14 @@ typedef enum {
magic_empty = const_cpu_to_le32(0xffffffff),/* Record is empty and has
to be initialized before
it can be used. */
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} NTFS_RECORD_TYPES;
#else
__NTFS_RECORD_TYPES_end;
#endif
/*
* Generic magic comparison macros. Finally found a use for the ## preprocessor
* operator! (-8
*/
#define ntfs_is_magic(x, m) ( le32_eq(x, magic_##m) )
#define ntfs_is_magicp(p, m) ( le32_eq(*p, magic_##m) )
#define ntfs_is_magic(x, m) ( (u32)(x) == (u32)magic_##m )
#define ntfs_is_magicp(p, m) ( *(u32*)(p) == (u32)magic_##m )
/*
* Specialised magic comparison macros for the NTFS_RECORD_TYPES defined above.
@ -270,24 +260,14 @@ typedef enum {
* index, that means an INDEX_ROOT and an INDEX_ALLOCATION with a name other
* than "$I30". It is unknown if it is limited to metadata files only.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 MFT_RECORD_FLAGS;
static const MFT_RECORD_FLAGS
#else
typedef enum {
#endif
MFT_RECORD_IN_USE = const_cpu_to_le16(0x0001),
MFT_RECORD_IS_DIRECTORY = const_cpu_to_le16(0x0002),
MFT_RECORD_IS_4 = const_cpu_to_le16(0x0004),
MFT_RECORD_IS_VIEW_INDEX = const_cpu_to_le16(0x0008),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
MFT_REC_SPACE_FILLER = 0xffff, /* Just to make flags
16-bit. */
} __attribute__((__packed__)) MFT_RECORD_FLAGS;
#else
__MFT_RECORD_FLAGS_end;
#endif
/*
* mft references (aka file references or file record segment references) are
@ -515,13 +495,7 @@ typedef struct {
* enum exchanging AT_ for the dollar sign ($). If that isn't a revealing
* choice of symbol... (-;
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 ATTR_TYPES;
static const ATTR_TYPES
#else
typedef enum {
#endif
AT_UNUSED = const_cpu_to_le32( 0),
AT_STANDARD_INFORMATION = const_cpu_to_le32( 0x10),
AT_ATTRIBUTE_LIST = const_cpu_to_le32( 0x20),
@ -541,11 +515,7 @@ typedef enum {
AT_LOGGED_UTILITY_STREAM = const_cpu_to_le32( 0x100),
AT_FIRST_USER_DEFINED_ATTRIBUTE = const_cpu_to_le32( 0x1000),
AT_END = const_cpu_to_le32(0xffffffff),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} ATTR_TYPES;
#else
__ATTR_TYPES_end;
#endif
/**
* enum COLLATION_RULES - The collation rules for sorting views/indexes/etc
@ -583,13 +553,7 @@ typedef enum {
* the 2nd object_id. If the first le32 values of both object_ids were
* equal then the second le32 values would be compared, etc.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 COLLATION_RULES;
static const COLLATION_RULES
#else
typedef enum {
#endif
COLLATION_BINARY = const_cpu_to_le32(0),
COLLATION_FILE_NAME = const_cpu_to_le32(1),
COLLATION_UNICODE_STRING = const_cpu_to_le32(2),
@ -597,11 +561,7 @@ typedef enum {
COLLATION_NTOFS_SID = const_cpu_to_le32(17),
COLLATION_NTOFS_SECURITY_HASH = const_cpu_to_le32(18),
COLLATION_NTOFS_ULONGS = const_cpu_to_le32(19),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} COLLATION_RULES;
#else
__COLLATION_RULES_end;
#endif
/**
* enum ATTR_DEF_FLAGS -
@ -613,13 +573,7 @@ typedef enum {
* name attribute has this flag set and this is the only attribute indexed in
* NT4.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 ATTR_DEF_FLAGS;
static const ATTR_DEF_FLAGS
#else
typedef enum {
#endif
ATTR_DEF_INDEXABLE = const_cpu_to_le32(0x02), /* Attribute can be
indexed. */
ATTR_DEF_MULTIPLE = const_cpu_to_le32(0x04), /* Attribute type
@ -644,11 +598,7 @@ typedef enum {
non-resident. Without this, only log
modifications if the attribute is
resident. */
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} ATTR_DEF_FLAGS;
#else
__ATTR_DEF_FLAGS_end;
#endif
/**
* struct ATTR_DEF -
@ -678,24 +628,14 @@ typedef struct {
/**
* enum ATTR_FLAGS - Attribute flags (16-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 ATTR_FLAGS;
static const ATTR_FLAGS
#else
typedef enum {
#endif
ATTR_IS_COMPRESSED = const_cpu_to_le16(0x0001),
ATTR_COMPRESSION_MASK = const_cpu_to_le16(0x00ff), /* Compression
method mask. Also, first
illegal value. */
ATTR_IS_ENCRYPTED = const_cpu_to_le16(0x4000),
ATTR_IS_SPARSE = const_cpu_to_le16(0x8000),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} __attribute__((__packed__)) ATTR_FLAGS;
#else
__ATTR_FLAGS_end;
#endif
/*
* Attribute compression.
@ -885,13 +825,7 @@ typedef ATTR_RECORD ATTR_REC;
/**
* enum FILE_ATTR_FLAGS - File attribute flags (32-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 FILE_ATTR_FLAGS;
static const FILE_ATTR_FLAGS
#else
typedef enum {
#endif
/*
* These flags are only present in the STANDARD_INFORMATION attribute
* (in the field file_attributes).
@ -954,11 +888,7 @@ typedef enum {
* $FILE_NAME attributes.
*/
FILE_ATTR_VIEW_INDEX_PRESENT = const_cpu_to_le32(0x20000000),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} __attribute__((__packed__)) FILE_ATTR_FLAGS;
#else
__FILE_ATTR_FLAGS_end;
#endif
/*
* NOTE on times in NTFS: All times are in MS standard time format, i.e. they
@ -1575,13 +1505,7 @@ typedef struct {
*
* Defines the access rights.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 ACCESS_MASK;
static const ACCESS_MASK
#else
typedef enum {
#endif
/*
* The specific rights (bits 0 to 15). Depend on the type of the
* object being secured by the ACE.
@ -1709,11 +1633,7 @@ typedef enum {
* above for the descriptions of the rights granted.
*/
GENERIC_READ = const_cpu_to_le32(0x80000000),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} ACCESS_MASK;
#else
__ACCESS_MASK_end;
#endif
/**
* struct GENERIC_MAPPING -
@ -1753,20 +1673,10 @@ typedef struct {
/**
* enum OBJECT_ACE_FLAGS - The object ACE flags (32-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 OBJECT_ACE_FLAGS;
static const OBJECT_ACE_FLAGS
#else
typedef enum {
#endif
ACE_OBJECT_TYPE_PRESENT = const_cpu_to_le32(1),
ACE_INHERITED_OBJECT_TYPE_PRESENT = const_cpu_to_le32(2),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} OBJECT_ACE_FLAGS;
#else
__OBJECT_ACE_FLAGS_end;
#endif
/**
* struct ACCESS_ALLOWED_OBJECT_ACE -
@ -1871,13 +1781,7 @@ typedef enum {
* and all pointer fields are expressed as offsets from the
* beginning of the security descriptor.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 SECURITY_DESCRIPTOR_CONTROL;
static const SECURITY_DESCRIPTOR_CONTROL
#else
typedef enum {
#endif
SE_OWNER_DEFAULTED = const_cpu_to_le16(0x0001),
SE_GROUP_DEFAULTED = const_cpu_to_le16(0x0002),
SE_DACL_PRESENT = const_cpu_to_le16(0x0004),
@ -1892,11 +1796,7 @@ typedef enum {
SE_SACL_PROTECTED = const_cpu_to_le16(0x2000),
SE_RM_CONTROL_VALID = const_cpu_to_le16(0x4000),
SE_SELF_RELATIVE = const_cpu_to_le16(0x8000),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} __attribute__((__packed__)) SECURITY_DESCRIPTOR_CONTROL;
#else
__SECURITY_DESCRIPTOR_CONTROL_end;
#endif
/**
* struct SECURITY_DESCRIPTOR_RELATIVE -
@ -2110,13 +2010,7 @@ typedef struct {
/**
* enum VOLUME_FLAGS - Possible flags for the volume (16-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 VOLUME_FLAGS;
static const VOLUME_FLAGS
#else
typedef enum {
#endif
VOLUME_IS_DIRTY = const_cpu_to_le16(0x0001),
VOLUME_RESIZE_LOG_FILE = const_cpu_to_le16(0x0002),
VOLUME_UPGRADE_ON_MOUNT = const_cpu_to_le16(0x0004),
@ -2126,11 +2020,7 @@ typedef enum {
VOLUME_CHKDSK_UNDERWAY = const_cpu_to_le16(0x4000),
VOLUME_MODIFIED_BY_CHKDSK = const_cpu_to_le16(0x8000),
VOLUME_FLAGS_MASK = const_cpu_to_le16(0xc03f),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} __attribute__((__packed__)) VOLUME_FLAGS;
#else
__VOLUME_FLAGS_end;
#endif
/**
* struct VOLUME_INFORMATION - Attribute: Volume information (0x70).
@ -2304,13 +2194,7 @@ typedef struct {
/**
* enum QUOTA_FLAGS - Quota flags (32-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 QUOTA_FLAGS;
static const QUOTA_FLAGS
#else
typedef enum {
#endif
/* The user quota flags. Names explain meaning. */
QUOTA_FLAG_DEFAULT_LIMITS = const_cpu_to_le32(0x00000001),
QUOTA_FLAG_LIMIT_REACHED = const_cpu_to_le32(0x00000002),
@ -2329,11 +2213,7 @@ typedef enum {
QUOTA_FLAG_OUT_OF_DATE = const_cpu_to_le32(0x00000200),
QUOTA_FLAG_CORRUPT = const_cpu_to_le32(0x00000400),
QUOTA_FLAG_PENDING_DELETES = const_cpu_to_le32(0x00000800),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} QUOTA_FLAGS;
#else
__QUOTA_FLAGS_end;
#endif
/**
* struct QUOTA_CONTROL_ENTRY -
@ -2390,32 +2270,16 @@ typedef struct {
/**
* enum PREDEFINED_OWNER_IDS - Predefined owner_id values (32-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 PREDEFINED_OWNER_IDS;
static const PREDEFINED_OWNER_IDS
#else
typedef enum {
#endif
QUOTA_INVALID_ID = const_cpu_to_le32(0x00000000),
QUOTA_DEFAULTS_ID = const_cpu_to_le32(0x00000001),
QUOTA_FIRST_USER_ID = const_cpu_to_le32(0x00000100),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} PREDEFINED_OWNER_IDS;
#else
__PREDEFINED_OWNER_IDS_end;
#endif
/**
* enum INDEX_ENTRY_FLAGS - Index entry flags (16-bit).
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 INDEX_ENTRY_FLAGS;
static const INDEX_ENTRY_FLAGS
#else
typedef enum {
#endif
INDEX_ENTRY_NODE = const_cpu_to_le16(1), /* This entry contains a
sub-node, i.e. a reference to an index
block in form of a virtual cluster
@ -2424,12 +2288,8 @@ typedef enum {
entry in an index block. The index
entry does not represent a file but it
can point to a sub-node. */
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
INDEX_ENTRY_SPACE_FILLER = 0xffff, /* Just to force 16-bit width. */
} __attribute__((__packed__)) INDEX_ENTRY_FLAGS;
#else
__INDEX_ENTRY_FLAGS_end;
#endif
/**
* struct INDEX_ENTRY_HEADER - This the index entry header (see below).
@ -2560,13 +2420,7 @@ typedef struct {
* Some flags may be used in bits 12 to 15 to further describe the
* reparse point.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 PREDEFINED_REPARSE_TAGS;
static const PREDEFINED_REPARSE_TAGS
#else
typedef enum {
#endif
IO_REPARSE_TAG_DIRECTORY = const_cpu_to_le32(0x10000000),
IO_REPARSE_TAG_IS_ALIAS = const_cpu_to_le32(0x20000000),
IO_REPARSE_TAG_IS_HIGH_LATENCY = const_cpu_to_le32(0x40000000),
@ -2601,11 +2455,7 @@ typedef enum {
IO_REPARSE_TAG_VALID_VALUES = const_cpu_to_le32(0xf000ffff),
IO_REPARSE_PLUGIN_SELECT = const_cpu_to_le32(0xffff0fff),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} PREDEFINED_REPARSE_TAGS;
#else
__PREDEFINED_REPARSE_TAGS_end;
#endif
/**
* struct REPARSE_POINT - Attribute: Reparse point (0xc0).
@ -2831,24 +2681,14 @@ typedef struct {
typedef EFS_DF_CERTIFICATE_THUMBPRINT_HEADER EFS_DF_CERT_THUMBPRINT_HEADER;
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le64 INTX_FILE_TYPES;
static const INTX_FILE_TYPES
#else
typedef enum {
#endif
INTX_SYMBOLIC_LINK =
const_cpu_to_le64(0x014B4E4C78746E49ULL), /* "IntxLNK\1" */
INTX_CHARACTER_DEVICE =
const_cpu_to_le64(0x0052484378746E49ULL), /* "IntxCHR\0" */
INTX_BLOCK_DEVICE =
const_cpu_to_le64(0x004B4C4278746E49ULL), /* "IntxBLK\0" */
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} INTX_FILE_TYPES;
#else
__INTX_FILE_TYPES_end;
#endif
typedef struct {
INTX_FILE_TYPES magic; /* Intx file magic. */

View File

@ -110,18 +110,10 @@ typedef struct {
* These are the so far known RESTART_AREA_* flags (16-bit) which contain
* information about the log file in which they are present.
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
static const le16
#else
enum {
#endif
RESTART_VOLUME_IS_CLEAN = const_cpu_to_le16(0x0002),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
RESTART_SPACE_FILLER = 0xffff, /* gcc: Force enum bit width to 16. */
} __attribute__((__packed__));
#else
__RESTART_AREA_FLAGS_end;
#endif
typedef le16 RESTART_AREA_FLAGS;
@ -343,25 +335,15 @@ typedef struct {
*
* (Or is it log record pages?)
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 LOG_RECORD_FLAGS;
static const LOG_RECORD_FLAGS
#else
typedef enum {
#endif
LOG_RECORD_MULTI_PAGE = const_cpu_to_le16(0x0001), /* ??? */
/* The flags below were introduced in Windows 10 */
LOG_RECORD_DELETING = const_cpu_to_le16(0x0002),
LOG_RECORD_ADDING = const_cpu_to_le16(0x0004),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
LOG_RECORD_SIZE_PLACE_HOLDER = 0xffff,
/* This has nothing to do with the log record. It is only so
gcc knows to make the flags 16-bit. */
} __attribute__((__packed__)) LOG_RECORD_FLAGS;
#else
__LOG_RECORD_FLAGS_end;
#endif
/**
* struct LOG_CLIENT_ID - The log client id structure identifying a log client.
@ -375,22 +357,12 @@ typedef struct {
* LOG_RECORD_TYPE : types of log records
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 LOG_RECORD_TYPE;
static const LOG_RECORD_TYPE
#else
enum {
#endif
LOG_STANDARD = const_cpu_to_le32(1),
LOG_CHECKPOINT = const_cpu_to_le32(2),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
LOG_RECORD_TYPE_PLACE_HOLDER = 0xffffffffU
} ;
typedef le32 LOG_RECORD_TYPE;
#else
__LOG_RECORD_TYPE_end;
#endif
/*
* ATTRIBUTE_FLAGS : flags describing the kind of NTFS record
@ -398,22 +370,12 @@ typedef le32 LOG_RECORD_TYPE;
* These flags were introduced in Vista, only two flags are known?
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le16 ATTRIBUTE_FLAGS;
static const ATTRIBUTE_FLAGS
#else
enum {
#endif
ACTS_ON_MFT = const_cpu_to_le16(2),
ACTS_ON_INDX = const_cpu_to_le16(8),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
ATTRIBUTE_FLAGS_PLACE_HOLDER = 0xffff,
} ;
typedef le16 ATTRIBUTE_FLAGS;
#else
__ATTRIBUTE_FLAGS_end;
#endif
#define LOG_RECORD_HEAD_SZ 0x30 /* size of header of struct LOG_RECORD */

View File

@ -27,10 +27,6 @@
#include "config.h"
#endif
#if !defined(ENABLE_STRICT_ENDIANNESS_CHECKING)
#define ENABLE_STRICT_ENDIANNESS_CHECKING 1
#endif /* !defined(ENABLE_STRICT_ENDIANNESS_CHECKING) */
#if HAVE_STDINT_H || !HAVE_CONFIG_H
#include <stdint.h>
#endif
@ -48,7 +44,6 @@ typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
typedef u16 le16;
typedef u32 le32;
typedef u64 le64;
@ -68,71 +63,6 @@ typedef u64 sle64;
typedef u16 sbe16;
typedef u32 sbe32;
typedef u64 sbe64;
#else
typedef union {
u8 data[2];
u16 value;
} le16;
typedef union {
u8 data[4];
u32 value;
} le32;
typedef union {
u8 data[8];
u64 value;
} le64;
typedef union {
u8 data[2];
u16 value;
} be16;
typedef union {
u8 data[4];
u32 value;
} be32;
typedef union {
u8 data[8];
u64 value;
} be64;
/*
* Declare s{l,b}e{16,32,64} to be unsigned because we do not want sign
* extension on BE architectures.
*/
typedef union {
u8 data[2];
u16 value;
} sle16;
typedef union {
u8 data[4];
u32 value;
} sle32;
typedef union {
u8 data[8];
u64 value;
} sle64;
typedef union {
u8 data[2];
u16 value;
} sbe16;
typedef union {
u8 data[4];
u32 value;
} sbe32;
typedef union {
u8 data[8];
u64 value;
} sbe64;
#endif /* !ENABLE_STRICT_ENDIANNESS_CHECKING ... */
typedef le16 ntfschar; /* 2-byte Unicode character type. */
#define UCHAR_T_SIZE_BITS 1

View File

@ -2223,7 +2223,7 @@ static void fuse_lib_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
}
}
if (dh->filled) {
if (off < dh->len) {
if ((off >= 0) && (off < dh->len)) {
if (off + size > dh->len)
size = dh->len - off;
} else

View File

@ -670,11 +670,10 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args)
fprintf(stderr, "fuse: 'allow_other' and 'allow_root' options are mutually exclusive\n");
goto out;
}
res = 0;
res = -1;
if (mo.ishelp)
goto out;
res = -1;
if (get_mnt_flag_opts(&mnt_opts, mo.flags) == -1)
goto out;
#ifndef __SOLARIS__

View File

@ -189,29 +189,29 @@ static int is_world_sid(const SID * usid)
return (
/* check whether S-1-1-0 : world */
((usid->sub_authority_count == 1)
&& be16_eq(usid->identifier_authority.high_part, const_cpu_to_be16(0))
&& be32_eq(usid->identifier_authority.low_part, const_cpu_to_be32(1))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(0)))
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(1))
&& (usid->sub_authority[0] == const_cpu_to_le32(0)))
/* check whether S-1-5-32-545 : local user */
|| ((usid->sub_authority_count == 2)
&& be16_eq(usid->identifier_authority.high_part, const_cpu_to_be16(0))
&& be32_eq(usid->identifier_authority.low_part, const_cpu_to_be32(5))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(32))
&& le32_eq(usid->sub_authority[1], const_cpu_to_le32(545)))
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(32))
&& (usid->sub_authority[1] == const_cpu_to_le32(545)))
/* check whether S-1-5-11 : authenticated user */
|| ((usid->sub_authority_count == 1)
&& be16_eq(usid->identifier_authority.high_part, const_cpu_to_be16(0))
&& be32_eq(usid->identifier_authority.low_part, const_cpu_to_be32(5))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(11)))
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(11)))
#if !POSIXACLS
/* check whether S-1-5-4 : interactive user */
|| ((usid->sub_authority_count == 1)
&& be16_eq(usid->identifier_authority.high_part, const_cpu_to_be16(0))
&& be32_eq(usid->identifier_authority.low_part, const_cpu_to_be32(5))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(4)))
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(4)))
#endif /* !POSIXACLS */
);
}
@ -225,9 +225,9 @@ static int is_world_sid(const SID * usid)
BOOL ntfs_is_user_sid(const SID *usid)
{
return ((usid->sub_authority_count == 5)
&& be16_eq(usid->identifier_authority.high_part, const_cpu_to_be16(0))
&& be32_eq(usid->identifier_authority.low_part, const_cpu_to_be32(5))
&& le32_eq(usid->sub_authority[0], const_cpu_to_le32(21)));
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (usid->sub_authority[0] == const_cpu_to_le32(21)));
}
/*
@ -243,8 +243,8 @@ static BOOL ntfs_known_group_sid(const SID *usid)
{
/* count == 1 excludes S-1-5-5-X-Y (logon) */
return ((usid->sub_authority_count == 1)
&& be16_eq(usid->identifier_authority.high_part, const_cpu_to_be16(0))
&& be32_eq(usid->identifier_authority.low_part, const_cpu_to_be32(5))
&& (usid->identifier_authority.high_part == const_cpu_to_be16(0))
&& (usid->identifier_authority.low_part == const_cpu_to_be32(5))
&& (le32_to_cpu(usid->sub_authority[0]) >= 1)
&& (le32_to_cpu(usid->sub_authority[0]) <= 6));
}
@ -649,10 +649,10 @@ BOOL ntfs_valid_descr(const char *securattr, unsigned int attrsz)
&& (!offsacl
|| ((offsacl >= sizeof(SECURITY_DESCRIPTOR_RELATIVE))
&& (offsacl+sizeof(ACL) <= attrsz)))
&& le32_andz(phead->owner, const_cpu_to_le32(3))
&& le32_andz(phead->group, const_cpu_to_le32(3))
&& le32_andz(phead->dacl, const_cpu_to_le32(3))
&& le32_andz(phead->sacl, const_cpu_to_le32(3))
&& !(phead->owner & const_cpu_to_le32(3))
&& !(phead->group & const_cpu_to_le32(3))
&& !(phead->dacl & const_cpu_to_le32(3))
&& !(phead->sacl & const_cpu_to_le32(3))
&& (ntfs_attr_size(securattr) <= attrsz)
&& ntfs_valid_sid((const SID*)&securattr[offowner])
&& ntfs_valid_sid((const SID*)&securattr[offgroup])
@ -662,12 +662,12 @@ BOOL ntfs_valid_descr(const char *securattr, unsigned int attrsz)
* but "Dr Watson" has SE_DACL_PRESENT though no DACL
*/
&& (!offdacl
|| (!le16_andz(phead->control, SE_DACL_PRESENT)
|| ((phead->control & SE_DACL_PRESENT)
&& ((pdacl->revision == ACL_REVISION)
|| (pdacl->revision == ACL_REVISION_DS))))
/* same for SACL */
&& (!offsacl
|| (!le16_andz(phead->control, SE_SACL_PRESENT)
|| ((phead->control & SE_SACL_PRESENT)
&& ((psacl->revision == ACL_REVISION)
|| (psacl->revision == ACL_REVISION_DS))))) {
/*
@ -757,61 +757,61 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
&& acceptable
&& (!fordir
|| (poldace->flags & NO_PROPAGATE_INHERIT_ACE)
|| !le32_andz(poldace->mask, le32_or(GENERIC_ALL, le32_or(GENERIC_READ,
le32_or(GENERIC_WRITE, GENERIC_EXECUTE)))))
|| (poldace->mask & (GENERIC_ALL | GENERIC_READ
| GENERIC_WRITE | GENERIC_EXECUTE)))
&& !ntfs_same_sid(&poldace->sid, ownersid)
&& !ntfs_same_sid(&poldace->sid, groupsid)) {
pnewace = (ACCESS_ALLOWED_ACE*)
((char*)newacl + dst);
memcpy(pnewace,poldace,acesz);
/* reencode GENERIC_ALL */
if (!le32_andz(pnewace->mask, GENERIC_ALL)) {
pnewace->mask = le32_and(pnewace->mask, le32_not(GENERIC_ALL));
if (pnewace->mask & GENERIC_ALL) {
pnewace->mask &= ~GENERIC_ALL;
if (fordir)
pnewace->mask = le32_or(pnewace->mask, le32_or(OWNER_RIGHTS,
le32_or(DIR_READ,
le32_or(DIR_WRITE,
DIR_EXEC))));
pnewace->mask |= OWNER_RIGHTS
| DIR_READ
| DIR_WRITE
| DIR_EXEC;
else
/*
* The last flag is not defined for a file,
* however Windows sets it, so do the same
*/
pnewace->mask = le32_or(pnewace->mask, le32_or(OWNER_RIGHTS,
le32_or(FILE_READ,
le32_or(FILE_WRITE,
le32_or(FILE_EXEC,
const_cpu_to_le32(0x40))))));
pnewace->mask |= OWNER_RIGHTS
| FILE_READ
| FILE_WRITE
| FILE_EXEC
| const_cpu_to_le32(0x40);
}
/* reencode GENERIC_READ (+ EXECUTE) */
if (!le32_andz(pnewace->mask, GENERIC_READ)) {
if (pnewace->mask & GENERIC_READ) {
if (fordir)
pnewace->mask = le32_or(pnewace->mask, le32_or(OWNER_RIGHTS,
le32_or(DIR_READ,
DIR_EXEC)));
pnewace->mask |= OWNER_RIGHTS
| DIR_READ
| DIR_EXEC;
else
pnewace->mask = le32_or(pnewace->mask, le32_or(OWNER_RIGHTS,
le32_or(FILE_READ,
FILE_EXEC)));
pnewace->mask = le32_and(pnewace->mask, le32_not(le32_or(GENERIC_READ,
le32_or(GENERIC_EXECUTE,
le32_or(WRITE_DAC,
le32_or(WRITE_OWNER,
le32_or(DELETE, le32_or(FILE_WRITE_EA,
FILE_WRITE_ATTRIBUTES))))))));
pnewace->mask |= OWNER_RIGHTS
| FILE_READ
| FILE_EXEC;
pnewace->mask &= ~(GENERIC_READ
| GENERIC_EXECUTE
| WRITE_DAC
| WRITE_OWNER
| DELETE | FILE_WRITE_EA
| FILE_WRITE_ATTRIBUTES);
}
/* reencode GENERIC_WRITE */
if (!le32_andz(pnewace->mask, GENERIC_WRITE)) {
if (pnewace->mask & GENERIC_WRITE) {
if (fordir)
pnewace->mask = le32_or(pnewace->mask, le32_or(OWNER_RIGHTS,
DIR_WRITE));
pnewace->mask |= OWNER_RIGHTS
| DIR_WRITE;
else
pnewace->mask = le32_or(pnewace->mask, le32_or(OWNER_RIGHTS,
FILE_WRITE));
pnewace->mask = le32_and(pnewace->mask, le32_not(le32_or(GENERIC_WRITE,
le32_or(WRITE_DAC,
le32_or(WRITE_OWNER,
FILE_DELETE_CHILD)))));
pnewace->mask |= OWNER_RIGHTS
| FILE_WRITE;
pnewace->mask &= ~(GENERIC_WRITE
| WRITE_DAC
| WRITE_OWNER
| FILE_DELETE_CHILD);
}
/* remove inheritance flags */
pnewace->flags &= ~(OBJECT_INHERIT_ACE
@ -825,16 +825,16 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
&& ntfs_same_sid(&poldace->sid, authsid)) {
if (pauthace) {
pauthace->flags |= pnewace->flags;
pauthace->mask = le32_or(pauthace->mask, pnewace->mask);
pauthace->mask |= pnewace->mask;
} else {
pauthace = pnewace;
if (!le16_cmpz(inherited))
if (inherited)
pnewace->flags |= INHERITED_ACE;
dst += acesz;
newcnt++;
}
} else {
if (!le16_cmpz(inherited))
if (inherited)
pnewace->flags |= INHERITED_ACE;
dst += acesz;
newcnt++;
@ -844,7 +844,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
* Inheritance for access, specific to
* creator-owner (and creator-group)
*/
if ((fordir || le16_cmpz(inherited)
if ((fordir || !inherited
|| (poldace->flags
& (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE)))
&& acceptable) {
@ -863,12 +863,12 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
pnewace->flags &= ~(OBJECT_INHERIT_ACE
| CONTAINER_INHERIT_ACE
| INHERIT_ONLY_ACE);
if (!le16_cmpz(inherited))
if (inherited)
pnewace->flags |= INHERITED_ACE;
if ((pnewace->type == ACCESS_ALLOWED_ACE_TYPE)
&& pownerace
&& !(pnewace->flags & ~pownerace->flags)) {
pownerace->mask = le32_or(pownerace->mask, pnewace->mask);
pownerace->mask |= pnewace->mask;
} else {
dst += usidsz + 8;
newcnt++;
@ -881,7 +881,7 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
pnewace->flags &= ~(OBJECT_INHERIT_ACE
| CONTAINER_INHERIT_ACE
| INHERIT_ONLY_ACE);
if (!le16_cmpz(inherited))
if (inherited)
pnewace->flags |= INHERITED_ACE;
dst += gsidsz + 8;
newcnt++;
@ -909,13 +909,13 @@ int ntfs_inherit_acl(const ACL *oldacl, ACL *newacl,
&& !(poldace->flags & NO_PROPAGATE_INHERIT_ACE)
&& !ntfs_same_sid(&poldace->sid, ownersid)
&& !ntfs_same_sid(&poldace->sid, groupsid)) {
if (!le32_andz(poldace->mask, le32_or(GENERIC_ALL, le32_or(GENERIC_READ,
le32_or(GENERIC_WRITE, GENERIC_EXECUTE)))))
if ((poldace->mask & (GENERIC_ALL | GENERIC_READ
| GENERIC_WRITE | GENERIC_EXECUTE)))
pnewace->flags |= INHERIT_ONLY_ACE;
else
pnewace->flags &= ~INHERIT_ONLY_ACE;
}
if (!le16_cmpz(inherited))
if (inherited)
pnewace->flags |= INHERITED_ACE;
/*
* Prepare grouping similar ACE for authenticated users
@ -2480,19 +2480,19 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
if (isdir) {
gflags = DIR_INHERITANCE;
if (mode & S_IXUSR)
grants = le32_or(grants, DIR_EXEC);
grants |= DIR_EXEC;
if (mode & S_IWUSR)
grants = le32_or(grants, DIR_WRITE);
grants |= DIR_WRITE;
if (mode & S_IRUSR)
grants = le32_or(grants, DIR_READ);
grants |= DIR_READ;
} else {
gflags = FILE_INHERITANCE;
if (mode & S_IXUSR)
grants = le32_or(grants, FILE_EXEC);
grants |= FILE_EXEC;
if (mode & S_IWUSR)
grants = le32_or(grants, FILE_WRITE);
grants |= FILE_WRITE;
if (mode & S_IRUSR)
grants = le32_or(grants, FILE_READ);
grants |= FILE_READ;
}
/* a possible ACE to deny owner what he/she would */
@ -2506,41 +2506,41 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
if (isdir) {
pdace->flags = DIR_INHERITANCE;
if (mode & (S_IXGRP | S_IXOTH))
denials = le32_or(denials, DIR_EXEC);
denials |= DIR_EXEC;
if (mode & (S_IWGRP | S_IWOTH))
denials = le32_or(denials, DIR_WRITE);
denials |= DIR_WRITE;
if (mode & (S_IRGRP | S_IROTH))
denials = le32_or(denials, DIR_READ);
denials |= DIR_READ;
} else {
pdace->flags = FILE_INHERITANCE;
if (mode & (S_IXGRP | S_IXOTH))
denials = le32_or(denials, FILE_EXEC);
denials |= FILE_EXEC;
if (mode & (S_IWGRP | S_IWOTH))
denials = le32_or(denials, FILE_WRITE);
denials |= FILE_WRITE;
if (mode & (S_IRGRP | S_IROTH))
denials = le32_or(denials, FILE_READ);
denials |= FILE_READ;
}
} else {
if (isdir) {
pdace->flags = DIR_INHERITANCE;
if ((mode & S_IXOTH) && !(mode & S_IXGRP))
denials = le32_or(denials, DIR_EXEC);
denials |= DIR_EXEC;
if ((mode & S_IWOTH) && !(mode & S_IWGRP))
denials = le32_or(denials, DIR_WRITE);
denials |= DIR_WRITE;
if ((mode & S_IROTH) && !(mode & S_IRGRP))
denials = le32_or(denials, DIR_READ);
denials |= DIR_READ;
} else {
pdace->flags = FILE_INHERITANCE;
if ((mode & S_IXOTH) && !(mode & S_IXGRP))
denials = le32_or(denials, FILE_EXEC);
denials |= FILE_EXEC;
if ((mode & S_IWOTH) && !(mode & S_IWGRP))
denials = le32_or(denials, FILE_WRITE);
denials |= FILE_WRITE;
if ((mode & S_IROTH) && !(mode & S_IRGRP))
denials = le32_or(denials, FILE_READ);
denials |= FILE_READ;
}
}
denials = le32_and(denials, le32_not(grants));
if (!le32_cmpz(denials)) {
denials &= ~grants;
if (denials) {
pdace->type = ACCESS_DENIED_ACE_TYPE;
pdace->size = cpu_to_le16(usidsz + 8);
pdace->mask = denials;
@ -2587,19 +2587,19 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
if (isdir) {
gflags = DIR_INHERITANCE;
if (mode & S_IXGRP)
grants = le32_or(grants, DIR_EXEC);
grants |= DIR_EXEC;
if (mode & S_IWGRP)
grants = le32_or(grants, DIR_WRITE);
grants |= DIR_WRITE;
if (mode & S_IRGRP)
grants = le32_or(grants, DIR_READ);
grants |= DIR_READ;
} else {
gflags = FILE_INHERITANCE;
if (mode & S_IXGRP)
grants = le32_or(grants, FILE_EXEC);
grants |= FILE_EXEC;
if (mode & S_IWGRP)
grants = le32_or(grants, FILE_WRITE);
grants |= FILE_WRITE;
if (mode & S_IRGRP)
grants = le32_or(grants, FILE_READ);
grants |= FILE_READ;
}
/* a possible ACE to deny group what it would get from world */
@ -2611,22 +2611,22 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
if (isdir) {
pdace->flags = DIR_INHERITANCE;
if (mode & S_IXOTH)
denials = le32_or(denials, DIR_EXEC);
denials |= DIR_EXEC;
if (mode & S_IWOTH)
denials = le32_or(denials, DIR_WRITE);
denials |= DIR_WRITE;
if (mode & S_IROTH)
denials = le32_or(denials, DIR_READ);
denials |= DIR_READ;
} else {
pdace->flags = FILE_INHERITANCE;
if (mode & S_IXOTH)
denials = le32_or(denials, FILE_EXEC);
denials |= FILE_EXEC;
if (mode & S_IWOTH)
denials = le32_or(denials, FILE_WRITE);
denials |= FILE_WRITE;
if (mode & S_IROTH)
denials = le32_or(denials, FILE_READ);
denials |= FILE_READ;
}
denials = le32_and(denials, le32_not(le32_or(grants, OWNER_RIGHTS)));
if (!le32_cmpz(denials)) {
denials &= ~(grants | OWNER_RIGHTS);
if (denials) {
pdace->type = ACCESS_DENIED_ACE_TYPE;
pdace->size = cpu_to_le16(gsidsz + 8);
pdace->mask = denials;
@ -2660,19 +2660,19 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
if (isdir) {
pgace->flags = DIR_INHERITANCE;
if (mode & S_IXOTH)
grants = le32_or(grants, DIR_EXEC);
grants |= DIR_EXEC;
if (mode & S_IWOTH)
grants = le32_or(grants, DIR_WRITE);
grants |= DIR_WRITE;
if (mode & S_IROTH)
grants = le32_or(grants, DIR_READ);
grants |= DIR_READ;
} else {
pgace->flags = FILE_INHERITANCE;
if (mode & S_IXOTH)
grants = le32_or(grants, FILE_EXEC);
grants |= FILE_EXEC;
if (mode & S_IWOTH)
grants = le32_or(grants, FILE_WRITE);
grants |= FILE_WRITE;
if (mode & S_IROTH)
grants = le32_or(grants, FILE_READ);
grants |= FILE_READ;
}
pgace->size = cpu_to_le16(wsidsz + 8);
pgace->mask = grants;
@ -2690,7 +2690,7 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
else
pgace->flags = FILE_INHERITANCE;
pgace->size = cpu_to_le16(asidsz + 8);
grants = le32_or(OWNER_RIGHTS, le32_or(FILE_READ, le32_or(FILE_WRITE, FILE_EXEC)));
grants = OWNER_RIGHTS | FILE_READ | FILE_WRITE | FILE_EXEC;
pgace->mask = grants;
memcpy((char*)&pgace->sid, adminsid, asidsz);
pos += asidsz + 8;
@ -2706,7 +2706,7 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
else
pgace->flags = FILE_INHERITANCE;
pgace->size = cpu_to_le16(ssidsz + 8);
grants = le32_or(OWNER_RIGHTS, le32_or(FILE_READ, le32_or(FILE_WRITE, FILE_EXEC)));
grants = OWNER_RIGHTS | FILE_READ | FILE_WRITE | FILE_EXEC;
pgace->mask = grants;
memcpy((char*)&pgace->sid, systemsid, ssidsz);
pos += ssidsz + 8;
@ -2723,11 +2723,11 @@ static int buildacls(char *secattr, int offs, mode_t mode, int isdir,
pgace->size = cpu_to_le16(nsidsz + 8);
grants = const_cpu_to_le32(0);
if (mode & S_ISUID)
grants = le32_or(grants, FILE_APPEND_DATA);
grants |= FILE_APPEND_DATA;
if (mode & S_ISGID)
grants = le32_or(grants, FILE_WRITE_DATA);
grants |= FILE_WRITE_DATA;
if (mode & S_ISVTX)
grants = le32_or(grants, FILE_READ_DATA);
grants |= FILE_READ_DATA;
pgace->mask = grants;
memcpy((char*)&pgace->sid, nullsid, nsidsz);
pos += nsidsz + 8;
@ -2890,8 +2890,8 @@ char *ntfs_build_descr(mode_t mode,
* The flag SE_DACL_PROTECTED prevents the ACL
* to be changed in an inheritance after creation
*/
pnhead->control = le16_or(SE_DACL_PRESENT, le16_or(SE_DACL_PROTECTED,
SE_SELF_RELATIVE));
pnhead->control = SE_DACL_PRESENT | SE_DACL_PROTECTED
| SE_SELF_RELATIVE;
/*
* Windows prefers ACL first, do the same to
* get the same hash value and avoid duplication
@ -2942,84 +2942,84 @@ static int merge_permissions(BOOL isdir,
perm = 0;
/* build owner permission */
if (!le32_cmpz(owner)) {
if (owner) {
if (isdir) {
/* exec if any of list, traverse */
if (!le32_andz(owner, DIR_GEXEC))
if (owner & DIR_GEXEC)
perm |= S_IXUSR;
/* write if any of addfile, adddir, delchild */
if (!le32_andz(owner, DIR_GWRITE))
if (owner & DIR_GWRITE)
perm |= S_IWUSR;
/* read if any of list */
if (!le32_andz(owner, DIR_GREAD))
if (owner & DIR_GREAD)
perm |= S_IRUSR;
} else {
/* exec if execute or generic execute */
if (!le32_andz(owner, FILE_GEXEC))
if (owner & FILE_GEXEC)
perm |= S_IXUSR;
/* write if any of writedata or generic write */
if (!le32_andz(owner, FILE_GWRITE))
if (owner & FILE_GWRITE)
perm |= S_IWUSR;
/* read if any of readdata or generic read */
if (!le32_andz(owner, FILE_GREAD))
if (owner & FILE_GREAD)
perm |= S_IRUSR;
}
}
/* build group permission */
if (!le32_cmpz(group)) {
if (group) {
if (isdir) {
/* exec if any of list, traverse */
if (!le32_andz(group, DIR_GEXEC))
if (group & DIR_GEXEC)
perm |= S_IXGRP;
/* write if any of addfile, adddir, delchild */
if (!le32_andz(group, DIR_GWRITE))
if (group & DIR_GWRITE)
perm |= S_IWGRP;
/* read if any of list */
if (!le32_andz(group, DIR_GREAD))
if (group & DIR_GREAD)
perm |= S_IRGRP;
} else {
/* exec if execute */
if (!le32_andz(group, FILE_GEXEC))
if (group & FILE_GEXEC)
perm |= S_IXGRP;
/* write if any of writedata, appenddata */
if (!le32_andz(group, FILE_GWRITE))
if (group & FILE_GWRITE)
perm |= S_IWGRP;
/* read if any of readdata */
if (!le32_andz(group, FILE_GREAD))
if (group & FILE_GREAD)
perm |= S_IRGRP;
}
}
/* build world permission */
if (!le32_cmpz(world)) {
if (world) {
if (isdir) {
/* exec if any of list, traverse */
if (!le32_andz(world, DIR_GEXEC))
if (world & DIR_GEXEC)
perm |= S_IXOTH;
/* write if any of addfile, adddir, delchild */
if (!le32_andz(world, DIR_GWRITE))
if (world & DIR_GWRITE)
perm |= S_IWOTH;
/* read if any of list */
if (!le32_andz(world, DIR_GREAD))
if (world & DIR_GREAD)
perm |= S_IROTH;
} else {
/* exec if execute */
if (!le32_andz(world, FILE_GEXEC))
if (world & FILE_GEXEC)
perm |= S_IXOTH;
/* write if any of writedata, appenddata */
if (!le32_andz(world, FILE_GWRITE))
if (world & FILE_GWRITE)
perm |= S_IWOTH;
/* read if any of readdata */
if (!le32_andz(world, FILE_GREAD))
if (world & FILE_GREAD)
perm |= S_IROTH;
}
}
/* build special permission flags */
if (!le32_cmpz(special)) {
if (!le32_andz(special, FILE_APPEND_DATA))
if (special) {
if (special & FILE_APPEND_DATA)
perm |= S_ISUID;
if (!le32_andz(special, FILE_WRITE_DATA))
if (special & FILE_WRITE_DATA)
perm |= S_ISGID;
if (!le32_andz(special, FILE_READ_DATA))
if (special & FILE_READ_DATA)
perm |= S_ISVTX;
}
return (perm);
@ -3225,27 +3225,27 @@ static int build_std_permissions(const char *securattr,
|| ntfs_same_sid(ownersid, &pace->sid)) {
noown = FALSE;
if (pace->type == ACCESS_ALLOWED_ACE_TYPE)
allowown = le32_or(allowown, pace->mask);
allowown |= pace->mask;
else if (pace->type == ACCESS_DENIED_ACE_TYPE)
denyown = le32_or(denyown, pace->mask);
denyown |= pace->mask;
} else
if (ntfs_same_sid(gsid, &pace->sid)
&& le32_andz(pace->mask, WRITE_OWNER)) {
&& !(pace->mask & WRITE_OWNER)) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE)
allowgrp = le32_or(allowgrp, pace->mask);
allowgrp |= pace->mask;
else if (pace->type == ACCESS_DENIED_ACE_TYPE)
denygrp = le32_or(denygrp, pace->mask);
denygrp |= pace->mask;
} else
if (is_world_sid((const SID*)&pace->sid)) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE)
allowall = le32_or(allowall, pace->mask);
allowall |= pace->mask;
else
if (pace->type == ACCESS_DENIED_ACE_TYPE)
denyall = le32_or(denyall, pace->mask);
denyall |= pace->mask;
} else
if ((ntfs_same_sid((const SID*)&pace->sid,nullsid))
&& (pace->type == ACCESS_ALLOWED_ACE_TYPE))
special = le32_or(special, pace->mask);
special |= pace->mask;
}
offace += le16_to_cpu(pace->size);
}
@ -3256,18 +3256,18 @@ static int build_std_permissions(const char *securattr,
* merges the admin ACEs
*/
if (noown)
allowown = le32_or(FILE_READ_DATA, le32_or(FILE_WRITE_DATA, FILE_EXECUTE));
allowown = (FILE_READ_DATA | FILE_WRITE_DATA | FILE_EXECUTE);
/*
* Add to owner rights granted to group or world
* unless denied personaly, and add to group rights
* granted to world unless denied specifically
*/
allowown = le32_or(allowown, le32_or(allowgrp, allowall));
allowgrp = le32_or(allowgrp, allowall);
allowown |= (allowgrp | allowall);
allowgrp |= allowall;
return (merge_permissions(isdir,
le32_and(allowown, le32_not(le32_or(denyown, denyall))),
le32_and(allowgrp, le32_not(le32_or(denygrp, denyall))),
le32_and(allowall, le32_not(denyall)),
allowown & ~(denyown | denyall),
allowgrp & ~(denygrp | denyall),
allowall & ~denyall,
special));
}
@ -3313,29 +3313,29 @@ static int build_owngrp_permissions(const char *securattr,
if (!(pace->flags & INHERIT_ONLY_ACE)) {
if ((ntfs_same_sid(usid, &pace->sid)
|| ntfs_same_sid(ownersid, &pace->sid))
&& !le32_andz(pace->mask, WRITE_OWNER)) {
&& (pace->mask & WRITE_OWNER)) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE) {
allowown = le32_or(allowown, pace->mask);
allowown |= pace->mask;
ownpresent = TRUE;
}
} else
if (ntfs_same_sid(usid, &pace->sid)
&& le32_andz(pace->mask, WRITE_OWNER)) {
&& (!(pace->mask & WRITE_OWNER))) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE) {
allowgrp = le32_or(allowgrp, pace->mask);
allowgrp |= pace->mask;
grppresent = TRUE;
}
} else
if (is_world_sid((const SID*)&pace->sid)) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE)
allowall = le32_or(allowall, pace->mask);
allowall |= pace->mask;
else
if (pace->type == ACCESS_DENIED_ACE_TYPE)
denyall = le32_or(denyall, pace->mask);
denyall |= pace->mask;
} else
if ((ntfs_same_sid((const SID*)&pace->sid,nullsid))
&& (pace->type == ACCESS_ALLOWED_ACE_TYPE))
special = le32_or(special, pace->mask);
special |= pace->mask;
}
offace += le16_to_cpu(pace->size);
}
@ -3344,9 +3344,9 @@ static int build_owngrp_permissions(const char *securattr,
if (!grppresent)
allowgrp = allowall;
return (merge_permissions(isdir,
le32_and(allowown, le32_not(le32_or(denyown, denyall))),
le32_and(allowgrp, le32_not(le32_or(denygrp, denyall))),
le32_and(allowall, le32_not(denyall)),
allowown & ~(denyown | denyall),
allowgrp & ~(denygrp | denyall),
allowall & ~denyall,
special));
}
@ -3501,48 +3501,48 @@ static int build_ownadmin_permissions(const char *securattr,
for (nace = 0; nace < acecnt; nace++) {
pace = (const ACCESS_ALLOWED_ACE*)&securattr[offace];
if (!(pace->flags & INHERIT_ONLY_ACE)
&& le32_andz(le32_not(pace->mask), le32_or(ROOT_OWNER_UNMARK, ROOT_GROUP_UNMARK))) {
&& !(~pace->mask & (ROOT_OWNER_UNMARK | ROOT_GROUP_UNMARK))) {
if ((ntfs_same_sid(usid, &pace->sid)
|| ntfs_same_sid(ownersid, &pace->sid))
&& ((!le32_andz(pace->mask, WRITE_OWNER) && firstapply))) {
&& (((pace->mask & WRITE_OWNER) && firstapply))) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE) {
allowown = le32_or(allowown, pace->mask);
allowown |= pace->mask;
isforeign &= ~1;
} else
if (pace->type == ACCESS_DENIED_ACE_TYPE)
denyown = le32_or(denyown, pace->mask);
denyown |= pace->mask;
} else
if (ntfs_same_sid(gsid, &pace->sid)
&& (le32_andz(pace->mask, WRITE_OWNER))) {
&& (!(pace->mask & WRITE_OWNER))) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE) {
allowgrp = le32_or(allowgrp, pace->mask);
allowgrp |= pace->mask;
isforeign &= ~2;
} else
if (pace->type == ACCESS_DENIED_ACE_TYPE)
denygrp = le32_or(denygrp, pace->mask);
denygrp |= pace->mask;
} else if (is_world_sid((const SID*)&pace->sid)) {
if (pace->type == ACCESS_ALLOWED_ACE_TYPE)
allowall = le32_or(allowall, pace->mask);
allowall |= pace->mask;
else
if (pace->type == ACCESS_DENIED_ACE_TYPE)
denyall = le32_or(denyall, pace->mask);
denyall |= pace->mask;
}
firstapply = FALSE;
} else
if (!(pace->flags & INHERIT_ONLY_ACE))
if ((ntfs_same_sid((const SID*)&pace->sid,nullsid))
&& (pace->type == ACCESS_ALLOWED_ACE_TYPE))
special = le32_or(special, pace->mask);
special |= pace->mask;
offace += le16_to_cpu(pace->size);
}
if (isforeign) {
allowown = le32_or(allowown, le32_or(allowgrp, allowall));
allowgrp = le32_or(allowgrp, allowall);
allowown |= (allowgrp | allowall);
allowgrp |= allowall;
}
return (merge_permissions(isdir,
le32_and(allowown, le32_not(le32_or(denyown, denyall))),
le32_and(allowgrp, le32_not(le32_or(denygrp, denyall))),
le32_and(allowall, le32_not(denyall)),
allowown & ~(denyown | denyall),
allowgrp & ~(denygrp | denyall),
allowall & ~denyall,
special));
}
@ -3583,7 +3583,7 @@ const SID *ntfs_acl_owner(const char *securattr)
nace = 0;
do {
pace = (const ACCESS_ALLOWED_ACE*)&securattr[offace];
if (!le32_andz(pace->mask, WRITE_OWNER)
if ((pace->mask & WRITE_OWNER)
&& (pace->type == ACCESS_ALLOWED_ACE_TYPE)
&& ntfs_is_user_sid(&pace->sid))
found = TRUE;

File diff suppressed because it is too large Load Diff

View File

@ -155,7 +155,7 @@ int ntfs_attrlist_entry_add(ntfs_inode *ni, ATTR_RECORD *attr)
le16_to_cpu(attr->value_offset)), (attr->non_resident) ?
0 : le32_to_cpu(attr->value_length), ctx)) {
/* Found some extent, check it to be before new extent. */
if (sle64_eq(ctx->al_entry->lowest_vcn, attr->lowest_vcn)) {
if (ctx->al_entry->lowest_vcn == attr->lowest_vcn) {
err = EEXIST;
ntfs_log_trace("Such attribute already present in the "
"attribute list.\n");

View File

@ -67,7 +67,7 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
ntfs_log_debug("Beginning bootsector check.\n");
ntfs_log_debug("Checking OEMid, NTFS signature.\n");
if (!le64_eq(b->oem_id, const_cpu_to_le64(0x202020205346544eULL))) { /* "NTFS " */
if (b->oem_id != const_cpu_to_le64(0x202020205346544eULL)) { /* "NTFS " */
ntfs_log_error("NTFS signature is missing.\n");
goto not_ntfs;
}
@ -157,12 +157,12 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
/* MFT and MFTMirr may not overlap the boot sector or be the same */
if (((s64)sle64_to_cpu(b->mft_lcn) <= 0)
|| ((s64)sle64_to_cpu(b->mftmirr_lcn) <= 0)
|| sle64_eq(b->mft_lcn, b->mftmirr_lcn)) {
|| (b->mft_lcn == b->mftmirr_lcn)) {
ntfs_log_error("Invalid location of MFT or MFTMirr.\n");
goto not_ntfs;
}
if (!le16_eq(b->end_of_sector_marker, const_cpu_to_le16(0xaa55)))
if (b->end_of_sector_marker != const_cpu_to_le16(0xaa55))
ntfs_log_debug("Warning: Bootsector has invalid end of sector "
"marker.\n");

View File

@ -246,26 +246,26 @@ COLLATE ntfs_get_collate_function(COLLATION_RULES cr)
{
COLLATE collate;
/* switch (cr) { */
if (le32_eq(cr, COLLATION_BINARY)) {
switch (cr) {
case COLLATION_BINARY :
collate = ntfs_collate_binary;
}
else if (le32_eq(cr, COLLATION_FILE_NAME)) {
break;
case COLLATION_FILE_NAME :
collate = ntfs_collate_file_name;
}
else if (le32_eq(cr, COLLATION_NTOFS_SECURITY_HASH)) {
break;
case COLLATION_NTOFS_SECURITY_HASH :
collate = ntfs_collate_ntofs_security_hash;
}
else if (le32_eq(cr, COLLATION_NTOFS_ULONG)) {
break;
case COLLATION_NTOFS_ULONG :
collate = ntfs_collate_ntofs_ulong;
}
else if (le32_eq(cr, COLLATION_NTOFS_ULONGS)) {
break;
case COLLATION_NTOFS_ULONGS :
collate = ntfs_collate_ntofs_ulongs;
}
else {
break;
default :
errno = EOPNOTSUPP;
collate = (COLLATE)NULL;
/* break; */
break;
}
return (collate);
}

View File

@ -724,10 +724,10 @@ s64 ntfs_compressed_attr_pread(ntfs_attr *na, s64 pos, s64 count, void *b)
(unsigned long long)na->ni->mft_no, le32_to_cpu(na->type),
(long long)pos, (long long)count);
data_flags = na->data_flags;
compression = le32_and(na->ni->flags, FILE_ATTR_COMPRESSED);
compression = na->ni->flags & FILE_ATTR_COMPRESSED;
if (!na || !na->ni || !na->ni->vol || !b
|| !le16_eq(le16_and(data_flags, ATTR_COMPRESSION_MASK),
ATTR_IS_COMPRESSED)
|| ((data_flags & ATTR_COMPRESSION_MASK)
!= ATTR_IS_COMPRESSED)
|| pos < 0 || count < 0) {
errno = EINVAL;
return -1;
@ -846,7 +846,7 @@ do_next_cb:
to_read = min(count, cb_size - ofs);
ofs += vcn << vol->cluster_size_bits;
NAttrClearCompressed(na);
na->data_flags = le16_and(na->data_flags, le16_not(ATTR_COMPRESSION_MASK));
na->data_flags &= ~ATTR_COMPRESSION_MASK;
tdata_size = na->data_size;
tinitialized_size = na->initialized_size;
na->data_size = na->initialized_size = na->allocated_size;
@ -864,7 +864,7 @@ do_next_cb:
err = errno;
na->data_size = tdata_size;
na->initialized_size = tinitialized_size;
na->ni->flags = le32_or(na->ni->flags, compression);
na->ni->flags |= compression;
na->data_flags = data_flags;
free(cb);
free(dest);
@ -881,7 +881,7 @@ do_next_cb:
} while (to_read > 0);
na->data_size = tdata_size;
na->initialized_size = tinitialized_size;
na->ni->flags = le32_or(na->ni->flags, compression);
na->ni->flags |= compression;
na->data_flags = data_flags;
ofs = 0;
} else {
@ -904,7 +904,7 @@ do_next_cb:
*/
to_read = cb_size;
NAttrClearCompressed(na);
na->data_flags = le16_and(na->data_flags, le16_not(ATTR_COMPRESSION_MASK));
na->data_flags &= ~ATTR_COMPRESSION_MASK;
tdata_size = na->data_size;
tinitialized_size = na->initialized_size;
na->data_size = na->initialized_size = na->allocated_size;
@ -924,7 +924,7 @@ do_next_cb:
err = errno;
na->data_size = tdata_size;
na->initialized_size = tinitialized_size;
na->ni->flags = le32_or(na->ni->flags, compression);
na->ni->flags |= compression;
na->data_flags = data_flags;
free(cb);
free(dest);
@ -938,7 +938,7 @@ do_next_cb:
} while (to_read > 0);
na->data_size = tdata_size;
na->initialized_size = tinitialized_size;
na->ni->flags = le32_or(na->ni->flags, compression);
na->ni->flags |= compression;
na->data_flags = data_flags;
/* Just a precaution. */
if (cb_pos + 2 <= cb_end)

View File

@ -317,7 +317,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
* The last entry cannot contain a name. It can however contain
* a pointer to a child node in the B+tree so we just break out.
*/
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_END))
if (ie->ie_flags & INDEX_ENTRY_END)
break;
/* The file name must not overflow from the entry */
@ -359,7 +359,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
* ENOENT, unless we have got the mft reference of a matching name
* cached in mref in which case return mref.
*/
if (le16_andz(ie->ie_flags, INDEX_ENTRY_NODE)) {
if (!(ie->ie_flags & INDEX_ENTRY_NODE)) {
ntfs_attr_put_search_ctx(ctx);
if (mref)
return mref;
@ -438,7 +438,7 @@ descend_into_child_node:
* The last entry cannot contain a name. It can however contain
* a pointer to a child node in the B+tree so we just break out.
*/
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_END))
if (ie->ie_flags & INDEX_ENTRY_END)
break;
/* The file name must not overflow from the entry */
@ -475,7 +475,7 @@ descend_into_child_node:
* We have finished with this index buffer without success. Check for
* the presence of a child node.
*/
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_NODE)) {
if (ie->ie_flags & INDEX_ENTRY_NODE) {
if ((ia->index.ih_flags & NODE_MASK) == LEAF_NODE) {
ntfs_log_error("Index entry with child node found in a leaf "
"node in directory inode %lld.\n",
@ -876,23 +876,23 @@ u32 ntfs_interix_types(ntfs_inode *ni)
* Unrecognized patterns (eg HID + SYST for metadata)
* are plain files or directories
*/
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
dt_type = NTFS_DT_DIR;
else
dt_type = NTFS_DT_REG;
if (na->data_size <= 1) {
if (le32_andz(ni->flags, FILE_ATTR_HIDDEN))
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 (le64_eq(magic, INTX_SYMBOLIC_LINK))
if (magic == INTX_SYMBOLIC_LINK)
dt_type = NTFS_DT_LNK;
else if (le64_eq(magic, INTX_BLOCK_DEVICE))
else if (magic == INTX_BLOCK_DEVICE)
dt_type = NTFS_DT_BLK;
else if (le64_eq(magic, INTX_CHARACTER_DEVICE))
else if (magic == INTX_CHARACTER_DEVICE)
dt_type = NTFS_DT_CHR;
}
}
@ -919,16 +919,16 @@ static u32 ntfs_dir_entry_type(ntfs_inode *dir_ni, MFT_REF mref,
dt_type = NTFS_DT_UNKNOWN;
ni = ntfs_inode_open(dir_ni->vol, mref);
if (ni) {
if (!le32_andz(attributes, FILE_ATTR_REPARSE_POINT))
if (attributes & FILE_ATTR_REPARSE_POINT)
dt_type = (ntfs_possible_symlink(ni)
? NTFS_DT_LNK : NTFS_DT_REPARSE);
else
if (!le32_andz(attributes, FILE_ATTR_SYSTEM)
&& le32_andz(attributes, FILE_ATTR_I30_INDEX_PRESENT))
if ((attributes & FILE_ATTR_SYSTEM)
&& !(attributes & FILE_ATTR_I30_INDEX_PRESENT))
dt_type = ntfs_interix_types(ni);
else
dt_type = (!le32_andz(attributes,
FILE_ATTR_I30_INDEX_PRESENT)
dt_type = (attributes
& FILE_ATTR_I30_INDEX_PRESENT
? NTFS_DT_DIR : NTFS_DT_REG);
if (ntfs_inode_close(ni)) {
/* anything special worth doing ? */
@ -981,20 +981,20 @@ static int ntfs_filldir(ntfs_inode *dir_ni, s64 *pos, u8 ivcn_bits,
/* Skip root directory self reference entry. */
if (MREF_LE(ie->indexed_file) == FILE_root)
return 0;
if (!le32_andz(ie->key.file_name.file_attributes,
le32_or(FILE_ATTR_REPARSE_POINT, FILE_ATTR_SYSTEM))
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 (!le32_andz(ie->key.file_name.file_attributes,
FILE_ATTR_I30_INDEX_PRESENT))
else if (ie->key.file_name.file_attributes
& FILE_ATTR_I30_INDEX_PRESENT)
dt_type = NTFS_DT_DIR;
else
dt_type = NTFS_DT_REG;
/* return metadata files and hidden files if requested */
if ((!metadata && (NVolShowHidFiles(dir_ni->vol)
|| le32_andz(fn->file_attributes, FILE_ATTR_HIDDEN)))
|| !(fn->file_attributes & FILE_ATTR_HIDDEN)))
|| (NVolShowSysFiles(dir_ni->vol) && (NVolShowHidFiles(dir_ni->vol)
|| metadata))) {
if (NVolCaseSensitive(dir_ni->vol)) {
@ -1120,7 +1120,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
return -1;
}
if (le16_andz(dir_ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (!(dir_ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
errno = ENOTDIR;
return -1;
}
@ -1236,7 +1236,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
goto dir_err_out;
}
/* The last entry cannot contain a name. */
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_END))
if (ie->ie_flags & INDEX_ENTRY_END)
break;
if (!le16_to_cpu(ie->length))
@ -1378,7 +1378,7 @@ find_next_index_buffer:
goto dir_err_out;
}
/* The last entry cannot contain a name. */
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_END))
if (ie->ie_flags & INDEX_ENTRY_END)
break;
if (!le16_to_cpu(ie->length))
@ -1499,7 +1499,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
* JPA Depending on available inherited security descriptor,
* Write STANDARD_INFORMATION v1.2 (no inheritance) or v3
*/
if (!le32_cmpz(securid))
if (securid)
si_len = sizeof(STANDARD_INFORMATION);
else
si_len = offsetof(STANDARD_INFORMATION, v1_end);
@ -1512,7 +1512,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
si->last_data_change_time = ni->last_data_change_time;
si->last_mft_change_time = ni->last_mft_change_time;
si->last_access_time = ni->last_access_time;
if (!le32_cmpz(securid)) {
if (securid) {
set_nino_flag(ni, v3_Extensions);
ni->owner_id = si->owner_id = const_cpu_to_le32(0);
ni->security_id = si->security_id = securid;
@ -1535,23 +1535,23 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
break;
}
}
ni->flags = le32_or(ni->flags, FILE_ATTR_ARCHIVE);
ni->flags |= FILE_ATTR_ARCHIVE;
if (NVolHideDotFiles(dir_ni->vol)
&& (name_len > 1)
&& (le16_eq(name[0], const_cpu_to_le16('.')))
&& (!le16_eq(name[1], const_cpu_to_le16('.'))))
ni->flags = le32_or(ni->flags, FILE_ATTR_HIDDEN);
&& (name[0] == const_cpu_to_le16('.'))
&& (name[1] != const_cpu_to_le16('.')))
ni->flags |= FILE_ATTR_HIDDEN;
/*
* Set compression flag according to parent directory
* unless NTFS version < 3.0 or cluster size > 4K
* or compression has been disabled
*/
if (!le32_andz(dir_ni->flags, FILE_ATTR_COMPRESSED)
if ((dir_ni->flags & FILE_ATTR_COMPRESSED)
&& (dir_ni->vol->major_ver >= 3)
&& NVolCompression(dir_ni->vol)
&& (dir_ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
&& (S_ISREG(type) || S_ISDIR(type)))
ni->flags = le32_or(ni->flags, FILE_ATTR_COMPRESSED);
ni->flags |= FILE_ATTR_COMPRESSED;
/* Add STANDARD_INFORMATION to inode. */
if (ntfs_attr_add(ni, AT_STANDARD_INFORMATION, AT_UNNAMED, 0,
(u8*)si, si_len)) {
@ -1561,7 +1561,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
goto err_out;
}
if (le32_cmpz(securid)) {
if (!securid) {
if (ntfs_sd_add_everyone(ni)) {
err = errno;
goto err_out;
@ -1702,14 +1702,14 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
if (special_files == NTFS_FILES_INTERIX)
fn->file_attributes = FILE_ATTR_SYSTEM;
} else
fn->file_attributes = le32_or(fn->file_attributes, le32_and(ni->flags, FILE_ATTR_COMPRESSED));
fn->file_attributes = le32_or(fn->file_attributes, FILE_ATTR_ARCHIVE);
fn->file_attributes = le32_or(fn->file_attributes, le32_and(ni->flags, FILE_ATTR_HIDDEN));
fn->file_attributes |= ni->flags & FILE_ATTR_COMPRESSED;
fn->file_attributes |= FILE_ATTR_ARCHIVE;
fn->file_attributes |= ni->flags & FILE_ATTR_HIDDEN;
fn->creation_time = ni->creation_time;
fn->last_data_change_time = ni->last_data_change_time;
fn->last_mft_change_time = ni->last_mft_change_time;
fn->last_access_time = ni->last_access_time;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
fn->data_size = fn->allocated_size = const_cpu_to_sle64(0);
else {
fn->data_size = cpu_to_sle64(ni->data_size);
@ -1733,7 +1733,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
/* Set hard links count and directory flag. */
ni->mrec->link_count = const_cpu_to_le16(1);
if (S_ISDIR(type))
ni->mrec->flags = le16_or(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY);
ni->mrec->flags |= MFT_RECORD_IS_DIRECTORY;
/* Add reparse data */
if (special_files == NTFS_FILES_WSL) {
switch (type) {
@ -1843,7 +1843,7 @@ int ntfs_check_empty_dir(ntfs_inode *ni)
ntfs_attr *na;
int ret = 0;
if (le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY))
return 0;
na = ntfs_attr_open(ni, AT_INDEX_ROOT, NTFS_INDEX_I30, 4);
@ -2025,7 +2025,7 @@ search:
* (Windows also does so), however delete the name if it were
* in an extent, to avoid leaving an attribute list.
*/
if (le16_eq(ni->mrec->link_count, const_cpu_to_le16(1)) && !actx->base_ntfs_ino) {
if ((ni->mrec->link_count == const_cpu_to_le16(1)) && !actx->base_ntfs_ino) {
/* make sure to not loop to another search */
looking_for_dos_name = FALSE;
} else {
@ -2081,7 +2081,7 @@ search:
ntfs_log_error("Could not delete inode cache entry for %s\n",
pathname);
#endif
if (!le16_cmpz(ni->mrec->link_count)) {
if (ni->mrec->link_count) {
ntfs_inode_update_times(ni, NTFS_UPDATE_CTIME);
goto ok;
}
@ -2215,11 +2215,11 @@ static int ntfs_link_i(ntfs_inode *ni, ntfs_inode *dir_ni, const ntfschar *name,
if (NVolHideDotFiles(dir_ni->vol)) {
/* Set hidden flag according to the latest name */
if ((name_len > 1)
&& (le16_eq(name[0], const_cpu_to_le16('.')))
&& (!le16_eq(name[1], const_cpu_to_le16('.'))))
ni->flags = le32_or(ni->flags, FILE_ATTR_HIDDEN);
&& (name[0] == const_cpu_to_le16('.'))
&& (name[1] != const_cpu_to_le16('.')))
ni->flags |= FILE_ATTR_HIDDEN;
else
ni->flags = le32_and(ni->flags, le32_not(FILE_ATTR_HIDDEN));
ni->flags &= ~FILE_ATTR_HIDDEN;
}
/* Create FILE_NAME attribute. */
@ -2234,8 +2234,8 @@ static int ntfs_link_i(ntfs_inode *ni, ntfs_inode *dir_ni, const ntfschar *name,
fn->file_name_length = name_len;
fn->file_name_type = nametype;
fn->file_attributes = ni->flags;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
fn->file_attributes = le32_or(fn->file_attributes, FILE_ATTR_I30_INDEX_PRESENT);
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
fn->file_attributes |= FILE_ATTR_I30_INDEX_PRESENT;
fn->data_size = fn->allocated_size = const_cpu_to_sle64(0);
} else {
fn->allocated_size = cpu_to_sle64(ni->allocated_size);
@ -2878,7 +2878,7 @@ int ntfs_dir_link_cnt(ntfs_inode *ni)
}
if (ni->nr_extents == -1)
ni = ni->base_ni;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
/*
* Directory : scan the directory and count
* subdirectories whose name is not DOS-only.

View File

@ -448,8 +448,8 @@ int ntfs_ea_check_wsldev(ntfs_inode *ni, dev_t *rdevp)
next = le32_to_cpu(p_ea->next_entry_offset);
found = ((next > (int)(sizeof(lxdev) + sizeof(device)))
&& (p_ea->name_length == (sizeof(lxdev) - 1))
&& le16_eq(p_ea->value_length,
const_cpu_to_le16(sizeof(device)))
&& (p_ea->value_length
== const_cpu_to_le16(sizeof(device)))
&& !memcmp(p_ea->name, lxdev, sizeof(lxdev)));
if (!found)
offset += next;

View File

@ -74,7 +74,7 @@ int ntfs_get_efs_info(ntfs_inode *ni, char *value, size_t size)
s64 attr_size = 0;
if (ni) {
if (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
if (ni->flags & FILE_ATTR_ENCRYPTED) {
efs_info = (EFS_ATTR_HEADER*)ntfs_attr_readall(ni,
AT_LOGGED_UTILITY_STREAM,(ntfschar*)NULL, 0,
&attr_size);
@ -159,7 +159,7 @@ static int fixup_loop(ntfs_inode *ni)
ntfs_log_error("can't open DATA Attribute\n");
res = -1;
}
if (na && le16_andz(ctx->attr->flags, ATTR_IS_ENCRYPTED)) {
if (na && !(ctx->attr->flags & ATTR_IS_ENCRYPTED)) {
if (!NAttrNonResident(na)
&& ntfs_attr_make_non_resident(na, ctx)) {
/*
@ -217,8 +217,8 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size,
res = 0;
if (ni && value && size) {
if (!le32_andz(ni->flags, le32_or(FILE_ATTR_ENCRYPTED, FILE_ATTR_COMPRESSED))) {
if (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
if (ni->flags & (FILE_ATTR_ENCRYPTED | FILE_ATTR_COMPRESSED)) {
if (ni->flags & FILE_ATTR_ENCRYPTED) {
ntfs_log_trace("Inode %lld already encrypted\n",
(long long)ni->mft_no);
errno = EEXIST;
@ -285,14 +285,14 @@ int ntfs_set_efs_info(ntfs_inode *ni, const char *value, size_t size,
}
if (!res) {
/* Don't handle AT_DATA Attribute(s) if inode is a directory */
if (le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
/* iterate over AT_DATA attributes */
/* set encrypted flag, truncate attribute to match padding bytes */
if (fixup_loop(ni))
return -1;
}
ni->flags = le32_or(ni->flags, FILE_ATTR_ENCRYPTED);
ni->flags |= FILE_ATTR_ENCRYPTED;
NInoSetDirty(ni);
NInoFileNameSetDirty(ni);
}
@ -418,7 +418,7 @@ int ntfs_efs_fixup_attribute(ntfs_attr_search_ctx *ctx, ntfs_attr *na)
ctx->attr->data_size = cpu_to_sle64(newsize);
if (sle64_to_cpu(ctx->attr->initialized_size) > newsize)
ctx->attr->initialized_size = ctx->attr->data_size;
ctx->attr->flags = le16_or(ctx->attr->flags, ATTR_IS_ENCRYPTED);
ctx->attr->flags |= ATTR_IS_ENCRYPTED;
if (close_ctx)
ntfs_attr_put_search_ctx(ctx);

View File

@ -66,8 +66,9 @@ void ntfs_index_entry_mark_dirty(ntfs_index_context *ictx)
{
if (ictx->is_in_root)
ntfs_inode_mark_dirty(ictx->actx->ntfs_ino);
else
else if (ictx->ib != NULL) {
ictx->ib_dirty = TRUE;
}
}
static s64 ntfs_ib_vcn_to_pos(ntfs_index_context *icx, VCN vcn)
@ -222,7 +223,7 @@ static u8 *ntfs_ie_get_end(INDEX_HEADER *ih)
static int ntfs_ie_end(INDEX_ENTRY *ie)
{
return !le16_andz(ie->ie_flags, INDEX_ENTRY_END) || le16_cmpz(ie->length);
return ie->ie_flags & INDEX_ENTRY_END || !ie->length;
}
/**
@ -376,13 +377,13 @@ static INDEX_ENTRY *ntfs_ie_dup_novcn(INDEX_ENTRY *ie)
ntfs_log_trace("Entering\n");
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_NODE))
if (ie->ie_flags & INDEX_ENTRY_NODE)
size -= sizeof(VCN);
dup = ntfs_malloc(size);
if (dup) {
memcpy(dup, ie, size);
dup->ie_flags = le16_and(dup->ie_flags, le16_not(INDEX_ENTRY_NODE));
dup->ie_flags &= ~INDEX_ENTRY_NODE;
dup->length = cpu_to_le16(size);
}
return dup;
@ -528,7 +529,7 @@ int ntfs_index_entry_inconsistent(const INDEX_ENTRY *ie,
int ret;
ret = 0;
if (!le16_cmpz(ie->key_length)
if (ie->key_length
&& ((le16_to_cpu(ie->key_length) + offsetof(INDEX_ENTRY, key))
> le16_to_cpu(ie->length))) {
ntfs_log_error("Overflow from index entry in inode %lld\n",
@ -536,7 +537,7 @@ int ntfs_index_entry_inconsistent(const INDEX_ENTRY *ie,
ret = -1;
} else
if (le32_eq(collation_rule, COLLATION_FILE_NAME)) {
if (collation_rule == COLLATION_FILE_NAME) {
if ((offsetof(INDEX_ENTRY, key.file_name.file_name)
+ ie->key.file_name.file_name_length
* sizeof(ntfschar))
@ -547,7 +548,7 @@ int ntfs_index_entry_inconsistent(const INDEX_ENTRY *ie,
ret = -1;
}
} else {
if (!le16_cmpz(ie->data_length)
if (ie->data_length
&& ((le16_to_cpu(ie->data_offset)
+ le16_to_cpu(ie->data_length))
> le16_to_cpu(ie->length))) {
@ -649,7 +650,7 @@ static int ntfs_ie_lookup(const void *key, const int key_len,
* presence of a child node and if not present return with errno ENOENT,
* otherwise we will keep searching in another index block.
*/
if (le16_andz(ie->ie_flags, INDEX_ENTRY_NODE)) {
if (!(ie->ie_flags & INDEX_ENTRY_NODE)) {
ntfs_log_debug("Index entry wasn't found.\n");
*ie_out = ie;
errno = ENOENT;
@ -1180,7 +1181,7 @@ static int ntfs_ib_cut_tail(ntfs_index_context *icx, INDEX_BLOCK *ib,
ies_end = (char *)ntfs_ie_get_end(&ib->index);
ie_last = ntfs_ie_get_last((INDEX_ENTRY *)ies_start, ies_end);
if (!le16_andz(ie_last->ie_flags, INDEX_ENTRY_NODE))
if (ie_last->ie_flags & INDEX_ENTRY_NODE)
ntfs_ie_set_vcn(ie_last, ntfs_ie_get_vcn(ie));
memcpy(ie, ie_last, le16_to_cpu(ie_last->length));
@ -1262,7 +1263,7 @@ retry :
ntfs_ir_nill(ir);
ie = ntfs_ie_get_first(&ir->index);
ie->ie_flags = le16_or(ie->ie_flags, INDEX_ENTRY_NODE);
ie->ie_flags |= INDEX_ENTRY_NODE;
ie->length = const_cpu_to_le16(sizeof(INDEX_ENTRY_HEADER) + sizeof(VCN));
ir->index.ih_flags = LARGE_INDEX;
@ -1385,7 +1386,7 @@ static int ntfs_ie_add_vcn(INDEX_ENTRY **ie)
if (!p)
return STATUS_ERROR;
p->ie_flags = le16_or(p->ie_flags, INDEX_ENTRY_NODE);
p->ie_flags |= INDEX_ENTRY_NODE;
*ie = p;
return STATUS_OK;
@ -1404,7 +1405,7 @@ static int ntfs_ih_insert(INDEX_HEADER *ih, INDEX_ENTRY *orig_ie, VCN new_vcn,
if (!ie)
return STATUS_ERROR;
if (le16_andz(ie->ie_flags, INDEX_ENTRY_NODE))
if (!(ie->ie_flags & INDEX_ENTRY_NODE))
if (ntfs_ie_add_vcn(&ie))
goto out;
@ -1446,7 +1447,7 @@ static int ntfs_ir_insert_median(ntfs_index_context *icx, INDEX_ENTRY *median,
new_size = le32_to_cpu(icx->ir->index.index_length) +
le16_to_cpu(median->length);
if (le16_andz(median->ie_flags, INDEX_ENTRY_NODE))
if (!(median->ie_flags & INDEX_ENTRY_NODE))
new_size += sizeof(VCN);
ret = ntfs_ir_make_space(icx, new_size);
@ -1670,7 +1671,7 @@ static int ntfs_ih_takeout(ntfs_index_context *icx, INDEX_HEADER *ih,
ntfs_log_trace("Entering\n");
full = le32_eq(ih->index_length, ih->allocated_size);
full = ih->index_length == ih->allocated_size;
ie_roam = ntfs_ie_dup_novcn(ie);
if (!ie_roam)
return STATUS_ERROR;
@ -1712,7 +1713,7 @@ static void ntfs_ir_leafify(ntfs_index_context *icx, INDEX_HEADER *ih)
ntfs_log_trace("Entering\n");
ie = ntfs_ie_get_first(ih);
ie->ie_flags = le16_and(ie->ie_flags, le16_not(INDEX_ENTRY_NODE));
ie->ie_flags &= ~INDEX_ENTRY_NODE;
ie->length = cpu_to_le16(le16_to_cpu(ie->length) - sizeof(VCN));
ih->index_length = cpu_to_le32(le32_to_cpu(ih->index_length) - sizeof(VCN));
@ -1931,7 +1932,7 @@ int ntfs_index_rm(ntfs_index_context *icx)
else
ih = &icx->ib->index;
if (!le16_andz(icx->entry->ie_flags, INDEX_ENTRY_NODE)) {
if (icx->entry->ie_flags & INDEX_ENTRY_NODE) {
ret = ntfs_index_rm_node(icx);
@ -2064,7 +2065,7 @@ static INDEX_ENTRY *ntfs_index_walk_down(INDEX_ENTRY *ie,
entry = ictx->entry;
} else
entry = (INDEX_ENTRY*)NULL;
} while (entry && !le16_andz(entry->ie_flags, INDEX_ENTRY_NODE));
} while (entry && (entry->ie_flags & INDEX_ENTRY_NODE));
return (entry);
}
@ -2115,7 +2116,7 @@ static INDEX_ENTRY *ntfs_index_walk_up(INDEX_ENTRY *ie,
}
ictx->entry = entry;
} while (entry && (ictx->pindex > 0)
&& !le16_andz(entry->ie_flags, INDEX_ENTRY_END));
&& (entry->ie_flags & INDEX_ENTRY_END));
} else
entry = (INDEX_ENTRY*)NULL;
return (entry);
@ -2159,7 +2160,7 @@ INDEX_ENTRY *ntfs_index_next(INDEX_ENTRY *ie, ntfs_index_context *ictx)
* if this happens, walk up
*/
if (!le16_andz(ie->ie_flags, INDEX_ENTRY_END))
if (ie->ie_flags & INDEX_ENTRY_END)
next = ntfs_index_walk_up(ie, ictx);
else {
/*
@ -2173,20 +2174,20 @@ INDEX_ENTRY *ntfs_index_next(INDEX_ENTRY *ie, ntfs_index_context *ictx)
/* walk down if it has a subnode */
if (!le16_andz(flags, INDEX_ENTRY_NODE)) {
if (flags & INDEX_ENTRY_NODE) {
next = ntfs_index_walk_down(next,ictx);
} else {
/* walk up it has no subnode, nor data */
if (!le16_andz(flags, INDEX_ENTRY_END)) {
if (flags & INDEX_ENTRY_END) {
next = ntfs_index_walk_up(next, ictx);
}
}
}
/* return NULL if stuck at end of a block */
if (next && !le16_andz(next->ie_flags, INDEX_ENTRY_END))
if (next && (next->ie_flags & INDEX_ENTRY_END))
next = (INDEX_ENTRY*)NULL;
return (next);
}

View File

@ -173,7 +173,7 @@ static ntfs_inode *ntfs_inode_real_open(ntfs_volume *vol, const MFT_REF mref)
goto out;
if (ntfs_file_record_read(vol, mref, &ni->mrec, NULL))
goto err_out;
if (le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE)) {
if (!(ni->mrec->flags & MFT_RECORD_IN_USE)) {
errno = ENOENT;
goto err_out;
}
@ -184,7 +184,7 @@ static ntfs_inode *ntfs_inode_real_open(ntfs_volume *vol, const MFT_REF mref)
/* Receive some basic information about inode. */
if (ntfs_attr_lookup(AT_STANDARD_INFORMATION, AT_UNNAMED,
0, CASE_SENSITIVE, 0, NULL, 0, ctx)) {
if (le64_cmpz(ni->mrec->base_mft_record))
if (!ni->mrec->base_mft_record)
ntfs_log_perror("No STANDARD_INFORMATION in base record"
" %lld", (long long)MREF(mref));
goto put_err_out;
@ -263,8 +263,8 @@ get_size:
} else {
if (ctx->attr->non_resident) {
ni->data_size = sle64_to_cpu(ctx->attr->data_size);
if (!le16_andz(ctx->attr->flags,
le16_or(ATTR_IS_COMPRESSED, ATTR_IS_SPARSE)))
if (ctx->attr->flags &
(ATTR_IS_COMPRESSED | ATTR_IS_SPARSE))
ni->allocated_size = sle64_to_cpu(
ctx->attr->compressed_size);
else
@ -516,7 +516,7 @@ int ntfs_inode_close(ntfs_inode *ni)
if (ni->vol && ni->vol->nidata_cache
&& ((ni->mft_no == FILE_root)
|| ((ni->mft_no >= FILE_first_user)
&& le16_andz(ni->mrec->flags, MFT_RECORD_IS_4)))) {
&& !(ni->mrec->flags & MFT_RECORD_IS_4)))) {
/* If we have dirty metadata, write it out. */
dirty = NInoDirty(ni) || NInoAttrListDirty(ni);
if (dirty) {
@ -811,7 +811,7 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni)
}
/* Collect the reparse tag, if any */
reparse_tag = const_cpu_to_le32(0);
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
if (!ntfs_attr_lookup(AT_REPARSE_POINT, NULL,
0, CASE_SENSITIVE, 0, NULL, 0, ctx)) {
rpp = (REPARSE_POINT*)((u8 *)ctx->attr +
@ -874,9 +874,9 @@ static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni)
/* Update flags and file size. */
fnx = (FILE_NAME_ATTR *)ictx->data;
fnx->file_attributes =
le32_or(le32_and(fnx->file_attributes, le32_not(FILE_ATTR_VALID_FLAGS)),
le32_and(ni->flags, FILE_ATTR_VALID_FLAGS));
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
(fnx->file_attributes & ~FILE_ATTR_VALID_FLAGS) |
(ni->flags & FILE_ATTR_VALID_FLAGS);
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
fnx->data_size = fnx->allocated_size
= const_cpu_to_sle64(0);
else {
@ -960,7 +960,7 @@ static int ntfs_inode_sync_in_dir(ntfs_inode *ni, ntfs_inode *dir_ni)
ntfs_log_enter("Entering for inode %lld\n", (long long)ni->mft_no);
/* Update STANDARD_INFORMATION. */
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE) && ni->nr_extents != -1 &&
if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 &&
ntfs_inode_sync_standard_information(ni)) {
if (!err || errno == EIO) {
err = errno;
@ -970,7 +970,7 @@ static int ntfs_inode_sync_in_dir(ntfs_inode *ni, ntfs_inode *dir_ni)
}
/* Update FILE_NAME's in the index. */
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE) && ni->nr_extents != -1 &&
if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 &&
NInoFileNameTestAndClearDirty(ni) &&
ntfs_inode_sync_file_name(ni, dir_ni)) {
if (!err || errno == EIO) {
@ -984,7 +984,7 @@ static int ntfs_inode_sync_in_dir(ntfs_inode *ni, ntfs_inode *dir_ni)
}
/* Write out attribute list from cache to disk. */
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE) && ni->nr_extents != -1 &&
if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 &&
NInoAttrList(ni) && NInoAttrListTestAndClearDirty(ni)) {
ntfs_attr *na;
@ -1142,7 +1142,7 @@ int ntfs_inode_add_attrlist(ntfs_inode *ni)
int ale_size;
if (le32_eq(ctx->attr->type, AT_ATTRIBUTE_LIST)) {
if (ctx->attr->type == AT_ATTRIBUTE_LIST) {
err = EIO;
ntfs_log_perror("Attribute list already present");
goto put_err_out;
@ -1336,10 +1336,10 @@ retry:
}
if (ntfs_inode_base(ctx->ntfs_ino)->mft_no == FILE_MFT &&
le32_eq(ctx->attr->type, AT_DATA))
ctx->attr->type == AT_DATA)
goto retry;
if (le32_eq(ctx->attr->type, AT_INDEX_ROOT))
if (ctx->attr->type == AT_INDEX_ROOT)
goto retry;
record_size = le32_to_cpu(ctx->attr->length);
@ -1432,7 +1432,7 @@ int ntfs_inode_badclus_bad(u64 mft_no, ATTR_RECORD *attr)
if (mft_no != FILE_BadClus)
return 0;
if (!le32_eq(attr->type, AT_DATA))
if (attr->type != AT_DATA)
return 0;
if ((ustr = ntfs_str2ucs("$Bad", &len)) == NULL) {

View File

@ -90,10 +90,10 @@ static BOOL ntfs_check_restart_page_header(RESTART_PAGE_HEADER *rp, s64 pos)
* Windows 8, and we will refuse to mount.
* Nevertheless, do all the relevant checks before rejecting.
*/
if ((!sle16_eq(rp->major_ver, const_cpu_to_sle16(1))
|| !sle16_eq(rp->minor_ver, const_cpu_to_sle16(1)))
&& (!sle16_eq(rp->major_ver, const_cpu_to_sle16(2))
|| !sle16_eq(rp->minor_ver, const_cpu_to_sle16(0)))) {
if (((rp->major_ver != const_cpu_to_sle16(1))
|| (rp->minor_ver != const_cpu_to_sle16(1)))
&& ((rp->major_ver != const_cpu_to_sle16(2))
|| (rp->minor_ver != const_cpu_to_sle16(0)))) {
ntfs_log_error("$LogFile version %i.%i is not "
"supported.\n (This driver supports version "
"1.1 and 2.0 only.)\n",
@ -224,10 +224,10 @@ static BOOL ntfs_check_restart_area(RESTART_PAGE_HEADER *rp)
* LOGFILE_NO_CLIENT or less than ra->log_clients or they are
* overflowing the client array.
*/
if ((!le16_eq(ra->client_free_list, LOGFILE_NO_CLIENT) &&
if ((ra->client_free_list != LOGFILE_NO_CLIENT &&
le16_to_cpu(ra->client_free_list) >=
le16_to_cpu(ra->log_clients)) ||
(!le16_eq(ra->client_in_use_list, LOGFILE_NO_CLIENT) &&
(ra->client_in_use_list != LOGFILE_NO_CLIENT &&
le16_to_cpu(ra->client_in_use_list) >=
le16_to_cpu(ra->log_clients))) {
ntfs_log_error("$LogFile restart area specifies "
@ -287,9 +287,19 @@ static BOOL ntfs_check_log_client_array(RESTART_PAGE_HEADER *rp)
LOG_CLIENT_RECORD *ca, *cr;
u16 nr_clients, idx;
BOOL in_free_list, idx_is_first;
u32 offset_clients;
ntfs_log_trace("Entering.\n");
/* The restart area must be fully within page */
if ((le16_to_cpu(rp->restart_area_offset) + sizeof(RESTART_AREA))
> le32_to_cpu(rp->system_page_size))
goto err_out;
ra = (RESTART_AREA*)((u8*)rp + le16_to_cpu(rp->restart_area_offset));
offset_clients = le16_to_cpu(rp->restart_area_offset)
+ le16_to_cpu(ra->client_array_offset);
/* The clients' records must begin within page */
if (offset_clients >= le32_to_cpu(rp->system_page_size))
goto err_out;
ca = (LOG_CLIENT_RECORD*)((u8*)ra +
le16_to_cpu(ra->client_array_offset));
/*
@ -308,11 +318,15 @@ check_list:
idx = le16_to_cpu(cr->next_client)) {
if (!nr_clients || idx >= le16_to_cpu(ra->log_clients))
goto err_out;
/* The client record must be fully within page */
if ((offset_clients + (idx + 1)*sizeof(LOG_CLIENT_RECORD))
> le32_to_cpu(rp->system_page_size))
goto err_out;
/* Set @cr to the current log client record. */
cr = ca + idx;
/* The first log client record must not have a prev_client. */
if (idx_is_first) {
if (!le16_eq(cr->prev_client, LOGFILE_NO_CLIENT))
if (cr->prev_client != LOGFILE_NO_CLIENT)
goto err_out;
idx_is_first = FALSE;
}
@ -380,7 +394,14 @@ static int ntfs_check_and_load_restart_page(ntfs_attr *log_na,
/*
* Allocate a buffer to store the whole restart page so we can multi
* sector transfer deprotect it.
* For safety, make sure this is consistent with the usa_count
* and shorter than the full log size
*/
if ((le32_to_cpu(rp->system_page_size)
> (u32)(le16_to_cpu(rp->usa_count) - 1)*NTFS_BLOCK_SIZE)
|| (le32_to_cpu(rp->system_page_size)
> le64_to_cpu(log_na->data_size)))
return (EINVAL);
trp = ntfs_malloc(le32_to_cpu(rp->system_page_size));
if (!trp)
return errno;
@ -429,7 +450,7 @@ static int ntfs_check_and_load_restart_page(ntfs_attr *log_na,
*/
err = 0;
if (ntfs_is_rstr_record(rp->magic) &&
!le16_eq(ra->client_in_use_list, LOGFILE_NO_CLIENT)) {
ra->client_in_use_list != LOGFILE_NO_CLIENT) {
if (!ntfs_check_log_client_array(trp)) {
err = EINVAL;
goto err_out;
@ -681,8 +702,8 @@ BOOL ntfs_is_logfile_clean(ntfs_attr *log_na, RESTART_PAGE_HEADER *rp)
* have the RESTART_VOLUME_IS_CLEAN bit set in the restart area flags,
* we assume there was an unclean shutdown.
*/
if (!le16_eq(ra->client_in_use_list, LOGFILE_NO_CLIENT) &&
le16_andz(ra->flags, RESTART_VOLUME_IS_CLEAN)) {
if (ra->client_in_use_list != LOGFILE_NO_CLIENT &&
!(ra->flags & RESTART_VOLUME_IS_CLEAN)) {
ntfs_log_error("The disk contains an unclean file system (%d, "
"%d).\n", le16_to_cpu(ra->client_in_use_list),
le16_to_cpu(ra->flags));

View File

@ -5,7 +5,7 @@
* Copyright (c) 2004-2005 Richard Russon
* Copyright (c) 2004-2008 Szabolcs Szakacsits
* Copyright (c) 2005 Yura Pakhuchiy
* Copyright (c) 2014-2018 Jean-Pierre Andre
* Copyright (c) 2014-2021 Jean-Pierre Andre
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@ -282,7 +282,7 @@ int ntfs_mft_record_check(const ntfs_volume *vol, const MFT_REF mref,
a = (ATTR_RECORD*)((char*)m + offset);
previous_type = AT_STANDARD_INFORMATION;
while ((space >= (s32)offsetof(ATTR_RECORD, resident_end))
&& !le32_eq(a->type, AT_END)
&& (a->type != AT_END)
&& (le32_to_cpu(a->type) >= le32_to_cpu(previous_type))) {
if ((le32_to_cpu(a->length) <= (u32)space)
&& !(le32_to_cpu(a->length) & 7)) {
@ -300,7 +300,7 @@ int ntfs_mft_record_check(const ntfs_volume *vol, const MFT_REF mref,
}
}
/* We are supposed to reach an AT_END */
if ((space < 4) || !le32_eq(a->type, AT_END)) {
if ((space < 4) || (a->type != AT_END)) {
ntfs_log_error("Bad end of MFT record %llu\n",
(unsigned long long)MREF(mref));
goto err_out;
@ -828,7 +828,7 @@ static int ntfs_mft_bitmap_extend_allocation_i(ntfs_volume *vol)
* We now have extended the mft bitmap allocated_size by one cluster.
* Reflect this in the ntfs_attr structure and the attribute record.
*/
if (!sle64_cmpz(a->lowest_vcn)) {
if (a->lowest_vcn) {
/*
* We are not in the first attribute extent, switch to it, but
* first ensure the changes will make it to disk later.
@ -978,7 +978,6 @@ static int ntfs_mft_bitmap_extend_initialized(ntfs_volume *vol)
ll = ntfs_attr_pwrite(mftbmp_na, old_initialized_size, 8, &ll);
if (ll == 8) {
ntfs_log_debug("Wrote eight initialized bytes to mft bitmap.\n");
vol->free_mft_records += (8 * 8);
ret = 0;
goto out;
}
@ -1180,7 +1179,7 @@ static int ntfs_mft_data_extend_allocation(ntfs_volume *vol)
* @rl is the last (non-terminator) runlist element of mft data
* attribute.
*/
if (!sle64_cmpz(a->lowest_vcn)) {
if (a->lowest_vcn) {
/*
* We are not in the first attribute extent, switch to it, but
* first ensure the changes will make it to disk later.
@ -1463,8 +1462,8 @@ ntfs_inode *ntfs_mft_rec_alloc(ntfs_volume *vol, BOOL mft_data)
* extents of MFT, so we need a special check.
* If already used, apply standard procedure.
*/
if (le64_cmpz(ext_ni->mrec->base_mft_record)
&& le16_cmpz(ext_ni->mrec->link_count))
if (!ext_ni->mrec->base_mft_record
&& !ext_ni->mrec->link_count)
forced_mft_data = TRUE;
ntfs_inode_close(ext_ni);
/* Double-check, in case it is used for MFT */
@ -1522,27 +1521,36 @@ found_free_rec:
/* Sanity check that the mft record is really not in use. */
if (!forced_mft_data
&& (ntfs_is_file_record(m->magic)
&& !le16_andz(m->flags, MFT_RECORD_IN_USE))) {
&& (m->flags & MFT_RECORD_IN_USE))) {
ntfs_log_error("Inode %lld is used but it wasn't marked in "
"$MFT bitmap. Fixed.\n", (long long)bit);
free(m);
goto undo_mftbmp_alloc;
}
/*
* Retrieve the former seq_no and usn so that the new record
* cannot be mistaken for the former one.
* However the original record may just be garbage, so
* use some sensible value when they cannot be retrieved.
*/
seq_no = m->sequence_number;
usn = *(le16*)((u8*)m + le16_to_cpu(m->usa_ofs));
if (le16_to_cpu(m->usa_ofs) <= (NTFS_BLOCK_SIZE - 2))
usn = *(le16*)((u8*)m + (le16_to_cpu(m->usa_ofs) & -2));
else
usn = const_cpu_to_le16(1);
if (ntfs_mft_record_layout(vol, bit, m)) {
ntfs_log_error("Failed to re-format mft record.\n");
free(m);
goto undo_mftbmp_alloc;
}
if (!le16_cmpz(seq_no))
if (seq_no)
m->sequence_number = seq_no;
seq_no = usn;
if (!le16_cmpz(seq_no) && !le16_eq(seq_no, const_cpu_to_le16(0xffff)))
if (seq_no && seq_no != const_cpu_to_le16(0xffff))
*(le16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = usn;
/* Set the mft record itself in use. */
m->flags = le16_or(m->flags, MFT_RECORD_IN_USE);
m->flags |= MFT_RECORD_IN_USE;
/* Now need to open an ntfs inode for the mft record. */
ni = ntfs_inode_allocate(vol);
if (!ni) {
@ -1767,6 +1775,7 @@ retry:
(long long)mftbmp_na->initialized_size);
if (mftbmp_na->initialized_size + 8 > mftbmp_na->allocated_size) {
const s64 old_allocated_size = mftbmp_na->allocated_size;
int ret = ntfs_mft_bitmap_extend_allocation(vol);
if (ret == STATUS_ERROR)
@ -1783,6 +1792,9 @@ retry:
(long long)mftbmp_na->allocated_size,
(long long)mftbmp_na->data_size,
(long long)mftbmp_na->initialized_size);
vol->free_mft_records +=
(mftbmp_na->allocated_size - old_allocated_size) << 3;
}
/*
* We now have sufficient allocated space, extend the initialized_size
@ -1839,7 +1851,7 @@ found_free_rec:
NVolClearNoFixupWarn(vol);
/* Sanity check that the mft record is really not in use. */
if (ntfs_is_file_record(m->magic) && !le16_andz(m->flags, MFT_RECORD_IN_USE)) {
if (ntfs_is_file_record(m->magic) && (m->flags & MFT_RECORD_IN_USE)) {
ntfs_log_error("Inode %lld is used but it wasn't marked in "
"$MFT bitmap. Fixed.\n", (long long)bit);
free(m);
@ -1861,13 +1873,13 @@ found_free_rec:
free(m);
goto undo_mftbmp_alloc;
}
if (!le16_cmpz(seq_no))
if (seq_no)
m->sequence_number = seq_no;
seq_no = usn;
if (!le16_cmpz(seq_no) && !le16_eq(seq_no, const_cpu_to_le16(0xffff)))
if (seq_no && seq_no != const_cpu_to_le16(0xffff))
*(le16*)((u8*)m + le16_to_cpu(m->usa_ofs)) = usn;
/* Set the mft record itself in use. */
m->flags = le16_or(m->flags, MFT_RECORD_IN_USE);
m->flags |= MFT_RECORD_IN_USE;
/* Now need to open an ntfs inode for the mft record. */
ni = ntfs_inode_allocate(vol);
if (!ni) {
@ -1971,7 +1983,7 @@ int ntfs_mft_record_free(ntfs_volume *vol, ntfs_inode *ni)
mft_no = ni->mft_no;
/* Mark the mft record as not in use. */
ni->mrec->flags = le16_and(ni->mrec->flags, le16_not(MFT_RECORD_IN_USE));
ni->mrec->flags &= ~MFT_RECORD_IN_USE;
/* Increment the sequence number, skipping zero, if it is not zero. */
old_seq_no = ni->mrec->sequence_number;
@ -2014,7 +2026,7 @@ bitmap_rollback:
ntfs_log_debug("Eeek! Rollback failed in ntfs_mft_record_free(). "
"Leaving inconsistent metadata!\n");
sync_rollback:
ni->mrec->flags = le16_or(ni->mrec->flags, MFT_RECORD_IN_USE);
ni->mrec->flags |= MFT_RECORD_IN_USE;
ni->mrec->sequence_number = old_seq_no;
ntfs_inode_mark_dirty(ni);
errno = err;

View File

@ -174,7 +174,7 @@ static u64 ntfs_fix_file_name(ntfs_inode *dir_ni, ntfschar *uname,
* We generally only get the first matching candidate,
* so we still have to check whether this is a real match
*/
if (icx->entry && !le16_andz(icx->entry->ie_flags, INDEX_ENTRY_END))
if (icx->entry && (icx->entry->ie_flags & INDEX_ENTRY_END))
/* get next entry if reaching end of block */
entry = ntfs_index_next(icx->entry, icx);
else
@ -244,7 +244,7 @@ static char *search_absolute(ntfs_volume *vol, ntfschar *path,
do {
len = 0;
while (((start + len) < count)
&& !le16_eq(path[start + len], const_cpu_to_le16('\\')))
&& (path[start + len] != const_cpu_to_le16('\\')))
len++;
inum = ntfs_fix_file_name(ni, &path[start], len);
ntfs_inode_close(ni);
@ -257,12 +257,12 @@ static char *search_absolute(ntfs_volume *vol, ntfschar *path,
path[start++] = const_cpu_to_le16('/');
}
} while (ni
&& !le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
&& le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)
&& (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
&& !(ni->flags & FILE_ATTR_REPARSE_POINT)
&& (start < count));
if (ni
&& ((!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY) ? isdir : !isdir)
|| (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT))))
&& ((ni->mrec->flags & MFT_RECORD_IS_DIRECTORY ? isdir : !isdir)
|| (ni->flags & FILE_ATTR_REPARSE_POINT)))
if (ntfs_ucstombs(path, count, &target, 0) < 0) {
if (target) {
free(target);
@ -316,15 +316,15 @@ static char *search_relative(ntfs_inode *ni, ntfschar *path, int count)
*/
while (curni && ok && !morelinks && (pos < (count - 1)) && --max) {
if ((count >= (pos + 2))
&& le16_eq(path[pos], const_cpu_to_le16('.'))
&& le16_eq(path[pos+1], const_cpu_to_le16('\\'))) {
&& (path[pos] == const_cpu_to_le16('.'))
&& (path[pos+1] == const_cpu_to_le16('\\'))) {
path[pos+1] = const_cpu_to_le16('/');
pos += 2;
} else {
if ((count >= (pos + 3))
&& le16_eq(path[pos], const_cpu_to_le16('.'))
&& le16_eq(path[pos+1], const_cpu_to_le16('.'))
&& le16_eq(path[pos+2], const_cpu_to_le16('\\'))) {
&& (path[pos] == const_cpu_to_le16('.'))
&&(path[pos+1] == const_cpu_to_le16('.'))
&& (path[pos+2] == const_cpu_to_le16('\\'))) {
path[pos+2] = const_cpu_to_le16('/');
pos += 3;
newni = ntfs_dir_parent_inode(curni);
@ -336,7 +336,7 @@ static char *search_relative(ntfs_inode *ni, ntfschar *path, int count)
} else {
lth = 0;
while (((pos + lth) < count)
&& !le16_eq(path[pos + lth], const_cpu_to_le16('\\')))
&& (path[pos + lth] != const_cpu_to_le16('\\')))
lth++;
if (lth > 0)
inum = ntfs_fix_file_name(curni,&path[pos],lth);
@ -352,7 +352,7 @@ static char *search_relative(ntfs_inode *ni, ntfschar *path, int count)
if (!curni)
ok = FALSE;
else {
if (!le32_andz(curni->flags, FILE_ATTR_REPARSE_POINT))
if (curni->flags & FILE_ATTR_REPARSE_POINT)
morelinks = TRUE;
if (ok && ((pos + lth) < count)) {
path[pos + lth] = const_cpu_to_le16('/');
@ -363,8 +363,8 @@ static char *search_relative(ntfs_inode *ni, ntfschar *path, int count)
} else {
pos += lth;
if (!morelinks
&& !le16_andz(le16_xor(ni->mrec->flags, curni->mrec->flags),
MFT_RECORD_IS_DIRECTORY))
&& (ni->mrec->flags ^ curni->mrec->flags)
& MFT_RECORD_IS_DIRECTORY)
ok = FALSE;
if (ntfs_inode_close(curni))
ok = FALSE;
@ -436,18 +436,18 @@ int ntfs_reparse_check_wsl(ntfs_inode *ni, const REPARSE_POINT *reparse)
int res;
res = -EOPNOTSUPP;
/* switch (reparse->reparse_tag) { */
if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_AF_UNIX) ||
le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_FIFO) ||
le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_CHR) ||
le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_BLK)) {
if (le16_cmpz(reparse->reparse_data_length)
&& !le32_andz(ni->flags, FILE_ATTRIBUTE_RECALL_ON_OPEN))
switch (reparse->reparse_tag) {
case IO_REPARSE_TAG_AF_UNIX :
case IO_REPARSE_TAG_LX_FIFO :
case IO_REPARSE_TAG_LX_CHR :
case IO_REPARSE_TAG_LX_BLK :
if (!reparse->reparse_data_length
&& (ni->flags & FILE_ATTRIBUTE_RECALL_ON_OPEN))
res = 0;
break;
default :
break;
}
else {
}
/* } */
if (res)
errno = EOPNOTSUPP;
return (res);
@ -477,14 +477,14 @@ static BOOL valid_reparse_data(ntfs_inode *ni,
ok = ni && reparse_attr
&& (size >= sizeof(REPARSE_POINT))
&& !le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_RESERVED_ZERO)
&& (reparse_attr->reparse_tag != IO_REPARSE_TAG_RESERVED_ZERO)
&& (((size_t)le16_to_cpu(reparse_attr->reparse_data_length)
+ sizeof(REPARSE_POINT)
+ (!le32_andz(reparse_attr->reparse_tag,
+ ((reparse_attr->reparse_tag &
IO_REPARSE_TAG_IS_MICROSOFT) ? 0 : sizeof(GUID))) == size);
if (ok) {
do {
if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_MOUNT_POINT)) {
switch (reparse_attr->reparse_tag) {
case IO_REPARSE_TAG_MOUNT_POINT :
if (size < sizeof(REPARSE_POINT) +
sizeof(struct MOUNT_POINT_REPARSE_DATA)) {
ok = FALSE;
@ -495,13 +495,13 @@ static BOOL valid_reparse_data(ntfs_inode *ni,
offs = le16_to_cpu(mount_point_data->subst_name_offset);
lth = le16_to_cpu(mount_point_data->subst_name_length);
/* consistency checks */
if (le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
|| ((size_t)((sizeof(REPARSE_POINT)
+ sizeof(struct MOUNT_POINT_REPARSE_DATA)
+ offs + lth)) > size))
ok = FALSE;
break;
} else if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_SYMLINK)) {
case IO_REPARSE_TAG_SYMLINK :
if (size < sizeof(REPARSE_POINT) +
sizeof(struct SYMLINK_REPARSE_DATA)) {
ok = FALSE;
@ -516,26 +516,25 @@ static BOOL valid_reparse_data(ntfs_inode *ni,
+ offs + lth)) > size)
ok = FALSE;
break;
} else if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_LX_SYMLINK)) {
case IO_REPARSE_TAG_LX_SYMLINK :
wsl_reparse_data = (const struct WSL_LINK_REPARSE_DATA*)
reparse_attr->reparse_data;
if ((le16_to_cpu(reparse_attr->reparse_data_length)
<= sizeof(wsl_reparse_data->type))
|| (!le32_eq(wsl_reparse_data->type, const_cpu_to_le32(2))))
|| (wsl_reparse_data->type != const_cpu_to_le32(2)))
ok = FALSE;
break;
} else if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_AF_UNIX) ||
le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_LX_FIFO) ||
le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_LX_CHR) ||
le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_LX_BLK)) {
if (!le16_cmpz(reparse_attr->reparse_data_length)
|| le32_andz(ni->flags, FILE_ATTRIBUTE_RECALL_ON_OPEN))
case IO_REPARSE_TAG_AF_UNIX :
case IO_REPARSE_TAG_LX_FIFO :
case IO_REPARSE_TAG_LX_CHR :
case IO_REPARSE_TAG_LX_BLK :
if (reparse_attr->reparse_data_length
|| !(ni->flags & FILE_ATTRIBUTE_RECALL_ON_OPEN))
ok = FALSE;
break;
default :
break;
}
else {
break;
} } while(0);
}
if (!ok)
errno = EINVAL;
@ -574,9 +573,9 @@ static char *ntfs_get_fulllink(ntfs_volume *vol, ntfschar *junction,
*/
if ((count >= 7)
&& !memcmp(junction,dir_junction_head,8)
&& !le16_cmpz(junction[4])
&& le16_eq(junction[5], const_cpu_to_le16(':'))
&& le16_eq(junction[6], const_cpu_to_le16('\\')))
&& junction[4]
&& (junction[5] == const_cpu_to_le16(':'))
&& (junction[6] == const_cpu_to_le16('\\')))
kind = DIR_JUNCTION;
else
/*
@ -585,7 +584,7 @@ static char *ntfs_get_fulllink(ntfs_volume *vol, ntfschar *junction,
*/
if ((count >= 12)
&& !memcmp(junction,vol_junction_head,22)
&& le16_eq(junction[count-1], const_cpu_to_le16('\\')))
&& (junction[count-1] == const_cpu_to_le16('\\')))
kind = VOL_JUNCTION;
else
kind = NO_JUNCTION;
@ -596,7 +595,7 @@ static char *ntfs_get_fulllink(ntfs_volume *vol, ntfschar *junction,
*/
if ((kind == DIR_JUNCTION)
&& (count >= 7)
&& !le16_cmpz(junction[7])
&& junction[7]
&& !ntfs_drive_letter(vol, junction[4])) {
target = search_absolute(vol,&junction[7],count - 7, isdir);
if (target) {
@ -677,16 +676,16 @@ char *ntfs_get_abslink(ntfs_volume *vol, ntfschar *junction, int count,
* where \ is an individual char and x a non-null char
*/
if ((count >= 3)
&& !le16_cmpz(junction[0])
&& le16_eq(junction[1], const_cpu_to_le16(':'))
&& le16_eq(junction[2], const_cpu_to_le16('\\')))
&& junction[0]
&& (junction[1] == const_cpu_to_le16(':'))
&& (junction[2] == const_cpu_to_le16('\\')))
kind = FULL_PATH;
else
/*
* For an absolute path we want an initial \
*/
if ((count >= 0)
&& le16_eq(junction[0], const_cpu_to_le16('\\')))
&& (junction[0] == const_cpu_to_le16('\\')))
kind = ABS_PATH;
else
kind = REJECTED_PATH;
@ -698,7 +697,7 @@ char *ntfs_get_abslink(ntfs_volume *vol, ntfschar *junction, int count,
*/
if (((kind == FULL_PATH)
&& (count >= 3)
&& !le16_cmpz(junction[3])
&& junction[3]
&& !ntfs_drive_letter(vol, junction[0]))
|| (kind == ABS_PATH)) {
if (kind == ABS_PATH)
@ -801,15 +800,15 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
target = (char*)NULL;
bad = TRUE;
isdir = !le16_eq(le16_and(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY),
const_cpu_to_le16(0));
isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
!= const_cpu_to_le16(0);
vol = ni->vol;
reparse_attr = (REPARSE_POINT*)ntfs_attr_readall(ni,
AT_REPARSE_POINT,(ntfschar*)NULL, 0, &attr_size);
if (reparse_attr && attr_size
&& valid_reparse_data(ni, reparse_attr, attr_size)) {
/* switch (reparse_attr->reparse_tag) { */
if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_MOUNT_POINT)) {
switch (reparse_attr->reparse_tag) {
case IO_REPARSE_TAG_MOUNT_POINT :
mount_point_data = (struct MOUNT_POINT_REPARSE_DATA*)
reparse_attr->reparse_data;
offs = le16_to_cpu(mount_point_data->subst_name_offset);
@ -820,8 +819,8 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
lth/2, mnt_point, isdir);
if (target)
bad = FALSE;
}
else if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_SYMLINK)) {
break;
case IO_REPARSE_TAG_SYMLINK :
symlink_data = (struct SYMLINK_REPARSE_DATA*)
reparse_attr->reparse_data;
offs = le16_to_cpu(symlink_data->subst_name_offset);
@ -831,14 +830,14 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
* Predetermine the kind of target,
* the called function has to make a full check
*/
if (le16_eq(*p++, const_cpu_to_le16('\\'))) {
if ((le16_eq(*p, const_cpu_to_le16('?')))
|| (le16_eq(*p, const_cpu_to_le16('\\'))))
if (*p++ == const_cpu_to_le16('\\')) {
if ((*p == const_cpu_to_le16('?'))
|| (*p == const_cpu_to_le16('\\')))
kind = FULL_TARGET;
else
kind = ABS_TARGET;
} else
if (le16_eq(*p, const_cpu_to_le16(':')))
if (*p == const_cpu_to_le16(':'))
kind = ABS_TARGET;
else
kind = REL_TARGET;
@ -846,8 +845,8 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
/* reparse data consistency has been checked */
switch (kind) {
case FULL_TARGET :
if (le32_andz(symlink_data->flags,
const_cpu_to_le32(1))) {
if (!(symlink_data->flags
& const_cpu_to_le32(1))) {
target = ntfs_get_fulllink(vol,
p, lth/2,
mnt_point, isdir);
@ -856,8 +855,8 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
}
break;
case ABS_TARGET :
if (!le32_andz(symlink_data->flags,
const_cpu_to_le32(1))) {
if (symlink_data->flags
& const_cpu_to_le32(1)) {
target = ntfs_get_abslink(vol,
p, lth/2,
mnt_point, isdir);
@ -866,8 +865,8 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
}
break;
case REL_TARGET :
if (!le32_andz(symlink_data->flags,
const_cpu_to_le32(1))) {
if (symlink_data->flags
& const_cpu_to_le32(1)) {
target = ntfs_get_rellink(ni,
p, lth/2);
if (target)
@ -875,11 +874,11 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
}
break;
}
}
else if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_LX_SYMLINK)) {
break;
case IO_REPARSE_TAG_LX_SYMLINK :
wsl_link_data = (struct WSL_LINK_REPARSE_DATA*)
reparse_attr->reparse_data;
if (le32_eq(wsl_link_data->type, const_cpu_to_le32(2))) {
if (wsl_link_data->type == const_cpu_to_le32(2)) {
lth = le16_to_cpu(
reparse_attr->reparse_data_length)
- sizeof(wsl_link_data->type);
@ -891,6 +890,7 @@ char *ntfs_make_symlink(ntfs_inode *ni, const char *mnt_point)
bad = FALSE;
}
}
break;
}
free(reparse_attr);
}
@ -917,12 +917,12 @@ BOOL ntfs_possible_symlink(ntfs_inode *ni)
reparse_attr = (REPARSE_POINT*)ntfs_attr_readall(ni,
AT_REPARSE_POINT,(ntfschar*)NULL, 0, &attr_size);
if (reparse_attr && attr_size) {
/* switch (reparse_attr->reparse_tag) { */
if (le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_MOUNT_POINT) ||
le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_SYMLINK) ||
le32_eq(reparse_attr->reparse_tag, IO_REPARSE_TAG_LX_SYMLINK)) {
switch (reparse_attr->reparse_tag) {
case IO_REPARSE_TAG_MOUNT_POINT :
case IO_REPARSE_TAG_SYMLINK :
case IO_REPARSE_TAG_LX_SYMLINK :
possible = TRUE;
} else {
default : ;
}
free(reparse_attr);
}
@ -1161,7 +1161,7 @@ int ntfs_get_ntfs_reparse_data(ntfs_inode *ni, char *value, size_t size)
attr_size = 0; /* default to no data and no error */
if (ni) {
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
reparse_attr = (REPARSE_POINT*)ntfs_attr_readall(ni,
AT_REPARSE_POINT,(ntfschar*)NULL, 0, &attr_size);
if (reparse_attr) {
@ -1219,8 +1219,8 @@ int ntfs_set_ntfs_reparse_data(ntfs_inode *ni,
AT_UNNAMED,0,&dummy,
(s64)0);
if (!res) {
ni->flags = le32_or(ni->flags,
FILE_ATTR_REPARSE_POINT);
ni->flags |=
FILE_ATTR_REPARSE_POINT;
NInoFileNameSetDirty(ni);
}
NInoSetDirty(ni);
@ -1290,8 +1290,8 @@ int ntfs_remove_ntfs_reparse_data(ntfs_inode *ni)
/* now remove attribute */
res = ntfs_attr_rm(na);
if (!res) {
ni->flags = le32_and(ni->flags,
le32_not(FILE_ATTR_REPARSE_POINT));
ni->flags &=
~FILE_ATTR_REPARSE_POINT;
NInoFileNameSetDirty(ni);
} else {
/*

View File

@ -5,7 +5,7 @@
* Copyright (c) 2002-2005 Richard Russon
* Copyright (c) 2002-2008 Szabolcs Szakacsits
* Copyright (c) 2004 Yura Pakhuchiy
* Copyright (c) 2007-2010 Jean-Pierre Andre
* Copyright (c) 2007-2022 Jean-Pierre Andre
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@ -918,11 +918,18 @@ static runlist_element *ntfs_mapping_pairs_decompress_i(const ntfs_volume *vol,
"array.\n");
goto err_out;
}
/* chkdsk accepts zero-sized runs only for holes */
if ((lcn != (LCN)-1) && !rl[rlpos].length) {
ntfs_log_debug(
"Invalid zero-sized data run.\n");
goto err_out;
}
/* Enter the current lcn into the runlist element. */
rl[rlpos].lcn = lcn;
}
/* Get to the next runlist element. */
rlpos++;
/* Get to the next runlist element, skipping zero-sized holes */
if (rl[rlpos].length)
rlpos++;
/* Increment the buffer position to the next mapping pair. */
buf += (*buf & 0xf) + ((*buf >> 4) & 0xf) + 1;
}
@ -948,7 +955,7 @@ mpa_err:
* the runlist with LCN_NOENT. Otherwise, we must terminate the runlist
* with LCN_RL_NOT_MAPPED and let the caller look for more extents.
*/
if (sle64_cmpz(attr->lowest_vcn)) {
if (!attr->lowest_vcn) {
VCN num_clusters;
num_clusters = ((sle64_to_cpu(attr->allocated_size) +
@ -987,13 +994,18 @@ mpa_err:
rl[rlpos].vcn = vcn;
rl[rlpos].length = (s64)0;
/* If no existing runlist was specified, we are done. */
if (!old_rl) {
if (!old_rl || !old_rl[0].length) {
ntfs_log_debug("Mapping pairs array successfully decompressed:\n");
ntfs_debug_runlist_dump(rl);
if (old_rl)
free(old_rl);
return rl;
}
/* Now combine the new and old runlists checking for overlaps. */
old_rl = ntfs_runlists_merge(old_rl, rl);
if (rl[0].length)
old_rl = ntfs_runlists_merge(old_rl, rl);
else
free(rl);
if (old_rl)
return old_rl;
err = errno;

View File

@ -74,13 +74,13 @@
#define FIRST_SECURITY_ID 0x100 /* Lowest security id */
/* Mask for attributes which can be forced */
#define FILE_ATTR_SETTABLE le32_or(FILE_ATTR_READONLY, \
le32_or(FILE_ATTR_HIDDEN, \
le32_or(FILE_ATTR_SYSTEM, \
le32_or(FILE_ATTR_ARCHIVE, \
le32_or(FILE_ATTR_TEMPORARY, \
le32_or(FILE_ATTR_OFFLINE, \
FILE_ATTR_NOT_CONTENT_INDEXED))))))
#define FILE_ATTR_SETTABLE ( FILE_ATTR_READONLY \
| FILE_ATTR_HIDDEN \
| FILE_ATTR_SYSTEM \
| FILE_ATTR_ARCHIVE \
| FILE_ATTR_TEMPORARY \
| FILE_ATTR_OFFLINE \
| FILE_ATTR_NOT_CONTENT_INDEXED )
struct SII { /* this is an image of an $SII index entry */
le16 offs;
@ -241,7 +241,7 @@ int ntfs_sid_to_mbs_size(const SID *sid)
* maximum is 2^32-1 = 4294967295 = 10 characters. If it needs to be
* in hexadecimal, then maximum is 0x665544332211 = 14 characters.
*/
if (be16_cmpz(sid->identifier_authority.high_part))
if (!sid->identifier_authority.high_part)
size += 10;
else
size += 14;
@ -324,7 +324,7 @@ char *ntfs_sid_to_mbs(const SID *sid, char *sid_str, size_t sid_str_size)
/* Add the identifier authority. */
for (u = i = 0, j = 40; i < 6; i++, j -= 8)
u += (u64)sid->identifier_authority.value[i] << j;
if (be16_cmpz(sid->identifier_authority.high_part))
if (!sid->identifier_authority.high_part)
i = snprintf(s, cnt, "%lu", (unsigned long)u);
else
i = snprintf(s, cnt, "0x%llx", (unsigned long long)u);
@ -707,7 +707,7 @@ static le32 entersecurityattr(ntfs_volume *vol,
size = le32_to_cpu(psii->datasize);
}
entry = next;
if (!entry && le32_cmpz(keyid) && !retries) {
if (!entry && !keyid && !retries) {
/* search failed, retry from smallest key */
ntfs_index_ctx_reinit(xsii);
found = !ntfs_index_lookup((char*)&keyid,
@ -722,7 +722,7 @@ static le32 entersecurityattr(ntfs_volume *vol,
psii = (struct SII*)entry;
}
if (psii
&& le16_andz(psii->flags, INDEX_ENTRY_END)) {
&& !(psii->flags & INDEX_ENTRY_END)) {
/* save first key and */
/* available position */
keyid = psii->keysecurid;
@ -737,7 +737,7 @@ static le32 entersecurityattr(ntfs_volume *vol,
}
}
}
if (le32_cmpz(keyid)) {
if (!keyid) {
/*
* could not find any entry, before creating the first
* entry, make a double check by making sure size of $SII
@ -753,7 +753,7 @@ static le32 entersecurityattr(ntfs_volume *vol,
}
ntfs_attr_close(na);
}
if (le32_cmpz(securid)) {
if (!securid) {
ntfs_log_error("Error creating a security_id\n");
errno = EIO;
}
@ -769,7 +769,7 @@ static le32 entersecurityattr(ntfs_volume *vol,
* the last byte overflows on a wrong block.
*/
if (!le32_cmpz(securid)) {
if (securid) {
gap = (-size) & (ALIGN_SDS_ENTRY - 1);
offs += gap + size;
if ((offs + attrsz + sizeof(SECURITY_DESCRIPTOR_HEADER) - 1)
@ -870,7 +870,7 @@ static le32 setsecurityattr(ntfs_volume *vol,
* lookup() may return a node with no data,
* if so get next
*/
if (!le16_andz(entry->ie_flags, INDEX_ENTRY_END))
if (entry->ie_flags & INDEX_ENTRY_END)
entry = ntfs_index_next(entry,xsdh);
do {
collision = FALSE;
@ -881,7 +881,7 @@ static le32 setsecurityattr(ntfs_volume *vol,
else size = 0;
/* if hash is not the same, the key is not present */
if (psdh && (size > 0)
&& (le32_eq(psdh->keyhash, hash))) {
&& (psdh->keyhash == hash)) {
/* if hash is the same */
/* check the whole record */
realign.parts.dataoffsh = psdh->dataoffsh;
@ -1009,7 +1009,7 @@ static int update_secur_descr(ntfs_volume *vol,
securid = setsecurityattr(vol,
(const SECURITY_DESCRIPTOR_RELATIVE*)newattr,
(s64)newattrsz);
if (!le32_cmpz(securid)) {
if (securid) {
na = ntfs_attr_open(ni, AT_STANDARD_INFORMATION,
AT_UNNAMED, 0);
if (na) {
@ -1085,7 +1085,7 @@ static int upgrade_secur_desc(ntfs_volume *vol,
securid = setsecurityattr(vol,
(const SECURITY_DESCRIPTOR_RELATIVE*)attr,
(s64)attrsz);
if (!le32_cmpz(securid)) {
if (securid) {
na = ntfs_attr_open(ni, AT_STANDARD_INFORMATION,
AT_UNNAMED, 0);
if (na) {
@ -1592,7 +1592,7 @@ static struct CACHED_PERMISSIONS *enter_cache(struct SECURITY_CONTEXT *scx,
/* cacheing is only possible if a security_id has been defined */
if (test_nino_flag(ni, v3_Extensions)
&& !le32_cmpz(ni->security_id)) {
&& ni->security_id) {
/*
* Immediately test the most frequent situation
* where the entry exists
@ -1682,7 +1682,7 @@ static struct CACHED_PERMISSIONS *enter_cache(struct SECURITY_CONTEXT *scx,
} else {
cacheentry = (struct CACHED_PERMISSIONS*)NULL;
#if CACHE_LEGACY_SIZE
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
struct CACHED_PERMISSIONS_LEGACY wanted;
struct CACHED_PERMISSIONS_LEGACY *legacy;
@ -1744,7 +1744,7 @@ static struct CACHED_PERMISSIONS *fetch_cache(struct SECURITY_CONTEXT *scx,
/* cacheing is only possible if a security_id has been defined */
cacheentry = (struct CACHED_PERMISSIONS*)NULL;
if (test_nino_flag(ni, v3_Extensions)
&& !le32_cmpz(ni->security_id)) {
&& (ni->security_id)) {
securindex = le32_to_cpu(ni->security_id);
index1 = securindex >> CACHE_PERMISSIONS_BITS;
index2 = securindex & ((1 << CACHE_PERMISSIONS_BITS) - 1);
@ -1765,7 +1765,7 @@ static struct CACHED_PERMISSIONS *fetch_cache(struct SECURITY_CONTEXT *scx,
#if CACHE_LEGACY_SIZE
else {
cacheentry = (struct CACHED_PERMISSIONS*)NULL;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
struct CACHED_PERMISSIONS_LEGACY wanted;
struct CACHED_PERMISSIONS_LEGACY *legacy;
@ -1879,7 +1879,7 @@ static char *getsecurityattr(ntfs_volume *vol, ntfs_inode *ni)
* attribute
*/
if (test_nino_flag(ni, v3_Extensions)
&& vol->secure_ni && !le32_cmpz(ni->security_id)) {
&& vol->secure_ni && ni->security_id) {
/* get v3.x descriptor in $Secure */
securid.security_id = ni->security_id;
securattr = retrievesecurityattr(vol,securid);
@ -2322,8 +2322,8 @@ static int ntfs_get_perm(struct SECURITY_CONTEXT *scx,
gid = cached->gid;
} else {
perm = 0; /* default to no permission */
isdir = !le16_eq(le16_and(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY),
const_cpu_to_le16(0));
isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
!= const_cpu_to_le16(0);
securattr = getsecurityattr(scx->vol, ni);
if (securattr) {
phead = (const SECURITY_DESCRIPTOR_RELATIVE*)
@ -2467,8 +2467,8 @@ int ntfs_get_owner_mode(struct SECURITY_CONTEXT *scx,
stbuf->st_mode = (stbuf->st_mode & ~07777) + perm;
} else {
perm = -1; /* default to error */
isdir = !le16_eq(le16_and(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY),
const_cpu_to_le16(0));
isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
!= const_cpu_to_le16(0);
securattr = getsecurityattr(scx->vol, ni);
if (securattr) {
phead =
@ -2838,7 +2838,7 @@ le32 ntfs_alloc_securid(struct SECURITY_CONTEXT *scx,
securid = setsecurityattr(scx->vol,
(const SECURITY_DESCRIPTOR_RELATIVE*)newattr,
newattrsz);
if (!le32_cmpz(securid)) {
if (securid) {
/* update cache, for subsequent use */
wanted.securid = securid;
ntfs_enter_cache(scx->vol->securid_cache,
@ -2889,7 +2889,7 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
/* check whether target securid is known in cache */
isdir = !le16_eq(le16_and(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY), const_cpu_to_le16(0));
isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) != const_cpu_to_le16(0);
wanted.uid = uid;
wanted.gid = gid;
wanted.dmode = mode & 07777;
@ -2916,9 +2916,9 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
/* adjust Windows read-only flag */
if (!isdir) {
if (mode & S_IWUSR)
ni->flags = le32_and(ni->flags, le32_not(FILE_ATTR_READONLY));
ni->flags &= ~FILE_ATTR_READONLY;
else
ni->flags = le32_or(ni->flags, FILE_ATTR_READONLY);
ni->flags |= FILE_ATTR_READONLY;
NInoFileNameSetDirty(ni);
}
}
@ -2954,9 +2954,9 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
/* adjust Windows read-only flag */
if (!isdir) {
if (mode & S_IWUSR)
ni->flags = le32_and(ni->flags, le32_not(FILE_ATTR_READONLY));
ni->flags &= ~FILE_ATTR_READONLY;
else
ni->flags = le32_or(ni->flags, FILE_ATTR_READONLY);
ni->flags |= FILE_ATTR_READONLY;
NInoFileNameSetDirty(ni);
}
/* update cache, for subsequent use */
@ -2968,7 +2968,7 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
}
#if CACHE_LEGACY_SIZE
/* also invalidate legacy cache */
if (isdir && le32_cmpz(ni->security_id)) {
if (isdir && !ni->security_id) {
struct CACHED_PERMISSIONS_LEGACY legacy;
legacy.mft_no = ni->mft_no;
@ -3218,8 +3218,8 @@ int ntfs_set_ntfs_acl(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
* For safety, invalidate even if updating
* failed.
*/
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
&& le32_cmpz(ni->security_id)) {
if ((ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
&& !ni->security_id) {
struct CACHED_PERMISSIONS_LEGACY legacy;
legacy.mft_no = ni->mft_no;
@ -3381,7 +3381,7 @@ int ntfs_sd_add_everyone(ntfs_inode *ni)
return -1;
sd->revision = SECURITY_DESCRIPTOR_REVISION;
sd->control = le16_or(SE_DACL_PRESENT, SE_SELF_RELATIVE);
sd->control = SE_DACL_PRESENT | SE_SELF_RELATIVE;
sid = (SID*)((u8*)sd + sizeof(SECURITY_DESCRIPTOR_ATTR));
sid->revision = SID_REVISION;
@ -3453,7 +3453,7 @@ int ntfs_allowed_access(struct SECURITY_CONTEXT *scx,
if (!scx->mapping[MAPUSERS]
|| (!scx->uid
&& (!(accesstype & S_IEXEC)
|| !le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))))
|| (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY))))
allow = 1;
else {
perm = ntfs_get_perm(scx, ni, accesstype);
@ -3663,8 +3663,8 @@ int ntfs_set_owner(struct SECURITY_CONTEXT *scx, ntfs_inode *ni,
mode = 0;
oldattr = getsecurityattr(scx->vol, ni);
if (oldattr) {
isdir = !le16_eq(le16_and(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY),
const_cpu_to_le16(0));
isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
!= const_cpu_to_le16(0);
phead = (const SECURITY_DESCRIPTOR_RELATIVE*)
oldattr;
gsid = (const SID*)
@ -3951,43 +3951,43 @@ static le32 build_inherited_id(struct SECURITY_CONTEXT *scx,
pnhead = (SECURITY_DESCRIPTOR_RELATIVE*)newattr;
pnhead->revision = SECURITY_DESCRIPTOR_REVISION;
pnhead->alignment = 0;
pnhead->control = le16_or(le16_and(pphead->control,
le16_or(SE_DACL_AUTO_INHERITED, SE_SACL_AUTO_INHERITED)),
SE_SELF_RELATIVE);
pnhead->control = (pphead->control
& (SE_DACL_AUTO_INHERITED | SE_SACL_AUTO_INHERITED))
| SE_SELF_RELATIVE;
pos = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
/*
* locate and inherit DACL
* do not test SE_DACL_PRESENT (wrong for "DR Watson")
*/
pnhead->dacl = const_cpu_to_le32(0);
if (!le32_cmpz(pphead->dacl)) {
if (pphead->dacl) {
offpacl = le32_to_cpu(pphead->dacl);
ppacl = (const ACL*)&parentattr[offpacl];
pnacl = (ACL*)&newattr[pos];
aclsz = ntfs_inherit_acl(ppacl, pnacl, usid, gsid,
fordir, le16_and(pphead->control,
SE_DACL_AUTO_INHERITED));
fordir, pphead->control
& SE_DACL_AUTO_INHERITED);
if (aclsz) {
pnhead->dacl = cpu_to_le32(pos);
pos += aclsz;
pnhead->control = le16_or(pnhead->control, SE_DACL_PRESENT);
pnhead->control |= SE_DACL_PRESENT;
}
}
/*
* locate and inherit SACL
*/
pnhead->sacl = const_cpu_to_le32(0);
if (!le32_cmpz(pphead->sacl)) {
if (pphead->sacl) {
offpacl = le32_to_cpu(pphead->sacl);
ppacl = (const ACL*)&parentattr[offpacl];
pnacl = (ACL*)&newattr[pos];
aclsz = ntfs_inherit_acl(ppacl, pnacl, usid, gsid,
fordir, le16_and(pphead->control,
SE_SACL_AUTO_INHERITED));
fordir, pphead->control
& SE_SACL_AUTO_INHERITED);
if (aclsz) {
pnhead->sacl = cpu_to_le32(pos);
pos += aclsz;
pnhead->control = le16_or(pnhead->control, SE_DACL_PRESENT);
pnhead->control |= SE_SACL_PRESENT;
}
}
/*
@ -4040,7 +4040,7 @@ le32 ntfs_inherited_id(struct SECURITY_CONTEXT *scx,
* the current process owns the parent directory
*/
if (test_nino_flag(dir_ni, v3_Extensions)
&& !le32_cmpz(dir_ni->security_id)) {
&& dir_ni->security_id) {
cached = fetch_cache(scx, dir_ni);
if (cached
&& (cached->uid == scx->uid) && (cached->gid == scx->gid))
@ -4051,7 +4051,7 @@ le32 ntfs_inherited_id(struct SECURITY_CONTEXT *scx,
* Not cached or not available in cache, compute it all
* Note : if parent directory has no id, it is not cacheable
*/
if (le32_cmpz(securid)) {
if (!securid) {
parentattr = getsecurityattr(scx->vol, dir_ni);
if (parentattr) {
securid = build_inherited_id(scx,
@ -4061,7 +4061,7 @@ le32 ntfs_inherited_id(struct SECURITY_CONTEXT *scx,
* Store the result into cache for further use
* if the current process owns the parent directory
*/
if (!le32_cmpz(securid)) {
if (securid) {
cached = fetch_cache(scx, dir_ni);
if (cached
&& (cached->uid == scx->uid)
@ -4392,7 +4392,7 @@ int ntfs_get_ntfs_attrib(ntfs_inode *ni, char *value, size_t size)
outsize = 0; /* default to no data and no error */
if (ni) {
attrib = le32_to_cpu(ni->flags);
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
attrib |= const_le32_to_cpu(FILE_ATTR_DIRECTORY);
else
attrib &= ~const_le32_to_cpu(FILE_ATTR_DIRECTORY);
@ -4431,15 +4431,15 @@ int ntfs_set_ntfs_attrib(ntfs_inode *ni,
memcpy(&attrib,value,sizeof(FILE_ATTR_FLAGS));
settable = FILE_ATTR_SETTABLE;
res = 0;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
/*
* Accept changing compression for a directory
* and set index root accordingly
*/
settable = le32_or(settable, FILE_ATTR_COMPRESSED);
if (!le32_andz(le32_xor(ni->flags, cpu_to_le32(attrib)),
FILE_ATTR_COMPRESSED)) {
if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED))
settable |= FILE_ATTR_COMPRESSED;
if ((ni->flags ^ cpu_to_le32(attrib))
& FILE_ATTR_COMPRESSED) {
if (ni->flags & FILE_ATTR_COMPRESSED)
dirflags = const_cpu_to_le16(0);
else
dirflags = ATTR_IS_COMPRESSED;
@ -4451,8 +4451,8 @@ int ntfs_set_ntfs_attrib(ntfs_inode *ni,
}
}
if (!res) {
ni->flags = le32_or(le32_and(ni->flags, le32_not(settable)),
le32_and(cpu_to_le32(attrib), settable));
ni->flags = (ni->flags & ~settable)
| (cpu_to_le32(attrib) & settable);
NInoFileNameSetDirty(ni);
NInoSetDirty(ni);
}
@ -4585,7 +4585,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection,
size = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
/* locate DACL if requested and available */
if (!le32_cmpz(phead->dacl) && (selection & DACL_SECURITY_INFORMATION)) {
if (phead->dacl && (selection & DACL_SECURITY_INFORMATION)) {
offdacl = le32_to_cpu(phead->dacl);
pdacl = (const ACL*)&attr[offdacl];
daclsz = le16_to_cpu(pdacl->size);
@ -4617,7 +4617,7 @@ static BOOL feedsecurityattr(const char *attr, u32 selection,
offgroup = gsidsz = 0;
/* locate SACL if requested and available */
if (!le32_cmpz(phead->sacl) && (selection & SACL_SECURITY_INFORMATION)) {
if (phead->sacl && (selection & SACL_SECURITY_INFORMATION)) {
/* find end of SACL */
offsacl = le32_to_cpu(phead->sacl);
psacl = (const ACL*)&attr[offsacl];
@ -4638,21 +4638,21 @@ static BOOL feedsecurityattr(const char *attr, u32 selection,
ok = FALSE;
} else {
if (selection & OWNER_SECURITY_INFORMATION)
control = le16_or(control, le16_and(phead->control, SE_OWNER_DEFAULTED));
control |= phead->control & SE_OWNER_DEFAULTED;
if (selection & GROUP_SECURITY_INFORMATION)
control = le16_or(control, le16_and(phead->control, SE_GROUP_DEFAULTED));
control |= phead->control & SE_GROUP_DEFAULTED;
if (selection & DACL_SECURITY_INFORMATION)
control = le16_or(control, le16_and(phead->control,
le16_or(SE_DACL_PRESENT,
le16_or(SE_DACL_DEFAULTED,
le16_or(SE_DACL_AUTO_INHERITED,
SE_DACL_PROTECTED)))));
control |= phead->control
& (SE_DACL_PRESENT
| SE_DACL_DEFAULTED
| SE_DACL_AUTO_INHERITED
| SE_DACL_PROTECTED);
if (selection & SACL_SECURITY_INFORMATION)
control = le16_or(control, le16_and(phead->control,
le16_or(SE_SACL_PRESENT,
le16_or(SE_SACL_DEFAULTED,
le16_or(SE_SACL_AUTO_INHERITED,
SE_SACL_PROTECTED)))));
control |= phead->control
& (SE_SACL_PRESENT
| SE_SACL_DEFAULTED
| SE_SACL_AUTO_INHERITED
| SE_SACL_PROTECTED);
/*
* copy header and feed new flags, even if no detailed data
*/
@ -4744,8 +4744,8 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
* copy new DACL if selected
* or keep old DACL if any
*/
if (!le32_cmpz((selection & DACL_SECURITY_INFORMATION) ?
newhead->dacl : oldhead->dacl)) {
if ((selection & DACL_SECURITY_INFORMATION) ?
newhead->dacl : oldhead->dacl) {
if (selection & DACL_SECURITY_INFORMATION) {
offdacl = le32_to_cpu(newhead->dacl);
pdacl = (const ACL*)&newattr[offdacl];
@ -4760,24 +4760,24 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
} else
targhead->dacl = const_cpu_to_le32(0);
if (selection & DACL_SECURITY_INFORMATION) {
control = le16_or(control, le16_and(newhead->control,
le16_or(SE_DACL_PRESENT,
le16_or(SE_DACL_DEFAULTED,
SE_DACL_PROTECTED))));
if (!le16_andz(newhead->control, SE_DACL_AUTO_INHERIT_REQ))
control = le16_or(control, SE_DACL_AUTO_INHERITED);
control |= newhead->control
& (SE_DACL_PRESENT
| SE_DACL_DEFAULTED
| SE_DACL_PROTECTED);
if (newhead->control & SE_DACL_AUTO_INHERIT_REQ)
control |= SE_DACL_AUTO_INHERITED;
} else
control = le16_or(control, le16_and(oldhead->control,
le16_or(SE_DACL_PRESENT,
le16_or(SE_DACL_DEFAULTED,
le16_or(SE_DACL_AUTO_INHERITED,
SE_DACL_PROTECTED)))));
control |= oldhead->control
& (SE_DACL_PRESENT
| SE_DACL_DEFAULTED
| SE_DACL_AUTO_INHERITED
| SE_DACL_PROTECTED);
/*
* copy new SACL if selected
* or keep old SACL if any
*/
if (!le32_cmpz((selection & SACL_SECURITY_INFORMATION) ?
newhead->sacl : oldhead->sacl)) {
if ((selection & SACL_SECURITY_INFORMATION) ?
newhead->sacl : oldhead->sacl) {
if (selection & SACL_SECURITY_INFORMATION) {
offsacl = le32_to_cpu(newhead->sacl);
psacl = (const ACL*)&newattr[offsacl];
@ -4792,24 +4792,24 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
} else
targhead->sacl = const_cpu_to_le32(0);
if (selection & SACL_SECURITY_INFORMATION) {
control = le16_or(control, le16_and(newhead->control,
le16_or(SE_SACL_PRESENT,
le16_or(SE_SACL_DEFAULTED,
SE_SACL_PROTECTED))));
if (!le16_andz(newhead->control, SE_SACL_AUTO_INHERIT_REQ))
control = le16_or(control, SE_SACL_AUTO_INHERITED);
control |= newhead->control
& (SE_SACL_PRESENT
| SE_SACL_DEFAULTED
| SE_SACL_PROTECTED);
if (newhead->control & SE_SACL_AUTO_INHERIT_REQ)
control |= SE_SACL_AUTO_INHERITED;
} else
control = le16_or(control, le16_and(oldhead->control,
le16_or(SE_SACL_PRESENT,
le16_or(SE_SACL_DEFAULTED,
le16_or(SE_SACL_AUTO_INHERITED,
SE_SACL_PROTECTED)))));
control |= oldhead->control
& (SE_SACL_PRESENT
| SE_SACL_DEFAULTED
| SE_SACL_AUTO_INHERITED
| SE_SACL_PROTECTED);
/*
* copy new OWNER if selected
* or keep old OWNER if any
*/
if (!le32_cmpz((selection & OWNER_SECURITY_INFORMATION) ?
newhead->owner : oldhead->owner)) {
if ((selection & OWNER_SECURITY_INFORMATION) ?
newhead->owner : oldhead->owner) {
if (selection & OWNER_SECURITY_INFORMATION) {
offowner = le32_to_cpu(newhead->owner);
powner = (const SID*)&newattr[offowner];
@ -4824,25 +4824,25 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
} else
targhead->owner = const_cpu_to_le32(0);
if (selection & OWNER_SECURITY_INFORMATION)
control = le16_or(control, le16_and(newhead->control, SE_OWNER_DEFAULTED));
control |= newhead->control & SE_OWNER_DEFAULTED;
else
control = le16_or(control, le16_and(oldhead->control, SE_OWNER_DEFAULTED));
control |= oldhead->control & SE_OWNER_DEFAULTED;
/*
* copy new GROUP if selected
* or keep old GROUP if any
*/
if (!le32_cmpz((selection & GROUP_SECURITY_INFORMATION) ?
newhead->group : oldhead->group)) {
if ((selection & GROUP_SECURITY_INFORMATION) ?
newhead->group : oldhead->group) {
if (selection & GROUP_SECURITY_INFORMATION) {
offgroup = le32_to_cpu(newhead->group);
pgroup = (const SID*)&newattr[offgroup];
control = le16_or(control, le16_and(newhead->control,
SE_GROUP_DEFAULTED));
control |= newhead->control
& SE_GROUP_DEFAULTED;
} else {
offgroup = le32_to_cpu(oldhead->group);
pgroup = (const SID*)&oldattr[offgroup];
control = le16_or(control, le16_and(oldhead->control,
SE_GROUP_DEFAULTED));
control |= oldhead->control
& SE_GROUP_DEFAULTED;
}
size = ntfs_sid_size(pgroup);
memcpy(&target[pos], pgroup, size);
@ -4851,9 +4851,9 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
} else
targhead->group = const_cpu_to_le32(0);
if (selection & GROUP_SECURITY_INFORMATION)
control = le16_or(control, le16_and(newhead->control, SE_GROUP_DEFAULTED));
control |= newhead->control & SE_GROUP_DEFAULTED;
else
control = le16_or(control, le16_and(oldhead->control, SE_GROUP_DEFAULTED));
control |= oldhead->control & SE_GROUP_DEFAULTED;
targhead->revision = SECURITY_DESCRIPTOR_REVISION;
targhead->alignment = 0;
targhead->control = control;
@ -4901,7 +4901,7 @@ int ntfs_get_file_security(struct SECURITY_API *scapi,
if (feedsecurityattr(attr,selection,
buf,buflen,psize)) {
if (test_nino_flag(ni, v3_Extensions)
&& !le32_cmpz(ni->security_id))
&& ni->security_id)
res = le32_to_cpu(
ni->security_id);
else
@ -4953,13 +4953,13 @@ int ntfs_set_file_security(struct SECURITY_API *scapi,
attrsz = ntfs_attr_size(attr);
/* if selected, owner and group must be present or defaulted */
missing = ((selection & OWNER_SECURITY_INFORMATION)
&& le32_cmpz(phead->owner)
&& le16_andz(phead->control, SE_OWNER_DEFAULTED))
&& !phead->owner
&& !(phead->control & SE_OWNER_DEFAULTED))
|| ((selection & GROUP_SECURITY_INFORMATION)
&& le32_cmpz(phead->group)
&& le16_andz(phead->control, SE_GROUP_DEFAULTED));
&& !phead->group
&& !(phead->control & SE_GROUP_DEFAULTED));
if (!missing
&& !le16_andz(phead->control, SE_SELF_RELATIVE)
&& (phead->control & SE_SELF_RELATIVE)
&& ntfs_valid_descr(attr, attrsz)) {
ni = ntfs_pathname_to_inode(scapi->security.vol,
NULL, path);
@ -5014,7 +5014,7 @@ int ntfs_get_file_attributes(struct SECURITY_API *scapi, const char *path)
ni = ntfs_pathname_to_inode(scapi->security.vol, NULL, path);
if (ni) {
attrib = le32_to_cpu(ni->flags);
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY))
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
attrib |= const_le32_to_cpu(FILE_ATTR_DIRECTORY);
else
attrib &= ~const_le32_to_cpu(FILE_ATTR_DIRECTORY);
@ -5061,15 +5061,15 @@ BOOL ntfs_set_file_attributes(struct SECURITY_API *scapi,
ni = ntfs_pathname_to_inode(scapi->security.vol, NULL, path);
if (ni) {
settable = FILE_ATTR_SETTABLE;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
/*
* Accept changing compression for a directory
* and set index root accordingly
*/
settable = le32_or(settable, FILE_ATTR_COMPRESSED);
if (!le32_andz(le32_xor(ni->flags, cpu_to_le32(attrib)),
FILE_ATTR_COMPRESSED)) {
if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED))
settable |= FILE_ATTR_COMPRESSED;
if ((ni->flags ^ cpu_to_le32(attrib))
& FILE_ATTR_COMPRESSED) {
if (ni->flags & FILE_ATTR_COMPRESSED)
dirflags = const_cpu_to_le16(0);
else
dirflags = ATTR_IS_COMPRESSED;
@ -5081,8 +5081,8 @@ BOOL ntfs_set_file_attributes(struct SECURITY_API *scapi,
}
}
if (!res) {
ni->flags = le32_or(le32_and(ni->flags, le32_not(settable)),
le32_and(cpu_to_le32(attrib), settable));
ni->flags = (ni->flags & ~settable)
| (cpu_to_le32(attrib) & settable);
NInoSetDirty(ni);
NInoFileNameSetDirty(ni);
}
@ -5106,7 +5106,7 @@ BOOL ntfs_read_directory(struct SECURITY_API *scapi,
if (scapi && (scapi->magic == MAGIC_API) && callback) {
ni = ntfs_pathname_to_inode(scapi->security.vol, NULL, path);
if (ni) {
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
pos = 0;
ntfs_readdir(ni,&pos,context,callback);
ok = !ntfs_inode_close(ni);

View File

@ -180,7 +180,7 @@ int ntfs_names_full_collate(const ntfschar *name1, const u32 name1_len,
cnt = min(name1_len, name2_len);
if (cnt > 0) {
if (ic == CASE_SENSITIVE) {
while (--cnt && le16_eq(*name1, *name2)) {
while (--cnt && (*name1 == *name2)) {
name1++;
name2++;
}
@ -475,7 +475,7 @@ static int utf16_to_utf8_size(const ntfschar *ins, const int ins_len, int outs_l
BOOL surrog;
surrog = FALSE;
for (i = 0; i < ins_len && !le16_cmpz(ins[i]) && count <= outs_len; i++) {
for (i = 0; i < ins_len && ins[i] && count <= outs_len; i++) {
unsigned short c = le16_to_cpu(ins[i]);
if (surrog) {
if ((c >= 0xdc00) && (c < 0xe000)) {
@ -586,7 +586,7 @@ static int ntfs_utf16_to_utf8(const ntfschar *ins, const int ins_len,
t = *outs;
for (i = 0; i < ins_len && !le16_cmpz(ins[i]); i++) {
for (i = 0; i < ins_len && ins[i]; i++) {
unsigned short c = le16_to_cpu(ins[i]);
/* size not double-checked */
if (halfpair) {
@ -1189,8 +1189,9 @@ char *ntfs_uppercase_mbs(const char *low,
free(upp);
upp = (char*)NULL;
errno = EILSEQ;
} else {
*t = 0;
}
*t = 0;
}
return (upp);
}
@ -1498,8 +1499,8 @@ BOOL ntfs_forbidden_chars(const ntfschar *name, int len, BOOL strict)
| (1L << ('?' - 0x20));
forbidden = (len == 0) ||
(strict && (le16_eq(name[len-1], const_cpu_to_le16(' ')) ||
le16_eq(name[len-1], const_cpu_to_le16('.'))));
(strict && (name[len-1] == const_cpu_to_le16(' ') ||
name[len-1] == const_cpu_to_le16('.')));
for (i=0; i<len; i++) {
ch = le16_to_cpu(name[i]);
if ((ch < 0x20)
@ -1559,7 +1560,7 @@ BOOL ntfs_forbidden_names(ntfs_volume *vol, const ntfschar *name, int len,
/* do a full check, depending on the third char */
switch (le16_to_cpu(name[2]) & ~0x20) {
case 'N' :
if (((len == 3) || le16_eq(name[3], dot))
if (((len == 3) || (name[3] == dot))
&& (!ntfs_ucsncasecmp(name, con, 3,
vol->upcase, vol->upcase_len)
|| !ntfs_ucsncasecmp(name, prn, 3,
@ -1567,13 +1568,13 @@ BOOL ntfs_forbidden_names(ntfs_volume *vol, const ntfschar *name, int len,
forbidden = TRUE;
break;
case 'X' :
if (((len == 3) || le16_eq(name[3], dot))
if (((len == 3) || (name[3] == dot))
&& !ntfs_ucsncasecmp(name, aux, 3,
vol->upcase, vol->upcase_len))
forbidden = TRUE;
break;
case 'L' :
if (((len == 3) || le16_eq(name[3], dot))
if (((len == 3) || (name[3] == dot))
&& !ntfs_ucsncasecmp(name, nul, 3,
vol->upcase, vol->upcase_len))
forbidden = TRUE;
@ -1582,7 +1583,7 @@ BOOL ntfs_forbidden_names(ntfs_volume *vol, const ntfschar *name, int len,
if ((len > 3)
&& (le16_to_cpu(name[3]) >= '1')
&& (le16_to_cpu(name[3]) <= '9')
&& ((len == 4) || le16_eq(name[4], dot))
&& ((len == 4) || (name[4] == dot))
&& !ntfs_ucsncasecmp(name, com, 3,
vol->upcase, vol->upcase_len))
forbidden = TRUE;
@ -1591,7 +1592,7 @@ BOOL ntfs_forbidden_names(ntfs_volume *vol, const ntfschar *name, int len,
if ((len > 3)
&& (le16_to_cpu(name[3]) >= '1')
&& (le16_to_cpu(name[3]) <= '9')
&& ((len == 4) || le16_eq(name[4], dot))
&& ((len == 4) || (name[4] == dot))
&& !ntfs_ucsncasecmp(name, lpt, 3,
vol->upcase, vol->upcase_len))
forbidden = TRUE;
@ -1629,7 +1630,7 @@ BOOL ntfs_collapsible_chars(ntfs_volume *vol,
if ((cs != ch)
&& ((ch >= vol->upcase_len)
|| (cs >= vol->upcase_len)
|| !le16_eq(vol->upcase[cs], vol->upcase[ch])))
|| (vol->upcase[cs] != vol->upcase[ch])))
collapsible = FALSE;
}
return (collapsible);

View File

@ -77,7 +77,7 @@
#include "security.h"
const char *ntfs_home =
"News, support and information: http://tuxera.com\n";
"News, support and information: https://github.com/tuxera/ntfs-3g/\n";
static const char *invalid_ntfs_msg =
"The device '%s' doesn't seem to have a valid NTFS.\n"
@ -121,7 +121,7 @@ static const char *fakeraid_msg =
static const char *access_denied_msg =
"Please check '%s' and the ntfs-3g binary permissions,\n"
"and the mounting user ID. More explanation is provided at\n"
"http://tuxera.com/community/ntfs-3g-faq/#unprivileged\n";
"https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n";
/**
* ntfs_volume_alloc - Create an NTFS volume object and initialise it
@ -350,8 +350,8 @@ mft_has_no_attr_list:
goto io_error_exit;
}
/* $MFT must be uncompressed and unencrypted. */
if (!le16_andz(a->flags, ATTR_COMPRESSION_MASK) ||
!le16_andz(a->flags, ATTR_IS_ENCRYPTED)) {
if (a->flags & ATTR_COMPRESSION_MASK ||
a->flags & ATTR_IS_ENCRYPTED) {
ntfs_log_error("$MFT must be uncompressed and "
"unencrypted.\n");
goto io_error_exit;
@ -711,8 +711,8 @@ static int ntfs_volume_check_logfile(ntfs_volume *vol)
* after such an event.
*/
if (rp
&& sle16_eq(rp->major_ver, const_cpu_to_sle16(2))
&& sle16_eq(rp->minor_ver, const_cpu_to_sle16(0))) {
&& (rp->major_ver == const_cpu_to_le16(2))
&& (rp->minor_ver == const_cpu_to_le16(0))) {
ntfs_log_error("Metadata kept in Windows cache, refused to mount.\n");
err = EPERM;
}
@ -1010,7 +1010,7 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags)
s = "mft record";
mrec = (MFT_RECORD*)(m + i * vol->mft_record_size);
if (!le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
if (mrec->flags & MFT_RECORD_IN_USE) {
if (ntfs_is_baad_record(mrec->magic)) {
ntfs_log_error("$MFT error: Incomplete multi "
"sector transfer detected in "
@ -1024,7 +1024,7 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags)
}
}
mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size);
if (!le16_andz(mrec2->flags, MFT_RECORD_IN_USE)) {
if (mrec2->flags & MFT_RECORD_IN_USE) {
if (ntfs_is_baad_record(mrec2->magic)) {
ntfs_log_error("$MFTMirr error: Incomplete "
"multi sector transfer "
@ -1778,7 +1778,7 @@ int ntfs_volume_write_flags(ntfs_volume *vol, const le16 flags)
goto err_out;
}
/* Set the volume flags. */
vol->flags = c->flags = le16_and(flags, VOLUME_FLAGS_MASK);
vol->flags = c->flags = flags & VOLUME_FLAGS_MASK;
/* Write them to disk. */
ntfs_inode_mark_dirty(vol->vol_ni);
if (ntfs_inode_sync(vol->vol_ni))

View File

@ -23,13 +23,27 @@ EXTRA_PROGRAM_NAMES = ntfswipe ntfstruncate ntfsrecover \
QUARANTINED_PROGRAM_NAMES = ntfsdump_logfile ntfsmftalloc ntfsmove ntfsck \
ntfsfallocate
man_MANS = mkntfs.8 ntfsfix.8 ntfslabel.8 ntfsinfo.8 \
ntfsundelete.8 ntfsresize.8 ntfsprogs.8 ntfsls.8 \
ntfsclone.8 ntfscluster.8 ntfscat.8 ntfscp.8 \
ntfscmp.8 ntfswipe.8 ntfstruncate.8 \
ntfsdecrypt.8 ntfsfallocate.8 ntfsrecover.8 \
ntfsusermap.8 ntfssecaudit.8
EXTRA_MANS =
man_MANS = mkntfs.8 \
ntfscat.8 \
ntfsclone.8 \
ntfscluster.8 \
ntfscmp.8 \
ntfscp.8 \
ntfsdecrypt.8 \
ntfsfallocate.8 \
ntfsfix.8 \
ntfsinfo.8 \
ntfslabel.8 \
ntfsls.8 \
ntfsprogs.8 \
ntfsresize.8 \
ntfsundelete.8
EXTRA_MANS = ntfsrecover.8 \
ntfssecaudit.8 \
ntfstruncate.8 \
ntfsusermap.8 \
ntfswipe.8
CLEANFILES = $(EXTRA_PROGRAMS)
@ -44,6 +58,7 @@ bin_PROGRAMS += $(EXTRA_PROGRAM_NAMES)
if ENABLE_QUARANTINED
bin_PROGRAMS += $(QUARANTINED_PROGRAM_NAMES)
endif
man_MANS += $(EXTRA_MANS)
else
EXTRA_PROGRAMS = $(EXTRA_PROGRAM_NAMES)
endif

View File

@ -285,7 +285,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR badblocks (8),

View File

@ -776,8 +776,20 @@ static ntfs_time mkntfs_time(void)
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (!opts.use_epoch_time)
ts.tv_sec = time(NULL);
if (!opts.use_epoch_time) {
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv = { 0, 0, };
if (!gettimeofday(&tv, NULL)) {
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000L;
}
else
#endif
{
ts.tv_sec = time(NULL);
}
}
return timespec2ntfs(ts);
}
@ -1234,18 +1246,18 @@ static int mkntfs_attr_find(const ATTR_TYPES type, const ntfschar *name,
le32_to_cpu(ctx->mrec->bytes_allocated))
break;
ctx->attr = a;
if ((!le32_eq(type, AT_UNUSED) && (le32_to_cpu(a->type) >
if (((type != AT_UNUSED) && (le32_to_cpu(a->type) >
le32_to_cpu(type))) ||
le32_eq(a->type, AT_END)) {
(a->type == AT_END)) {
errno = ENOENT;
return -1;
}
if (le32_cmpz(a->length))
if (!a->length)
break;
/* If this is an enumeration return this attribute. */
if (le32_eq(type, AT_UNUSED))
if (type == AT_UNUSED)
return 0;
if (!le32_eq(a->type, type))
if (a->type != type)
continue;
/*
* If @name is AT_UNNAMED we want an unnamed attribute.
@ -1410,7 +1422,7 @@ static int mkntfs_attr_lookup(const ATTR_TYPES type, const ntfschar *name,
base_ni = ctx->base_ntfs_ino;
else
base_ni = ctx->ntfs_ino;
if (!base_ni || !NInoAttrList(base_ni) || le32_eq(type, AT_ATTRIBUTE_LIST))
if (!base_ni || !NInoAttrList(base_ni) || type == AT_ATTRIBUTE_LIST)
return mkntfs_attr_find(type, name, name_len, ic, val, val_len,
ctx);
errno = EOPNOTSUPP;
@ -1471,19 +1483,19 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
goto err_out;
}
a = ctx->attr;
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (flags & ATTR_COMPRESSION_MASK) {
ntfs_log_error("Compressed attributes not supported yet.\n");
/* FIXME: Compress attribute into a temporary buffer, set */
/* val accordingly and save the compressed size. */
err = -EOPNOTSUPP;
goto err_out;
}
if (!le16_andz(flags, le16_or(ATTR_IS_ENCRYPTED, ATTR_IS_SPARSE))) {
if (flags & (ATTR_IS_ENCRYPTED | ATTR_IS_SPARSE)) {
ntfs_log_error("Encrypted/sparse attributes not supported.\n");
err = -EOPNOTSUPP;
goto err_out;
}
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (flags & ATTR_COMPRESSION_MASK) {
hdr_size = 72;
/* FIXME: This compression stuff is all wrong. Never mind for */
/* now. (AIA) */
@ -1562,12 +1574,12 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
a->data_size = cpu_to_sle64(val_len);
if (name_len)
memcpy((char*)a + hdr_size, uname, name_len << 1);
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (!le16_andz(flags, le16_and(ATTR_COMPRESSION_MASK, le16_not(ATTR_IS_COMPRESSED)))) {
if (flags & ATTR_COMPRESSION_MASK) {
if (flags & ATTR_COMPRESSION_MASK & ~ATTR_IS_COMPRESSED) {
ntfs_log_error("Unknown compression format. Reverting "
"to standard compression.\n");
a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK));
a->flags = le16_or(a->flags, ATTR_IS_COMPRESSED);
a->flags &= ~ATTR_COMPRESSION_MASK;
a->flags |= ATTR_IS_COMPRESSED;
}
a->compression_unit = 4;
inited_size = val_len;
@ -1578,9 +1590,9 @@ static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
err = -EOPNOTSUPP;
} else {
a->compression_unit = 0;
if (le32_eq(type, AT_DATA)
&& le32_eq(m->mft_record_number,
const_cpu_to_le32(FILE_LogFile)))
if ((type == AT_DATA)
&& (m->mft_record_number
== const_cpu_to_le32(FILE_LogFile)))
bw = ntfs_rlwrite(g_vol->dev, rl, val, val_len,
&inited_size, WRITE_LOGFILE);
else
@ -1662,14 +1674,14 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m,
goto err_out;
}
a = ctx->attr;
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (flags & ATTR_COMPRESSION_MASK) {
ntfs_log_error("Compressed attributes not supported yet.\n");
/* FIXME: Compress attribute into a temporary buffer, set */
/* val accordingly and save the compressed size. */
err = -EOPNOTSUPP;
goto err_out;
}
if (!le16_andz(flags, le16_or(ATTR_IS_ENCRYPTED, ATTR_IS_SPARSE))) {
if (flags & (ATTR_IS_ENCRYPTED | ATTR_IS_SPARSE)) {
ntfs_log_error("Encrypted/sparse attributes not supported.\n");
err = -EOPNOTSUPP;
goto err_out;
@ -1685,7 +1697,7 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m,
} else {
rl = NULL;
}
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (flags & ATTR_COMPRESSION_MASK) {
hdr_size = 72;
/* FIXME: This compression stuff is all wrong. Never mind for */
/* now. (AIA) */
@ -1759,12 +1771,12 @@ static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m,
a->initialized_size = cpu_to_sle64(val_len);
if (name_len)
memcpy((char*)a + hdr_size, uname, name_len << 1);
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (!le16_andz(flags, le16_and(ATTR_COMPRESSION_MASK, le16_not(ATTR_IS_COMPRESSED)))) {
if (flags & ATTR_COMPRESSION_MASK) {
if (flags & ATTR_COMPRESSION_MASK & ~ATTR_IS_COMPRESSED) {
ntfs_log_error("Unknown compression format. Reverting "
"to standard compression.\n");
a->flags = le16_and(a->flags, le16_not(ATTR_COMPRESSION_MASK));
a->flags = le16_or(a->flags, ATTR_IS_COMPRESSED);
a->flags &= ~ATTR_COMPRESSION_MASK;
a->flags |= ATTR_IS_COMPRESSED;
}
a->compression_unit = 4;
/* FIXME: Set the compressed size. */
@ -1885,7 +1897,7 @@ static int insert_resident_attr_in_mft_record(MFT_RECORD *m,
a->length = cpu_to_le32(asize);
a->non_resident = 0;
a->name_length = name_len;
if (le32_eq(type, AT_OBJECT_ID))
if (type == AT_OBJECT_ID)
a->name_offset = const_cpu_to_le16(0);
else
a->name_offset = const_cpu_to_le16(24);
@ -1931,7 +1943,7 @@ static int add_attr_std_info(MFT_RECORD *m, const FILE_ATTR_FLAGS flags,
si.version_number = const_cpu_to_le32(0);
si.class_id = const_cpu_to_le32(0);
si.security_id = security_id;
if (!le32_eq(si.security_id, const_cpu_to_le32(0)))
if (si.security_id != const_cpu_to_le32(0))
sd_size = 72;
/* FIXME: $Quota support... */
si.owner_id = const_cpu_to_le32(0);
@ -2249,7 +2261,7 @@ static int add_attr_vol_info(MFT_RECORD *m, const VOLUME_FLAGS flags,
memset(&vi, 0, sizeof(vi));
vi.major_ver = major_ver;
vi.minor_ver = minor_ver;
vi.flags = le16_and(flags, VOLUME_FLAGS_MASK);
vi.flags = flags & VOLUME_FLAGS_MASK;
err = insert_resident_attr_in_mft_record(m, AT_VOLUME_INFORMATION, NULL,
0, CASE_SENSITIVE, const_cpu_to_le16(0),
0, (u8*)&vi, sizeof(vi));
@ -2277,10 +2289,10 @@ static int add_attr_index_root(MFT_RECORD *m, const char *name,
r = ntfs_malloc(val_len);
if (!r)
return -errno;
r->type = le32_eq(indexed_attr_type, AT_FILE_NAME)
r->type = (indexed_attr_type == AT_FILE_NAME)
? AT_FILE_NAME : const_cpu_to_le32(0);
if (le32_eq(indexed_attr_type, AT_FILE_NAME) &&
!le32_eq(collation_rule, COLLATION_FILE_NAME)) {
if (indexed_attr_type == AT_FILE_NAME &&
collation_rule != COLLATION_FILE_NAME) {
free(r);
ntfs_log_error("add_attr_index_root: indexed attribute is $FILE_NAME "
"but collation rule is not COLLATION_FILE_NAME.\n");
@ -2460,7 +2472,7 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
goto err_out;
}
a = ctx->attr;
if (a->non_resident || !le16_cmpz(a->flags)) {
if (a->non_resident || a->flags) {
err = -EINVAL;
goto err_out;
}
@ -2507,7 +2519,7 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
ia_val->index.allocated_size = cpu_to_le32(index_block_size -
(sizeof(INDEX_ALLOCATION) - sizeof(INDEX_HEADER)));
/* Find the last entry in the index root and save it in re. */
while ((char*)re < re_end && le16_andz(re->ie_flags, INDEX_ENTRY_END)) {
while ((char*)re < re_end && !(re->ie_flags & INDEX_ENTRY_END)) {
/* Next entry in index root. */
re = (INDEX_ENTRY*)((char*)re + le16_to_cpu(re->length));
}
@ -2525,7 +2537,7 @@ static int upgrade_to_large_index(MFT_RECORD *m, const char *name,
}
/* Now fixup empty index root with pointer to index allocation VCN 0. */
r->index.ih_flags = LARGE_INDEX;
re->ie_flags = le16_or(re->ie_flags, INDEX_ENTRY_NODE);
re->ie_flags |= INDEX_ENTRY_NODE;
if (le16_to_cpu(re->length) < sizeof(INDEX_ENTRY_HEADER) + sizeof(VCN))
re->length = cpu_to_le16(le16_to_cpu(re->length) + sizeof(VCN));
r->index.index_length = cpu_to_le32(le32_to_cpu(r->index.entries_offset)
@ -2631,7 +2643,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
u32 u1, u2;
int i;
if (le32_eq(collation_rule, COLLATION_NTOFS_ULONG)) {
if (collation_rule == COLLATION_NTOFS_ULONG) {
/* i.e. $SII or $QUOTA-$Q */
u1 = le32_to_cpup((const le32*)key1);
u2 = le32_to_cpup((const le32*)key2);
@ -2642,7 +2654,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
/* u1 == u2 */
return 0;
}
if (le32_eq(collation_rule, COLLATION_NTOFS_ULONGS)) {
if (collation_rule == COLLATION_NTOFS_ULONGS) {
/* i.e $OBJID-$O */
i = 0;
while (i < min(key1_length, key2_length)) {
@ -2661,7 +2673,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
return 1;
return 0;
}
if (le32_eq(collation_rule, COLLATION_NTOFS_SECURITY_HASH)) {
if (collation_rule == COLLATION_NTOFS_SECURITY_HASH) {
/* i.e. $SDH */
u1 = le32_to_cpu(((SDH_INDEX_KEY*)key1)->hash);
u2 = le32_to_cpu(((SDH_INDEX_KEY*)key2)->hash);
@ -2678,7 +2690,7 @@ static int ntfs_index_keys_compare(u8 *key1, u8 *key2, int key1_length,
return 1;
return 0;
}
if (le32_eq(collation_rule, COLLATION_NTOFS_SID)) {
if (collation_rule == COLLATION_NTOFS_SID) {
/* i.e. $QUOTA-O */
i = memcmp(key1, key2, min(key1_length, key2_length));
if (!i) {
@ -2741,9 +2753,9 @@ static int insert_index_entry_in_res_dir_index(INDEX_ENTRY *idx, u32 idx_size,
* Loop until we exceed valid memory (corruption case) or until we
* reach the last entry.
*/
if (le32_eq(type, AT_FILE_NAME)) {
if (type == AT_FILE_NAME) {
while (((u8*)idx_entry < (u8*)idx_end) &&
le16_andz(idx_entry->ie_flags, INDEX_ENTRY_END)) {
!(idx_entry->ie_flags & INDEX_ENTRY_END)) {
/*
i = ntfs_file_values_compare(&idx->key.file_name,
&idx_entry->key.file_name, 1,
@ -2786,9 +2798,9 @@ do_next:
idx_entry = (INDEX_ENTRY*)((u8*)idx_entry +
le16_to_cpu(idx_entry->length));
}
} else if (le32_eq(type, AT_UNUSED)) { /* case view */
} else if (type == AT_UNUSED) { /* case view */
while (((u8*)idx_entry < (u8*)idx_end) &&
le16_andz(idx_entry->ie_flags, INDEX_ENTRY_END)) {
!(idx_entry->ie_flags & INDEX_ENTRY_END)) {
i = ntfs_index_keys_compare((u8*)idx + 0x10,
(u8*)idx_entry + 0x10,
le16_to_cpu(idx->key_length),
@ -2850,7 +2862,7 @@ static int initialize_secure(char *sds, u32 sds_size, MFT_RECORD *m)
err = 0;
while ((char*)sds_header < (char*)sds + sds_size) {
if (le32_cmpz(sds_header->length))
if (!sds_header->length)
break;
/* SDH index entry */
idx_entry_sdh->data_offset = const_cpu_to_le16(0x18);
@ -3037,7 +3049,7 @@ static int insert_file_link_in_dir_index(INDEX_BLOCK *idx, leMFT_REF file_ref,
* Loop until we exceed valid memory (corruption case) or until we
* reach the last entry.
*/
while ((char*)ie < index_end && le16_andz(ie->ie_flags, INDEX_ENTRY_END)) {
while ((char*)ie < index_end && !(ie->ie_flags & INDEX_ENTRY_END)) {
#if 0
#ifdef DEBUG
ntfs_log_debug("file_name_attr1->file_name_length = %i\n",
@ -3115,7 +3127,7 @@ static int insert_file_link_in_dir_index(INDEX_BLOCK *idx, leMFT_REF file_ref,
do_next:
#ifdef DEBUG
/* Next entry. */
if (le16_cmpz(ie->length)) {
if (!ie->length) {
ntfs_log_debug("BUG: ie->length is zero, breaking out "
"of loop.\n");
break;
@ -4297,7 +4309,7 @@ static BOOL create_file_volume(MFT_RECORD *m, leMFT_REF root_ref,
m = (MFT_RECORD*)(g_buf + 3 * g_vol->mft_record_size);
err = create_hardlink(g_index_block, root_ref, m,
MK_LE_MREF(FILE_Volume, FILE_Volume), 0LL, 0LL,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$Volume", FILE_NAME_WIN32_AND_DOS);
if (!err) {
init_system_file_sd(FILE_Volume, &sd, &i);
@ -4310,7 +4322,7 @@ static BOOL create_file_volume(MFT_RECORD *m, leMFT_REF root_ref,
err = add_attr_vol_name(m, g_vol->vol_name, g_vol->vol_name ?
strlen(g_vol->vol_name) : 0);
if (!err) {
if (!le16_andz(fl, VOLUME_IS_DIRTY))
if (fl & VOLUME_IS_DIRTY)
ntfs_log_quiet("Setting the volume dirty so check "
"disk runs on next reboot into "
"Windows.\n");
@ -4447,16 +4459,16 @@ static BOOL mkntfs_create_root_structures(void)
m = (MFT_RECORD*)(g_buf + i * g_vol->mft_record_size);
if (i < 16 || i > 23) {
m->mft_record_number = cpu_to_le32(i);
m->flags = le16_or(m->flags, MFT_RECORD_IN_USE);
m->flags |= MFT_RECORD_IN_USE;
ntfs_bit_set(g_mft_bitmap, 0LL + i, 1);
}
file_attrs = le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM);
file_attrs = FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM;
if (i == FILE_root) {
file_attrs = le32_or(file_attrs, FILE_ATTR_ARCHIVE);
file_attrs |= FILE_ATTR_ARCHIVE;
if (opts.disable_indexing)
file_attrs = le32_or(file_attrs, FILE_ATTR_NOT_CONTENT_INDEXED);
file_attrs |= FILE_ATTR_NOT_CONTENT_INDEXED;
if (opts.enable_compression)
file_attrs = le32_or(file_attrs, FILE_ATTR_COMPRESSED);
file_attrs |= FILE_ATTR_COMPRESSED;
}
/* setting specific security_id flag and */
/* file permissions for ntfs 3.x */
@ -4465,15 +4477,15 @@ static BOOL mkntfs_create_root_structures(void)
add_attr_std_info(m, file_attrs,
const_cpu_to_le32(0x0100));
} else if (i == 9) {
file_attrs = le32_or(file_attrs, FILE_ATTR_VIEW_INDEX_PRESENT);
file_attrs |= FILE_ATTR_VIEW_INDEX_PRESENT;
add_attr_std_info(m, file_attrs,
const_cpu_to_le32(0x0101));
} else if (i == 11) {
add_attr_std_info(m, file_attrs,
const_cpu_to_le32(0x0101));
} else if (i == 24 || i == 25 || i == 26) {
file_attrs = le32_or(file_attrs, FILE_ATTR_ARCHIVE);
file_attrs = le32_or(file_attrs, FILE_ATTR_VIEW_INDEX_PRESENT);
file_attrs |= FILE_ATTR_ARCHIVE;
file_attrs |= FILE_ATTR_VIEW_INDEX_PRESENT;
add_attr_std_info(m, file_attrs,
const_cpu_to_le32(0x0101));
} else {
@ -4486,11 +4498,11 @@ static BOOL mkntfs_create_root_structures(void)
extend_ref = MK_LE_MREF(11,11);
ntfs_log_verbose("Creating root directory (mft record 5)\n");
m = (MFT_RECORD*)(g_buf + 5 * g_vol->mft_record_size);
m->flags = le16_or(m->flags, MFT_RECORD_IS_DIRECTORY);
m->flags |= MFT_RECORD_IS_DIRECTORY;
m->link_count = cpu_to_le16(le16_to_cpu(m->link_count) + 1);
err = add_attr_file_name(m, root_ref, 0LL, 0LL,
le32_or(FILE_ATTR_HIDDEN, le32_or(FILE_ATTR_SYSTEM,
FILE_ATTR_I30_INDEX_PRESENT)), 0, 0, ".",
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM |
FILE_ATTR_I30_INDEX_PRESENT, 0, 0, ".",
FILE_NAME_WIN32_AND_DOS);
if (!err) {
init_root_sd(&sd, &i);
@ -4544,8 +4556,8 @@ static BOOL mkntfs_create_root_structures(void)
MK_LE_MREF(FILE_MFT, 1),
((g_mft_size - 1)
| (g_vol->cluster_size - 1)) + 1,
g_mft_size, le32_or(FILE_ATTR_HIDDEN,
FILE_ATTR_SYSTEM), 0, 0, "$MFT",
g_mft_size, FILE_ATTR_HIDDEN |
FILE_ATTR_SYSTEM, 0, 0, "$MFT",
FILE_NAME_WIN32_AND_DOS);
/* mft_bitmap is not modified in mkntfs; no need to sync it later. */
if (!err)
@ -4566,7 +4578,7 @@ static BOOL mkntfs_create_root_structures(void)
MK_LE_MREF(FILE_MFTMirr, FILE_MFTMirr),
g_rl_mftmirr[0].length * g_vol->cluster_size,
g_rl_mftmirr[0].length * g_vol->cluster_size,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$MFTMirr", FILE_NAME_WIN32_AND_DOS);
if (err < 0) {
ntfs_log_error("Couldn't create $MFTMirr: %s\n",
@ -4582,7 +4594,7 @@ static BOOL mkntfs_create_root_structures(void)
err = create_hardlink(g_index_block, root_ref, m,
MK_LE_MREF(FILE_LogFile, FILE_LogFile),
g_logfile_size, g_logfile_size,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$LogFile", FILE_NAME_WIN32_AND_DOS);
if (err < 0) {
ntfs_log_error("Couldn't create $LogFile: %s\n",
@ -4598,7 +4610,7 @@ static BOOL mkntfs_create_root_structures(void)
MK_LE_MREF(FILE_AttrDef, FILE_AttrDef),
(g_vol->attrdef_len + g_vol->cluster_size - 1) &
~(g_vol->cluster_size - 1), g_vol->attrdef_len,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$AttrDef", FILE_NAME_WIN32_AND_DOS);
if (!err) {
init_system_file_sd(FILE_AttrDef, &sd, &i);
@ -4626,7 +4638,7 @@ static BOOL mkntfs_create_root_structures(void)
(g_lcn_bitmap_byte_size + g_vol->cluster_size -
1) & ~(g_vol->cluster_size - 1),
g_lcn_bitmap_byte_size,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$Bitmap", FILE_NAME_WIN32_AND_DOS);
if (err < 0) {
ntfs_log_error("Couldn't create $Bitmap: %s\n", strerror(-err));
@ -4720,7 +4732,7 @@ static BOOL mkntfs_create_root_structures(void)
MK_LE_MREF(FILE_Boot, FILE_Boot),
(8192 + g_vol->cluster_size - 1) &
~(g_vol->cluster_size - 1), 8192,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$Boot", FILE_NAME_WIN32_AND_DOS);
if (!err) {
init_system_file_sd(FILE_Boot, &sd, &i);
@ -4737,7 +4749,7 @@ static BOOL mkntfs_create_root_structures(void)
* odd and we failed to set the device block size to the sector
* size, hence we schedule chkdsk to create it.
*/
volume_flags = le16_or(volume_flags, VOLUME_IS_DIRTY);
volume_flags |= VOLUME_IS_DIRTY;
}
free(bs);
/*
@ -4770,7 +4782,7 @@ static BOOL mkntfs_create_root_structures(void)
if (!err) {
err = create_hardlink(g_index_block, root_ref, m,
MK_LE_MREF(FILE_BadClus, FILE_BadClus),
0LL, 0LL, le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM),
0LL, 0LL, FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM,
0, 0, "$BadClus", FILE_NAME_WIN32_AND_DOS);
}
if (err < 0) {
@ -4781,12 +4793,12 @@ static BOOL mkntfs_create_root_structures(void)
/* create $Secure (NTFS 3.0+) */
ntfs_log_verbose("Creating $Secure (mft record 9)\n");
m = (MFT_RECORD*)(g_buf + 9 * g_vol->mft_record_size);
m->flags = le16_or(m->flags, MFT_RECORD_IS_VIEW_INDEX);
m->flags |= MFT_RECORD_IS_VIEW_INDEX;
if (!err)
err = create_hardlink(g_index_block, root_ref, m,
MK_LE_MREF(9, 9), 0LL, 0LL,
le32_or(FILE_ATTR_HIDDEN, le32_or(FILE_ATTR_SYSTEM,
FILE_ATTR_VIEW_INDEX_PRESENT)), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM |
FILE_ATTR_VIEW_INDEX_PRESENT, 0, 0,
"$Secure", FILE_NAME_WIN32_AND_DOS);
buf_sds = NULL;
buf_sds_first_size = 0;
@ -4841,7 +4853,7 @@ static BOOL mkntfs_create_root_structures(void)
g_vol->cluster_size - 1) &
~(g_vol->cluster_size - 1),
g_vol->upcase_len << 1,
le32_or(FILE_ATTR_HIDDEN, FILE_ATTR_SYSTEM), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM, 0, 0,
"$UpCase", FILE_NAME_WIN32_AND_DOS);
if (err < 0) {
ntfs_log_error("Couldn't create $UpCase: %s\n", strerror(-err));
@ -4853,12 +4865,12 @@ static BOOL mkntfs_create_root_structures(void)
* volume as corrupt. (ERSO)
*/
m = (MFT_RECORD*)(g_buf + 11 * g_vol->mft_record_size);
m->flags = le16_or(m->flags, MFT_RECORD_IS_DIRECTORY);
m->flags |= MFT_RECORD_IS_DIRECTORY;
if (!err)
err = create_hardlink(g_index_block, root_ref, m,
MK_LE_MREF(11, 11), 0LL, 0LL,
le32_or(FILE_ATTR_HIDDEN, le32_or(FILE_ATTR_SYSTEM,
FILE_ATTR_I30_INDEX_PRESENT)), 0, 0,
FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM |
FILE_ATTR_I30_INDEX_PRESENT, 0, 0,
"$Extend", FILE_NAME_WIN32_AND_DOS);
/* FIXME: This should be IGNORE_CASE */
if (!err)
@ -4888,12 +4900,12 @@ static BOOL mkntfs_create_root_structures(void)
}
/* create systemfiles for ntfs volumes (3.1) */
/* starting with file 24 (ignoring file 16-23) */
extend_flags = le32_or(FILE_ATTR_HIDDEN, le32_or(FILE_ATTR_SYSTEM,
le32_or(FILE_ATTR_ARCHIVE, FILE_ATTR_VIEW_INDEX_PRESENT)));
extend_flags = FILE_ATTR_HIDDEN | FILE_ATTR_SYSTEM |
FILE_ATTR_ARCHIVE | FILE_ATTR_VIEW_INDEX_PRESENT;
ntfs_log_verbose("Creating $Quota (mft record 24)\n");
m = (MFT_RECORD*)(g_buf + 24 * g_vol->mft_record_size);
m->flags = le16_or(m->flags, MFT_RECORD_IS_4);
m->flags = le16_or(m->flags, MFT_RECORD_IS_VIEW_INDEX);
m->flags |= MFT_RECORD_IS_4;
m->flags |= MFT_RECORD_IS_VIEW_INDEX;
if (!err)
err = create_hardlink_res((MFT_RECORD*)(g_buf +
11 * g_vol->mft_record_size), extend_ref, m,
@ -4915,8 +4927,8 @@ static BOOL mkntfs_create_root_structures(void)
}
ntfs_log_verbose("Creating $ObjId (mft record 25)\n");
m = (MFT_RECORD*)(g_buf + 25 * g_vol->mft_record_size);
m->flags = le16_or(m->flags, MFT_RECORD_IS_4);
m->flags = le16_or(m->flags, MFT_RECORD_IS_VIEW_INDEX);
m->flags |= MFT_RECORD_IS_4;
m->flags |= MFT_RECORD_IS_VIEW_INDEX;
if (!err)
err = create_hardlink_res((MFT_RECORD*)(g_buf +
11 * g_vol->mft_record_size), extend_ref,
@ -4939,8 +4951,8 @@ static BOOL mkntfs_create_root_structures(void)
}
ntfs_log_verbose("Creating $Reparse (mft record 26)\n");
m = (MFT_RECORD*)(g_buf + 26 * g_vol->mft_record_size);
m->flags = le16_or(m->flags, MFT_RECORD_IS_4);
m->flags = le16_or(m->flags, MFT_RECORD_IS_VIEW_INDEX);
m->flags |= MFT_RECORD_IS_4;
m->flags |= MFT_RECORD_IS_VIEW_INDEX;
if (!err)
err = create_hardlink_res((MFT_RECORD*)(g_buf +
11 * g_vol->mft_record_size),

View File

@ -126,7 +126,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
Read \fBlibntfs\fR(8) for details how to access encrypted files.

View File

@ -201,7 +201,7 @@ static int parse_options(int argc, char **argv)
}
break;
case 'a':
if (!le32_eq(opts.attr, const_cpu_to_le32(-1))) {
if (opts.attr != const_cpu_to_le32(-1)) {
ntfs_log_error("You must specify exactly one "
"attribute.\n");
} else if (parse_attribute(optarg, &attr) > 0) {
@ -353,9 +353,9 @@ static int cat(ntfs_volume *vol, ntfs_inode *inode, ATTR_TYPES type,
return 1;
}
if ((inode->mft_no < 2) && le32_eq(attr->type, AT_DATA))
if ((inode->mft_no < 2) && (attr->type == AT_DATA))
block_size = vol->mft_record_size;
else if (le32_eq(attr->type, AT_INDEX_ALLOCATION))
else if (attr->type == AT_INDEX_ALLOCATION)
block_size = index_get_size(inode);
else
block_size = 0;
@ -446,7 +446,7 @@ int main(int argc, char *argv[])
}
attr = AT_DATA;
if (!le32_eq(opts.attr, const_cpu_to_le32(-1)))
if (opts.attr != const_cpu_to_le32(-1))
attr = opts.attr;
result = cat(vol, inode, attr, opts.attr_name, opts.attr_name_len);

View File

@ -209,7 +209,7 @@ static BOOL verify_boot_sector(struct ntfs_device *dev, ntfs_volume *rawvol)
(buf[2]!=0x90)) {
check_failed("Boot sector: Bad jump.\n");
}
if (!le64_eq(ntfs_boot->oem_id, magicNTFS)) {
if (ntfs_boot->oem_id != magicNTFS) {
check_failed("Boot sector: Bad NTFS magic.\n");
}
bytes_per_sector = le16_to_cpu(ntfs_boot->bpb.bytes_per_sector);
@ -281,7 +281,7 @@ static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, ATT
//printf("Attr type: 0x%x.\n", attr_rec->type);
// Check attribute record. (Only what is in the buffer)
if (le32_eq(attr_rec->type, AT_END)) {
if (attr_rec->type==AT_END) {
check_failed("Attribute 0x%x not found in file record at offset %lld (0x%llx).\n", (int)le32_to_cpu(attr_rec->type),
(long long)offset_to_file_record,
(long long)offset_to_file_record);
@ -307,7 +307,7 @@ static runlist *load_runlist(ntfs_volume *rawvol, s64 offset_to_file_record, ATT
}
// todo: what ATTRIBUTE_LIST (0x20)?
if (le32_eq(attr_rec->type, attr_type)) {
if (attr_rec->type==attr_type) {
// Eurika!
// ntfs_mapping_pairs_decompress only use two values from vol. Just fake it.
@ -449,7 +449,7 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
// If this is the first attribute:
// todo: instance number must be smaller than next_instance.
if ((u8*)attr_rec == ((u8*)mft_rec) + attrs_offset) {
if (le64_cmpz(mft_rec->base_mft_record))
if (!mft_rec->base_mft_record)
assert_u32_equal(attr_type, 0x10,
"First attribute type");
// The following not always holds.
@ -469,7 +469,7 @@ static ATTR_REC *check_attr_record(ATTR_REC *attr_rec, MFT_RECORD *mft_rec,
// todo: instance is unique.
// Check flags.
if (!le16_andz(attr_rec->flags, le16_not(const_cpu_to_le16(0xc0ff)))) {
if (attr_rec->flags & ~(const_cpu_to_le16(0xc0ff))) {
check_failed("Attribute %lld:0x%x Unknown flags (0x%x).\n",
(long long)current_mft_record, (int)attr_type,
(int)le16_to_cpu(attr_rec->flags));
@ -616,7 +616,8 @@ static BOOL check_file_record(u8 *buffer, u16 buflen)
// Remove update seq & check it.
usa = *(u16*)(buffer+usa_ofs); // The value that should be at the end of every sector.
assert_u32_equal(usa_count-1, buflen/NTFS_BLOCK_SIZE, "USA length");
if (assert_u32_equal(usa_count-1, buflen/NTFS_BLOCK_SIZE, "USA length"))
return (1);
for (i=1;i<usa_count;i++) {
u16 *fixup = (u16*)(buffer+NTFS_BLOCK_SIZE*i-2); // the value at the end of the sector.
u16 saved_val = *(u16*)(buffer+usa_ofs+2*i); // the actual data value that was saved in the us array.
@ -629,7 +630,7 @@ static BOOL check_file_record(u8 *buffer, u16 buflen)
while ((u8*)attr_rec<=buffer+buflen-4) {
// Check attribute record. (Only what is in the buffer)
if (le32_eq(attr_rec->type, AT_END)) {
if (attr_rec->type==AT_END) {
// Done.
return 0;
}
@ -791,12 +792,12 @@ static int reset_dirty(ntfs_volume *vol)
{
le16 flags;
if (le16_cmpz(le16_or(vol->flags, VOLUME_IS_DIRTY)))
if (!(vol->flags | VOLUME_IS_DIRTY))
return 0;
ntfs_log_verbose("Resetting dirty flag.\n");
flags = le16_and(vol->flags, le16_not(VOLUME_IS_DIRTY));
flags = vol->flags & ~VOLUME_IS_DIRTY;
if (ntfs_volume_write_flags(vol, flags)) {
ntfs_log_error("Error setting volume flags.\n");
@ -858,7 +859,7 @@ int main(int argc, char **argv)
replay_log(vol);
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY))
if (vol->flags & VOLUME_IS_DIRTY)
ntfs_log_warning("Volume is dirty.\n");
check_volume(vol);

View File

@ -387,7 +387,7 @@ is part of the
package and is available at:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfsresize (8)

View File

@ -637,13 +637,13 @@ static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl)
if (inode <= LAST_METADATA_INODE) {
/* Don't save bad sectors (both $Bad and unnamed are ignored */
if (inode == FILE_BadClus && le32_eq(image->ctx->attr->type, AT_DATA))
if (inode == FILE_BadClus && image->ctx->attr->type == AT_DATA)
return 0;
if ((inode != FILE_LogFile) || opt.full_logfile)
return rl->length;
if (le32_eq(image->ctx->attr->type, AT_DATA)) {
if (image->ctx->attr->type == AT_DATA) {
/* Save at least the first 16 KiB of FILE_LogFile */
s64 s = (s64)16384 - rl->vcn * vol->cluster_size;
@ -657,7 +657,7 @@ static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl)
}
}
if (!le32_eq(image->ctx->attr->type, AT_DATA))
if (image->ctx->attr->type != AT_DATA)
return rl->length;
return 0;
@ -831,8 +831,8 @@ static void copy_cluster(int rescue, u64 rescue_lcn, u64 lcn)
else {
mask = const_cpu_to_le64(~0x0ffffffffULL);
bs->volume_serial_number
= le64_or(le64_and(volume_serial_number, mask),
le64_and(bs->volume_serial_number, le64_not(mask)));
= (volume_serial_number & mask)
| (bs->volume_serial_number & ~mask);
}
/* Show the new full serial after merging */
if (!lcn)
@ -1102,7 +1102,7 @@ static void wipe_index_entry_timestams(INDEX_ENTRY *e)
sle64 timestamp = timespec2ntfs(zero_time);
/* FIXME: can fall into infinite loop if corrupted */
while (le16_andz(e->ie_flags, INDEX_ENTRY_END)) {
while (!(e->ie_flags & INDEX_ENTRY_END)) {
e->key.file_name.creation_time = timestamp;
e->key.file_name.last_data_change_time = timestamp;
@ -1133,7 +1133,7 @@ static void wipe_index_allocation_timestamps(ntfs_inode *ni, ATTR_RECORD *attr)
return;
}
if (!le32_eq(indexr->type, AT_FILE_NAME))
if (indexr->type != AT_FILE_NAME)
goto out_indexr;
name = (ntfschar *)((u8 *)attr + le16_to_cpu(attr->name_offset));
@ -1218,9 +1218,9 @@ static void wipe_index_root_timestamps(ATTR_RECORD *attr, sle64 timestamp)
entry = (INDEX_ENTRY *)((u8 *)iroot +
le32_to_cpu(iroot->index.entries_offset) + 0x10);
while (le16_andz(entry->ie_flags, INDEX_ENTRY_END)) {
while (!(entry->ie_flags & INDEX_ENTRY_END)) {
if (le32_eq(iroot->type, AT_FILE_NAME)) {
if (iroot->type == AT_FILE_NAME) {
entry->key.file_name.creation_time = timestamp;
entry->key.file_name.last_access_time = timestamp;
@ -1274,13 +1274,13 @@ static void wipe_timestamps(ntfs_walk_clusters_ctx *image)
ATTR_RECORD *a = image->ctx->attr;
sle64 timestamp = timespec2ntfs(zero_time);
if (le32_eq(a->type, AT_FILE_NAME))
if (a->type == AT_FILE_NAME)
WIPE_TIMESTAMPS(FILE_NAME_ATTR, a, timestamp);
else if (le32_eq(a->type, AT_STANDARD_INFORMATION))
else if (a->type == AT_STANDARD_INFORMATION)
WIPE_TIMESTAMPS(STANDARD_INFORMATION, a, timestamp);
else if (le32_eq(a->type, AT_INDEX_ROOT))
else if (a->type == AT_INDEX_ROOT)
wipe_index_root_timestamps(a, timestamp);
}
@ -1297,7 +1297,7 @@ static void wipe_resident_data(ntfs_walk_clusters_ctx *image)
if (image->ni->mft_no <= LAST_METADATA_INODE)
return;
if (!le32_eq(a->type, AT_DATA))
if (a->type != AT_DATA)
return;
for (i = 0; i < le32_to_cpu(a->value_length); i++) {
@ -1401,7 +1401,7 @@ static void wipe_mft(char *mrec, u32 mrecsz, u64 mft_no)
image.ni = &ni;
ntfs_mst_post_read_fixup_warn((NTFS_RECORD*)mrec,mrecsz,FALSE);
wipe_unused_mft_data(&ni);
if (le16_andz(((MFT_RECORD*)mrec)->flags, MFT_RECORD_IN_USE)) {
if (!(((MFT_RECORD*)mrec)->flags & MFT_RECORD_IN_USE)) {
wipe_unused_mft(&ni);
} else {
/* ctx with no ntfs_inode prevents from searching external attrs */
@ -1410,7 +1410,7 @@ static void wipe_mft(char *mrec, u32 mrecsz, u64 mft_no)
while (!ntfs_attr_lookup(AT_UNUSED, NULL, 0, CASE_SENSITIVE, 0,
NULL, 0, ctx)) {
if (le32_eq(ctx->attr->type, AT_END))
if (ctx->attr->type == AT_END)
break;
image.ctx = ctx;
@ -1447,7 +1447,7 @@ static void wipe_indx(char *mrec, u32 mrecsz)
* The index bitmap is not checked, obsoleted records are
* wiped if they pass the safety checks
*/
if (le32_eq(indexa->magic, magic_INDX)
if ((indexa->magic == magic_INDX)
&& (le32_to_cpu(indexa->index.entries_offset) >= sizeof(INDEX_HEADER))
&& (le32_to_cpu(indexa->index.allocated_size) <= mrecsz)) {
entry = (INDEX_ENTRY *)((u8 *)mrec + le32_to_cpu(
@ -1704,7 +1704,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
if (wipe
&& !opt.preserve_timestamps
&& le32_eq(walk->image->ctx->attr->type, AT_INDEX_ALLOCATION))
&& walk->image->ctx->attr->type == AT_INDEX_ALLOCATION)
wipe_index_allocation_timestamps(walk->image->ni, a);
if (!(rl = ntfs_mapping_pairs_decompress(vol, a, NULL)))
@ -1713,8 +1713,8 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
/* special wipings for MFT records and directory indexes */
mft_data = ((walk->image->ni->mft_no == FILE_MFT)
|| (walk->image->ni->mft_no == FILE_MFTMirr))
&& le32_eq(a->type, AT_DATA);
index_i30 = le32_eq(walk->image->ctx->attr->type, AT_INDEX_ALLOCATION)
&& (a->type == AT_DATA);
index_i30 = (walk->image->ctx->attr->type == AT_INDEX_ALLOCATION)
&& (a->name_length == 4)
&& !memcmp((char*)a + le16_to_cpu(a->name_offset),
NTFS_INDEX_I30,8);
@ -1761,14 +1761,14 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
*/
if (!wipe && opt.metadata_image) {
if ((walk->image->ni->mft_no == FILE_LogFile)
&& le32_eq(walk->image->ctx->attr->type, AT_DATA)) {
&& (walk->image->ctx->attr->type == AT_DATA)) {
/* 16 KiB of FILE_LogFile */
walk->image->inuse
+= is_critical_metadata(walk->image,rl);
} else {
if ((walk->image->ni->mft_no
<= LAST_METADATA_INODE)
|| !le32_eq(walk->image->ctx->attr->type, AT_DATA))
|| (walk->image->ctx->attr->type != AT_DATA))
walk->image->inuse += lcn_length;
}
}
@ -1780,7 +1780,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
* because its logical blocks may be larger than
* a cluster and split over two extents.
*/
if (mft_data && sle64_cmpz(a->lowest_vcn)) {
if (mft_data && !a->lowest_vcn) {
na = ntfs_attr_open(walk->image->ni,
AT_DATA, NULL, 0);
if (na) {
@ -1796,7 +1796,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
perr_exit("Failed to open data of inode %lld",
(long long)walk->image->ni->mft_no);
}
if (index_i30 && sle64_cmpz(a->lowest_vcn)) {
if (index_i30 && !a->lowest_vcn) {
na = ntfs_attr_open(walk->image->ni,
AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4);
if (na) {
@ -1816,7 +1816,7 @@ static void walk_runs(struct ntfs_walk_cluster *walk)
if (opt.metadata
&& (opt.metadata_image || !wipe)
&& (walk->image->ni->mft_no == FILE_LogFile)
&& le32_eq(walk->image->ctx->attr->type, AT_DATA))
&& (walk->image->ctx->attr->type == AT_DATA))
clone_logfile_parts(walk->image, rl);
free(rl);
@ -1831,7 +1831,7 @@ static void walk_attributes(struct ntfs_walk_cluster *walk)
perr_exit("ntfs_get_attr_search_ctx");
while (!ntfs_attrs_walk(ctx)) {
if (le32_eq(ctx->attr->type, AT_END))
if (ctx->attr->type == AT_END)
break;
walk->image->ctx = ctx;
@ -1996,7 +1996,7 @@ static int walk_clusters(ntfs_volume *volume, struct ntfs_walk_cluster *walk)
continue;
}
deleted_inode = le16_andz(ni->mrec->flags, MFT_RECORD_IN_USE);
deleted_inode = !(ni->mrec->flags & MFT_RECORD_IN_USE);
if (deleted_inode && !opt.metadata_image) {
@ -2026,7 +2026,7 @@ static int walk_clusters(ntfs_volume *volume, struct ntfs_walk_cluster *walk)
if (wipe)
nr_used_mft_records++;
if (!le64_cmpz(ni->mrec->base_mft_record))
if (ni->mrec->base_mft_record)
goto out;
walk->image->ni = ni;
@ -2211,7 +2211,7 @@ static void mount_volume(unsigned long new_mntflag)
exit(1);
}
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY))
if (vol->flags & VOLUME_IS_DIRTY)
if (opt.force-- <= 0)
err_exit(dirty_volume_msg, opt.volume);

View File

@ -117,7 +117,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfsinfo (8),

View File

@ -67,7 +67,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfsinfo (8),

View File

@ -363,7 +363,7 @@ static int inode_open(ntfs_volume *vol, MFT_REF mref, ntfs_inode **ni)
return NTFSCMP_INODE_OPEN_ERROR;
}
if (!le64_cmpz((*ni)->mrec->base_mft_record)) {
if ((*ni)->mrec->base_mft_record) {
if (inode_close(*ni) != 0)
return NTFSCMP_INODE_CLOSE_ERROR;
@ -423,7 +423,7 @@ static char *get_attr_name(u64 mft_no,
char *name = NULL;
int name_len;
if (le32_eq(atype, AT_END))
if (atype == AT_END)
return NULL;
name_len = ntfs_ucstombs(uname, uname_len, &name, 0);
@ -707,7 +707,7 @@ static void cmp_attribute(ntfs_attr_search_ctx *ctx1,
goto close_attribs;
}
if (le32_eq(na1->type, AT_INDEX_ALLOCATION))
if (na1->type == AT_INDEX_ALLOCATION)
cmp_index_allocation(na1, na2);
else
cmp_attribute_data(na1, na2);
@ -764,13 +764,13 @@ static int new_attribute(ntfs_attr_search_ctx *ctx,
ATTR_TYPES prev_atype,
char *prev_name)
{
if (le32_cmpz(prev_atype) && !prev_name)
if (!prev_atype && !prev_name)
return 1;
if (!ctx->attr->non_resident)
return 1;
if (!le32_eq(prev_atype, ctx->attr->type))
if (prev_atype != ctx->attr->type)
return 1;
if (new_name(ctx, prev_name))

View File

@ -113,7 +113,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g
.hy
.SH SEE ALSO
.BR ntfsprogs (8)

View File

@ -199,7 +199,7 @@ static int parse_options(int argc, char **argv)
}
break;
case 'a':
if (!le32_eq(opts.attribute, AT_DATA)) {
if (opts.attribute != AT_DATA) {
ntfs_log_error("You can specify only one "
"attribute.\n");
err++;
@ -293,7 +293,7 @@ static int parse_options(int argc, char **argv)
err++;
}
if (opts.timestamp
&& (opts.attr_name || !le32_eq(opts.attribute, AT_DATA))) {
&& (opts.attr_name || (opts.attribute != AT_DATA))) {
ntfs_log_error("Setting --timestamp is only possible"
" with unname data attribute.\n");
err++;
@ -626,15 +626,15 @@ static int set_sizes(struct ALLOC_CONTEXT *alctx, ntfs_attr_search_ctx *ctx)
attr->data_size = cpu_to_sle64(na->data_size);
attr->initialized_size = cpu_to_sle64(na->initialized_size);
attr->allocated_size = cpu_to_sle64(na->allocated_size);
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE))
if (na->data_flags & ATTR_IS_SPARSE)
attr->compressed_size = cpu_to_sle64(na->compressed_size);
/* Copy the unnamed data attribute sizes to inode */
if (le32_eq(opts.attribute, AT_DATA) && !na->name_len) {
if ((opts.attribute == AT_DATA) && !na->name_len) {
ni = na->ni;
ni->data_size = na->data_size;
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE)) {
if (na->data_flags & ATTR_IS_SPARSE) {
ni->allocated_size = na->compressed_size;
ni->flags = le32_or(ni->flags, FILE_ATTR_SPARSE_FILE);
ni->flags |= FILE_ATTR_SPARSE_FILE;
} else
ni->allocated_size = na->allocated_size;
}
@ -883,7 +883,7 @@ int main(int argc, char *argv[])
return 1;
}
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY) && !opts.force)
if ((vol->flags & VOLUME_IS_DIRTY) && !opts.force)
goto umount;
NVolSetCompression(vol); /* allow compression */
@ -962,7 +962,7 @@ int main(int argc, char *argv[])
dir_ni = ntfs_inode_open(vol, FILE_root);
}
if (dir_ni) {
if (le16_andz(dir_ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (!(dir_ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
/* Remove the last '/' for estetic reasons. */
dirname_last_whack[0] = 0;
ntfs_log_error("The file '%s' already exists "
@ -993,7 +993,7 @@ int main(int argc, char *argv[])
free(parent_dirname);
}
/* The destination is a directory. */
if (!le16_andz(out->mrec->flags, MFT_RECORD_IS_DIRECTORY) && !opts.inode) {
if ((out->mrec->flags & MFT_RECORD_IS_DIRECTORY) && !opts.inode) {
char *filename;
char *overwrite_filename;
int overwrite_filename_len;
@ -1143,7 +1143,7 @@ int main(int argc, char *argv[])
}
offset += bw;
}
if (!le16_andz(na->data_flags, ATTR_COMPRESSION_MASK)
if ((na->data_flags & ATTR_COMPRESSION_MASK)
&& ntfs_attr_pclose(na))
ntfs_log_perror("ERROR: ntfs_attr_pclose failed");
ntfs_log_verbose("Syncing.\n");

View File

@ -120,7 +120,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
Read \fBntfs-3g\fR(8) for details on option efs_raw,

View File

@ -96,23 +96,13 @@ typedef enum {
* this registry key. It would be interesting to check out encryption on one
* of the "crippled" crypto Windows versions...
*/
#if ENABLE_STRICT_ENDIANNESS_CHECKING
typedef le32 NTFS_CRYPTO_ALGORITHMS;
static const le32
#else
typedef enum {
#endif
CALG_DES = const_cpu_to_le32(0x6601),
/* If not one of the below three, fall back to standard Des. */
CALG_3DES = const_cpu_to_le32(0x6603),
CALG_DESX = const_cpu_to_le32(0x6604),
CALG_AES_256 = const_cpu_to_le32(0x6610),
#if !ENABLE_STRICT_ENDIANNESS_CHECKING
} NTFS_CRYPTO_ALGORITHMS;
#else
__NTFS_CRYPTO_ALGORITHMS_end;
#endif
typedef struct {
u64 in_whitening, out_whitening;
@ -1083,27 +1073,27 @@ static ntfs_fek *ntfs_fek_import_from_raw(u8 *fek_buf, unsigned fek_size)
fek->des_gcry_cipher_hd_ptr = NULL;
*(gcry_cipher_hd_t***)(fek->key_data + ((key_size + 7) & ~7)) =
&fek->des_gcry_cipher_hd_ptr;
/* switch (fek->alg_id) { */
if (le32_eq(fek->alg_id, CALG_DESX)) {
switch (fek->alg_id) {
case CALG_DESX:
wanted_key_size = 16;
gcry_algo = GCRY_CIPHER_DES;
gcry_mode = GCRY_CIPHER_MODE_ECB;
}
else if (le32_eq(fek->alg_id, CALG_3DES)) {
break;
case CALG_3DES:
wanted_key_size = 24;
gcry_algo = GCRY_CIPHER_3DES;
gcry_mode = GCRY_CIPHER_MODE_CBC;
}
else if (le32_eq(fek->alg_id, CALG_AES_256)) {
break;
case CALG_AES_256:
wanted_key_size = 32;
gcry_algo = GCRY_CIPHER_AES256;
gcry_mode = GCRY_CIPHER_MODE_CBC;
}
else {
break;
default:
wanted_key_size = 8;
gcry_algo = GCRY_CIPHER_DES;
gcry_mode = GCRY_CIPHER_MODE_CBC;
if (le32_eq(fek->alg_id, CALG_DES))
if (fek->alg_id == CALG_DES)
ntfs_log_error("DES is not supported at present\n");
else
ntfs_log_error("Unknown crypto algorithm 0x%x\n",
@ -1132,7 +1122,7 @@ static ntfs_fek *ntfs_fek_import_from_raw(u8 *fek_buf, unsigned fek_size)
err = EINVAL;
goto out;
}
if (le32_eq(fek->alg_id, CALG_DESX)) {
if (fek->alg_id == CALG_DESX) {
err = ntfs_desx_key_expand(fek->key_data, (u32*)ctx->des_key,
&ctx->out_whitening, &ctx->in_whitening);
if (err == GPG_ERR_NO_ERROR)
@ -1190,7 +1180,7 @@ static ntfs_fek *ntfs_df_array_fek_get(EFS_DF_ARRAY_HEADER *df_array,
(u8*)df_header + le32_to_cpu(df_header->df_length))) {
df_cred = (EFS_DF_CREDENTIAL_HEADER*)((u8*)df_header +
le32_to_cpu(df_header->cred_header_offset));
if (!le32_eq(df_cred->type, NTFS_CRED_TYPE_CERT_THUMBPRINT)) {
if (df_cred->type != NTFS_CRED_TYPE_CERT_THUMBPRINT) {
ntfs_log_debug("Credential type is not certificate "
"thumbprint, skipping DF entry.\n");
continue;
@ -1258,14 +1248,14 @@ static ntfs_fek *ntfs_inode_fek_get(ntfs_inode *inode,
* iterate through the DDF or DRF array, respectively.
*/
if (df_type == DF_TYPE_DDF) {
if (!le32_cmpz(efs->offset_to_ddf_array))
if (efs->offset_to_ddf_array)
df_array = (EFS_DF_ARRAY_HEADER*)((u8*)efs +
le32_to_cpu(efs->offset_to_ddf_array));
else
ntfs_log_error("There are no entries in the DDF "
"array.\n");
} else if (df_type == DF_TYPE_DRF) {
if (!le32_cmpz(efs->offset_to_drf_array))
if (efs->offset_to_drf_array)
df_array = (EFS_DF_ARRAY_HEADER*)((u8*)efs +
le32_to_cpu(efs->offset_to_drf_array));
else
@ -1299,7 +1289,7 @@ static int ntfs_fek_decrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset)
* that gcry_cipher_setiv() wants an iv of length 8 bytes but we give
* it a length of 16 for AES256 so it does not like it.
*/
if (le32_eq(fek->alg_id, CALG_DESX)) {
if (fek->alg_id == CALG_DESX) {
int k;
fek->desx_ctx.prev_blk = 0;
@ -1313,12 +1303,12 @@ static int ntfs_fek_decrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset)
return -1;
}
/* Apply the IV. */
if (le32_eq(fek->alg_id, CALG_AES_256)) {
((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x5816657be9161312ULL + offset));
((le64*)data)[1] = le64_xor(((le64*)data)[1], cpu_to_le64(0x1989adbe44918961ULL + offset));
if (fek->alg_id == CALG_AES_256) {
((le64*)data)[0] ^= cpu_to_le64(0x5816657be9161312ULL + offset);
((le64*)data)[1] ^= cpu_to_le64(0x1989adbe44918961ULL + offset);
} else {
/* All other algos (Des, 3Des, DesX) use the same IV. */
((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x169119629891ad13ULL + offset));
((le64*)data)[0] ^= cpu_to_le64(0x169119629891ad13ULL + offset);
}
return 512;
}
@ -1343,14 +1333,14 @@ static int ntfs_fek_encrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset)
* it a length of 16 for AES256 so it does not like it.
*/
/* Apply the IV. */
if (le32_eq(fek->alg_id, CALG_AES_256)) {
((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x5816657be9161312ULL + offset));
((le64*)data)[1] = le64_xor(((le64*)data)[1], cpu_to_le64(0x1989adbe44918961ULL + offset));
if (fek->alg_id == CALG_AES_256) {
((le64*)data)[0] ^= cpu_to_le64(0x5816657be9161312ULL + offset);
((le64*)data)[1] ^= cpu_to_le64(0x1989adbe44918961ULL + offset);
} else {
/* All other algos (Des, 3Des, DesX) use the same IV. */
((le64*)data)[0] = le64_xor(((le64*)data)[0], cpu_to_le64(0x169119629891ad13ULL + offset));
((le64*)data)[0] ^= cpu_to_le64(0x169119629891ad13ULL + offset);
}
if (le32_eq(fek->alg_id, CALG_DESX)) {
if (fek->alg_id == CALG_DESX) {
int k;
fek->desx_ctx.prev_blk = 0;
@ -1462,7 +1452,7 @@ static int ntfs_feed_encrypt(ntfs_inode *inode, ntfs_fek *fek)
}
total = 0;
if (le16_andz(attr->data_flags, ATTR_IS_ENCRYPTED)) {
if (!(attr->data_flags & ATTR_IS_ENCRYPTED)) {
ntfs_log_error("The data stream was not encrypted\n");
goto rejected;
}

View File

@ -511,8 +511,8 @@ rstr_pass_loc:
* The $LogFile versions specified in each of the two restart
* page headers must match.
*/
if (!sle16_eq(rstr1->major_ver, rstr->major_ver) ||
!sle16_eq(rstr1->minor_ver, rstr->minor_ver))
if (rstr1->major_ver != rstr->major_ver ||
rstr1->minor_ver != rstr->minor_ver)
log_err_exit(buf, "Second restart area specifies "
"different $LogFile version to first "
"restart area. Cannot handle this "
@ -558,16 +558,16 @@ static void dump_log_record(LOG_RECORD *lr)
ntfs_log_info("transaction_id = 0x%x\n",
(unsigned int)le32_to_cpu(lr->transaction_id));
ntfs_log_info("flags = 0x%x:", le16_to_cpu(lr->log_record_flags));
if (le16_cmpz(lr->log_record_flags))
if (!lr->log_record_flags)
ntfs_log_info(" NONE\n");
else {
int _b = 0;
if (!le16_andz(lr->log_record_flags, LOG_RECORD_MULTI_PAGE)) {
if (lr->log_record_flags & LOG_RECORD_MULTI_PAGE) {
ntfs_log_info(" LOG_RECORD_MULTI_PAGE");
_b = 1;
}
if (!le16_andz(lr->log_record_flags, le16_not(LOG_RECORD_MULTI_PAGE))) {
if (lr->log_record_flags & ~LOG_RECORD_MULTI_PAGE) {
if (_b)
ntfs_log_info(" |");
ntfs_log_info(" Unknown flags");

View File

@ -128,7 +128,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfs-3g (8),

View File

@ -550,10 +550,10 @@ static int ntfs_merge_allocation(ntfs_attr *na, runlist_element *rl,
err = ntfs_inner_zero(na, rl);
}
if (!err) {
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE)) {
if (na->data_flags & ATTR_IS_SPARSE) {
na->compressed_size += size;
if (na->compressed_size >= na->allocated_size) {
na->data_flags = le16_and(na->data_flags, le16_not(ATTR_IS_SPARSE));
na->data_flags &= ~ATTR_IS_SPARSE;
if (na->compressed_size > na->allocated_size) {
ntfs_log_error("File size error : "
"apparent %lld, "
@ -714,17 +714,17 @@ static int ntfs_full_allocation(ntfs_attr *na, ntfs_attr_search_ctx *ctx,
= cpu_to_sle64(na->initialized_size);
attr->allocated_size
= cpu_to_sle64(na->allocated_size);
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE))
if (na->data_flags & ATTR_IS_SPARSE)
attr->compressed_size
= cpu_to_sle64(na->compressed_size);
/* Copy the unnamed data attribute sizes to inode */
if (le32_eq(attr_type, AT_DATA) && !attr_name_len) {
if ((attr_type == AT_DATA) && !attr_name_len) {
ni = na->ni;
ni->data_size = na->data_size;
if (!le16_andz(na->data_flags, ATTR_IS_SPARSE)) {
if (na->data_flags & ATTR_IS_SPARSE) {
ni->allocated_size
= na->compressed_size;
ni->flags = le32_or(ni->flags, FILE_ATTR_SPARSE_FILE);
ni->flags |= FILE_ATTR_SPARSE_FILE;
} else
ni->allocated_size
= na->allocated_size;
@ -759,7 +759,7 @@ static int ntfs_fallocate(ntfs_inode *ni, s64 alloc_offs, s64 alloc_len)
err = -1;
} else {
errmess = (const char*)NULL;
if (!le16_andz(na->data_flags, ATTR_IS_COMPRESSED)) {
if (na->data_flags & ATTR_IS_COMPRESSED) {
errmess= "Cannot fallocate a compressed file";
}
@ -859,7 +859,7 @@ int main(int argc, char **argv)
err_exit(vol, "Failed to mount %s: %s\n", dev_name,
strerror(errno));
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY) && !opts.force)
if ((vol->flags & VOLUME_IS_DIRTY) && !opts.force)
err_exit(vol, "Volume is dirty, please run chkdsk.\n");
if (ntfs_volume_get_free_space(vol))

View File

@ -75,7 +75,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR mkntfs (8),

View File

@ -236,7 +236,7 @@ static int OLD_ntfs_volume_set_flags(ntfs_volume *vol, const le16 flags)
return -1;
}
/* Sanity check */
if (le16_andz(m->flags, MFT_RECORD_IN_USE)) {
if (!(m->flags & MFT_RECORD_IN_USE)) {
ntfs_log_error("$Volume has been deleted. Cannot handle this "
"yet. Run chkdsk to fix this.\n");
errno = EIO;
@ -298,14 +298,14 @@ static int set_dirty_flag(ntfs_volume *vol)
/* Porting note: We test for the current state of VOLUME_IS_DIRTY. This
* should actually be more appropriate than testing for NVolWasDirty. */
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY))
if (vol->flags & VOLUME_IS_DIRTY)
return 0;
ntfs_log_info("Setting required flags on partition... ");
/*
* Set chkdsk flag, i.e. mark the partition dirty so chkdsk will run
* and fix it for us.
*/
flags = le16_or(vol->flags, VOLUME_IS_DIRTY);
flags = vol->flags | VOLUME_IS_DIRTY;
if (!opt.no_action && OLD_ntfs_volume_set_flags(vol, flags)) {
ntfs_log_info(FAILED);
ntfs_log_error("Error setting volume flags.\n");
@ -355,7 +355,7 @@ static int clear_sparse(ntfs_attr *na, const char *name)
if (ctx) {
if (!ntfs_attr_lookup(na->type, na->name, na->name_len,
CASE_SENSITIVE, 0, NULL, 0, ctx)) {
na->data_flags = le16_and(na->data_flags, le16_not(ATTR_IS_SPARSE));
na->data_flags &= ~ATTR_IS_SPARSE;
ctx->attr->data_size = cpu_to_sle64(na->data_size);
ctx->attr->initialized_size
= cpu_to_sle64(na->initialized_size);
@ -427,7 +427,7 @@ static int clear_badclus(ntfs_volume *vol)
* formatting, so do the same.
*/
if (ok) {
ni->flags = le32_and(ni->flags, le32_not(FILE_ATTR_SPARSE_FILE));
ni->flags &= ~FILE_ATTR_SPARSE_FILE;
ok = !clear_sparse(na, "$BadClus::$Bad");
}
ntfs_attr_close(na);
@ -528,7 +528,7 @@ static int fix_mftmirr(ntfs_volume *vol)
use_mirr = FALSE;
mrec = (MFT_RECORD*)(m + i * vol->mft_record_size);
if (!le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
if (mrec->flags & MFT_RECORD_IN_USE) {
if (ntfs_is_baad_record(mrec->magic)) {
ntfs_log_info(FAILED);
ntfs_log_error("$MFT error: Incomplete multi "
@ -546,7 +546,7 @@ static int fix_mftmirr(ntfs_volume *vol)
}
}
mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size);
if (!le16_andz(mrec2->flags, MFT_RECORD_IN_USE)) {
if (mrec2->flags & MFT_RECORD_IN_USE) {
if (ntfs_is_baad_record(mrec2->magic)) {
ntfs_log_info(FAILED);
ntfs_log_error("$MFTMirr error: Incomplete "
@ -561,7 +561,7 @@ static int fix_mftmirr(ntfs_volume *vol)
goto error_exit;
}
/* $MFT is corrupt but $MFTMirr is ok, use $MFTMirr. */
if (le16_andz(mrec->flags, MFT_RECORD_IN_USE) &&
if (!(mrec->flags & MFT_RECORD_IN_USE) &&
!ntfs_is_mft_record(mrec->magic))
use_mirr = TRUE;
}
@ -787,16 +787,16 @@ static ATTR_RECORD *find_unnamed_attr(MFT_RECORD *mrec, ATTR_TYPES type)
space = le32_to_cpu(mrec->bytes_in_use) - offset;
a = (ATTR_RECORD*)((char*)mrec + offset);
while ((space >= (s32)offsetof(ATTR_RECORD, resident_end))
&& !le32_eq(a->type, AT_END)
&& (a->type != AT_END)
&& (le32_to_cpu(a->length) <= (u32)space)
&& !(le32_to_cpu(a->length) & 7)
&& (!le32_eq(a->type, type) || a->name_length)) {
&& ((a->type != type) || a->name_length)) {
offset += le32_to_cpu(a->length);
space -= le32_to_cpu(a->length);
a = (ATTR_RECORD*)((char*)mrec + offset);
}
if ((offset >= le32_to_cpu(mrec->bytes_in_use))
|| !le32_eq(a->type, type)
|| (a->type != type)
|| a->name_length)
a = (ATTR_RECORD*)NULL;
return (a);
@ -912,18 +912,18 @@ static BOOL attrlist_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
>> vol->cluster_size_bits;
levcn = cpu_to_sle64(vcn);
while ((length > 0)
&& !le16_cmpz(al->length)
&& (!le32_eq(al->type, AT_DATA)
|| !sle64_eq(al->lowest_vcn, levcn))) {
&& al->length
&& ((al->type != AT_DATA)
|| ((leVCN)al->lowest_vcn != levcn))) {
length -= le16_to_cpu(al->length);
al = (ATTR_LIST_ENTRY*)
((char*)al + le16_to_cpu(al->length));
}
if ((length > 0)
&& !le16_cmpz(al->length)
&& le32_eq(al->type, AT_DATA)
&& al->length
&& (al->type == AT_DATA)
&& !al->name_length
&& sle64_eq(al->lowest_vcn, levcn)
&& ((leVCN)al->lowest_vcn == levcn)
&& (MREF_LE(al->mft_reference) >= SELFLOC_LIMIT)) {
selfloc->mft_ref1
= le64_to_cpu(al->mft_reference);
@ -974,7 +974,7 @@ static BOOL self_mapped_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
>> vol->cluster_size_bits;
a = find_unnamed_attr(mft1,AT_DATA);
if (a
&& !le16_andz(mft1->flags, MFT_RECORD_IN_USE)
&& (mft1->flags & MFT_RECORD_IN_USE)
&& ((VCN)sle64_to_cpu(a->lowest_vcn) == lowest_vcn)
&& (le64_to_cpu(mft1->base_mft_record)
== selfloc->mft_ref0)
@ -1027,8 +1027,8 @@ static BOOL spare_record_selfloc_condition(struct MFT_SELF_LOCATED *selfloc)
&& !ntfs_mst_post_read_fixup((NTFS_RECORD*)mft2,
vol->mft_record_size)
&& !ntfs_mft_record_check(vol, inum, mft2)) {
if (le64_cmpz(mft2->base_mft_record)
&& !le16_andz(mft2->flags, MFT_RECORD_IN_USE)
if (!mft2->base_mft_record
&& (mft2->flags & MFT_RECORD_IN_USE)
&& !find_unnamed_attr(mft2,AT_ATTRIBUTE_LIST)
&& !find_unnamed_attr(mft2,AT_FILE_NAME)) {
ok = TRUE;
@ -1670,9 +1670,9 @@ int main(int argc, char **argv)
* mounting was successful.
*/
if (opt.clear_dirty)
vol->flags = le16_and(vol->flags, le16_not(VOLUME_IS_DIRTY));
vol->flags &= ~VOLUME_IS_DIRTY;
else
vol->flags = le16_or(vol->flags, VOLUME_IS_DIRTY);
vol->flags |= VOLUME_IS_DIRTY;
if (!opt.no_action && ntfs_volume_write_flags(vol, vol->flags)) {
ntfs_log_error("Error: Failed to set volume dirty flag (%d "
"(%s))!\n", errno, strerror(errno));

View File

@ -83,7 +83,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfsprogs (8)

View File

@ -413,51 +413,51 @@ static const char *reparse_type_name(le32 tag)
const char *name;
le32 seltag;
seltag = le32_and(tag, IO_REPARSE_PLUGIN_SELECT);
do {
if (le32_eq(seltag, IO_REPARSE_TAG_MOUNT_POINT)) {
seltag = tag & IO_REPARSE_PLUGIN_SELECT;
switch (seltag) {
case IO_REPARSE_TAG_MOUNT_POINT :
name = " (mount point)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_SYMLINK)) {
case IO_REPARSE_TAG_SYMLINK :
name = " (symlink)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_WOF)) {
case IO_REPARSE_TAG_WOF :
name = " (Wof compressed)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_DEDUP)) {
case IO_REPARSE_TAG_DEDUP :
name = " (deduplicated)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_WCI)) {
case IO_REPARSE_TAG_WCI :
name = " (Windows container)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_CLOUD)) {
case IO_REPARSE_TAG_CLOUD :
name = " (Cloud)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_NFS)) {
case IO_REPARSE_TAG_NFS :
name = " (NFS symlink)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_LX_SYMLINK)) {
case IO_REPARSE_TAG_LX_SYMLINK :
name = " (Linux symlink)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_LX_FIFO)) {
case IO_REPARSE_TAG_LX_FIFO :
name = " (Linux fifo)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_LX_CHR)) {
case IO_REPARSE_TAG_LX_CHR :
name = " (Linux character device)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_LX_BLK)) {
case IO_REPARSE_TAG_LX_BLK :
name = " (Linux block device)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_AF_UNIX)) {
case IO_REPARSE_TAG_AF_UNIX :
name = " (Unix socket)";
break;
} else if (le32_eq(seltag, IO_REPARSE_TAG_APPEXECLINK)) {
case IO_REPARSE_TAG_APPEXECLINK :
name = " (Exec link)";
break;
} else {
default :
name = "";
break;
} } while(0);
}
return (name);
}
@ -473,9 +473,9 @@ static void ntfs_dump_volume(ntfs_volume *vol)
printf("\tVolume Name: %s\n", vol->vol_name);
printf("\tVolume State: %lu\n", vol->state);
printf("\tVolume Flags: 0x%04x", (int)le16_to_cpu(vol->flags));
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY))
if (vol->flags & VOLUME_IS_DIRTY)
printf(" DIRTY");
if (!le16_andz(vol->flags, VOLUME_MODIFIED_BY_CHKDSK))
if (vol->flags & VOLUME_MODIFIED_BY_CHKDSK)
printf(" MODIFIED_BY_CHKDSK");
printf("\n");
printf("\tVolume Version: %u.%u\n", vol->major_ver, vol->minor_ver);
@ -566,79 +566,79 @@ static void ntfs_dump_flags(const char *indent, ATTR_TYPES type, le32 flags)
const le32 original_flags = flags;
printf("%sFile attributes:\t", indent);
if (!le32_andz(flags, FILE_ATTR_READONLY)) {
if (flags & FILE_ATTR_READONLY) {
printf(" READONLY");
flags = le32_and(flags, le32_not(FILE_ATTR_READONLY));
flags &= ~FILE_ATTR_READONLY;
}
if (!le32_andz(flags, FILE_ATTR_HIDDEN)) {
if (flags & FILE_ATTR_HIDDEN) {
printf(" HIDDEN");
flags = le32_and(flags, le32_not(FILE_ATTR_HIDDEN));
flags &= ~FILE_ATTR_HIDDEN;
}
if (!le32_andz(flags, FILE_ATTR_SYSTEM)) {
if (flags & FILE_ATTR_SYSTEM) {
printf(" SYSTEM");
flags = le32_and(flags, le32_not(FILE_ATTR_SYSTEM));
flags &= ~FILE_ATTR_SYSTEM;
}
if (!le32_andz(flags, FILE_ATTR_DIRECTORY)) {
if (flags & FILE_ATTR_DIRECTORY) {
printf(" DIRECTORY");
flags = le32_and(flags, le32_not(FILE_ATTR_DIRECTORY));
flags &= ~FILE_ATTR_DIRECTORY;
}
if (!le32_andz(flags, FILE_ATTR_ARCHIVE)) {
if (flags & FILE_ATTR_ARCHIVE) {
printf(" ARCHIVE");
flags = le32_and(flags, le32_not(FILE_ATTR_ARCHIVE));
flags &= ~FILE_ATTR_ARCHIVE;
}
if (!le32_andz(flags, FILE_ATTR_DEVICE)) {
if (flags & FILE_ATTR_DEVICE) {
printf(" DEVICE");
flags = le32_and(flags, le32_not(FILE_ATTR_DEVICE));
flags &= ~FILE_ATTR_DEVICE;
}
if (!le32_andz(flags, FILE_ATTR_NORMAL)) {
if (flags & FILE_ATTR_NORMAL) {
printf(" NORMAL");
flags = le32_and(flags, le32_not(FILE_ATTR_NORMAL));
flags &= ~FILE_ATTR_NORMAL;
}
if (!le32_andz(flags, FILE_ATTR_TEMPORARY)) {
if (flags & FILE_ATTR_TEMPORARY) {
printf(" TEMPORARY");
flags = le32_and(flags, le32_not(FILE_ATTR_TEMPORARY));
flags &= ~FILE_ATTR_TEMPORARY;
}
if (!le32_andz(flags, FILE_ATTR_SPARSE_FILE)) {
if (flags & FILE_ATTR_SPARSE_FILE) {
printf(" SPARSE_FILE");
flags = le32_and(flags, le32_not(FILE_ATTR_SPARSE_FILE));
flags &= ~FILE_ATTR_SPARSE_FILE;
}
if (!le32_andz(flags, FILE_ATTR_REPARSE_POINT)) {
if (flags & FILE_ATTR_REPARSE_POINT) {
printf(" REPARSE_POINT");
flags = le32_and(flags, le32_not(FILE_ATTR_REPARSE_POINT));
flags &= ~FILE_ATTR_REPARSE_POINT;
}
if (!le32_andz(flags, FILE_ATTR_COMPRESSED)) {
if (flags & FILE_ATTR_COMPRESSED) {
printf(" COMPRESSED");
flags = le32_and(flags, le32_not(FILE_ATTR_COMPRESSED));
flags &= ~FILE_ATTR_COMPRESSED;
}
if (!le32_andz(flags, FILE_ATTR_OFFLINE)) {
if (flags & FILE_ATTR_OFFLINE) {
printf(" OFFLINE");
flags = le32_and(flags, le32_not(FILE_ATTR_OFFLINE));
flags &= ~FILE_ATTR_OFFLINE;
}
if (!le32_andz(flags, FILE_ATTR_NOT_CONTENT_INDEXED)) {
if (flags & FILE_ATTR_NOT_CONTENT_INDEXED) {
printf(" NOT_CONTENT_INDEXED");
flags = le32_and(flags, le32_not(FILE_ATTR_NOT_CONTENT_INDEXED));
flags &= ~FILE_ATTR_NOT_CONTENT_INDEXED;
}
if (!le32_andz(flags, FILE_ATTR_ENCRYPTED)) {
if (flags & FILE_ATTR_ENCRYPTED) {
printf(" ENCRYPTED");
flags = le32_and(flags, le32_not(FILE_ATTR_ENCRYPTED));
flags &= ~FILE_ATTR_ENCRYPTED;
}
/* We know that FILE_ATTR_I30_INDEX_PRESENT only exists on $FILE_NAME,
and in case we are wrong, let it appear as UNKNOWN */
if (le32_eq(type, AT_FILE_NAME)) {
if (!le32_andz(flags, FILE_ATTR_I30_INDEX_PRESENT)) {
if (type == AT_FILE_NAME) {
if (flags & FILE_ATTR_I30_INDEX_PRESENT) {
printf(" I30_INDEX");
flags = le32_and(flags, le32_not(FILE_ATTR_I30_INDEX_PRESENT));
flags &= ~FILE_ATTR_I30_INDEX_PRESENT;
}
}
if (!le32_andz(flags, FILE_ATTR_VIEW_INDEX_PRESENT)) {
if (flags & FILE_ATTR_VIEW_INDEX_PRESENT) {
printf(" VIEW_INDEX");
flags = le32_and(flags, le32_not(FILE_ATTR_VIEW_INDEX_PRESENT));
flags &= ~FILE_ATTR_VIEW_INDEX_PRESENT;
}
if (!le32_andz(flags, FILE_ATTRIBUTE_RECALL_ON_OPEN)) {
if (flags & FILE_ATTRIBUTE_RECALL_ON_OPEN) {
printf(" RECALL_ON_OPEN");
flags = le32_and(flags, le32_not(FILE_ATTRIBUTE_RECALL_ON_OPEN));
flags &= ~FILE_ATTRIBUTE_RECALL_ON_OPEN;
}
if (!le32_cmpz(flags))
if (flags)
printf(" UNKNOWN: 0x%08x", (unsigned int)le32_to_cpu(flags));
/* Print all the flags in hex. */
printf(" (0x%08x)\n", (unsigned)le32_to_cpu(original_flags));
@ -870,18 +870,18 @@ static void ntfs_dump_filename(const char *indent,
(unsigned)file_name_attr->file_name_length,
(unsigned)file_name_attr->file_name_length);
ntfs_dump_flags(indent, AT_FILE_NAME, file_name_attr->file_attributes);
if (!le32_andz(file_name_attr->file_attributes, FILE_ATTR_REPARSE_POINT) &&
!le32_cmpz(file_name_attr->reparse_point_tag)) {
if (file_name_attr->file_attributes & FILE_ATTR_REPARSE_POINT &&
file_name_attr->reparse_point_tag) {
tag = file_name_attr->reparse_point_tag;
printf("%sReparse point tag:\t 0x%08lx%s\n", indent,
(long)le32_to_cpu(tag),
reparse_type_name(tag));
} else if (!le32_cmpz(file_name_attr->reparse_point_tag)) {
} else if (file_name_attr->reparse_point_tag) {
printf("%sEA Length:\t\t %d (0x%x)\n", indent, (unsigned)
le16_to_cpu(file_name_attr->packed_ea_size),
(unsigned)
le16_to_cpu(file_name_attr->packed_ea_size));
if (!le16_cmpz(file_name_attr->reserved))
if (file_name_attr->reserved)
printf("%sReserved:\t\t %d (0x%x)\n", indent,
(unsigned)
le16_to_cpu(file_name_attr->reserved),
@ -1043,7 +1043,7 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc,
printf("%s\tControl:\t\t 0x%04x\n", indent,
le16_to_cpu(sec_desc->control));
if (!le16_andz(le16_not(sec_desc->control), SE_SELF_RELATIVE)) {
if (~sec_desc->control & SE_SELF_RELATIVE) {
SECURITY_DESCRIPTOR *sd = (SECURITY_DESCRIPTOR *)sec_desc;
printf("%s\tOwner SID pointer:\t %p\n", indent, sd->owner);
@ -1054,7 +1054,7 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc,
return;
}
if (!le32_cmpz(sec_desc->owner)) {
if (sec_desc->owner) {
sid = ntfs_sid_to_mbs((SID *)((char *)sec_desc +
le32_to_cpu(sec_desc->owner)), NULL, 0);
printf("%s\tOwner SID:\t\t %s\n", indent, sid);
@ -1062,7 +1062,7 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc,
} else
printf("%s\tOwner SID:\t\t missing\n", indent);
if (!le32_cmpz(sec_desc->group)) {
if (sec_desc->group) {
sid = ntfs_sid_to_mbs((SID *)((char *)sec_desc +
le32_to_cpu(sec_desc->group)), NULL, 0);
printf("%s\tGroup SID:\t\t %s\n", indent, sid);
@ -1071,8 +1071,8 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc,
printf("%s\tGroup SID:\t\t missing\n", indent);
printf("%s\tSystem ACL:\t\t ", indent);
if (!le16_andz(sec_desc->control, SE_SACL_PRESENT)) {
if (!le16_andz(sec_desc->control, SE_SACL_DEFAULTED)) {
if (sec_desc->control & SE_SACL_PRESENT) {
if (sec_desc->control & SE_SACL_DEFAULTED) {
printf("defaulted");
}
printf("\n");
@ -1084,8 +1084,8 @@ static void ntfs_dump_security_descriptor(SECURITY_DESCRIPTOR_ATTR *sec_desc,
}
printf("%s\tDiscretionary ACL:\t ", indent);
if (!le16_andz(sec_desc->control, SE_DACL_PRESENT)) {
if (!le16_andz(sec_desc->control, SE_SACL_DEFAULTED)) {
if (sec_desc->control & SE_DACL_PRESENT) {
if (sec_desc->control & SE_SACL_DEFAULTED) {
printf("defaulted");
}
printf("\n");
@ -1191,31 +1191,31 @@ static void ntfs_dump_attr_volume_information(ATTR_RECORD *attr)
printf("\tVolume Version:\t\t %d.%d\n", vol_information->major_ver,
vol_information->minor_ver);
printf("\tVolume Flags:\t\t ");
if (!le16_andz(vol_information->flags, VOLUME_IS_DIRTY))
if (vol_information->flags & VOLUME_IS_DIRTY)
printf("DIRTY ");
if (!le16_andz(vol_information->flags, VOLUME_RESIZE_LOG_FILE))
if (vol_information->flags & VOLUME_RESIZE_LOG_FILE)
printf("RESIZE_LOG ");
if (!le16_andz(vol_information->flags, VOLUME_UPGRADE_ON_MOUNT))
if (vol_information->flags & VOLUME_UPGRADE_ON_MOUNT)
printf("UPG_ON_MOUNT ");
if (!le16_andz(vol_information->flags, VOLUME_MOUNTED_ON_NT4))
if (vol_information->flags & VOLUME_MOUNTED_ON_NT4)
printf("MOUNTED_NT4 ");
if (!le16_andz(vol_information->flags, VOLUME_DELETE_USN_UNDERWAY))
if (vol_information->flags & VOLUME_DELETE_USN_UNDERWAY)
printf("DEL_USN ");
if (!le16_andz(vol_information->flags, VOLUME_REPAIR_OBJECT_ID))
if (vol_information->flags & VOLUME_REPAIR_OBJECT_ID)
printf("REPAIR_OBJID ");
if (!le16_andz(vol_information->flags, VOLUME_CHKDSK_UNDERWAY))
if (vol_information->flags & VOLUME_CHKDSK_UNDERWAY)
printf("CHKDSK_UNDERWAY ");
if (!le16_andz(vol_information->flags, VOLUME_MODIFIED_BY_CHKDSK))
if (vol_information->flags & VOLUME_MODIFIED_BY_CHKDSK)
printf("MOD_BY_CHKDSK ");
if (!le16_andz(vol_information->flags, VOLUME_FLAGS_MASK)) {
if (vol_information->flags & VOLUME_FLAGS_MASK) {
printf("(0x%04x)\n",
(unsigned)le16_to_cpu(vol_information->flags));
} else
printf("none set (0x0000)\n");
if (!le16_andz(vol_information->flags, le16_not(VOLUME_FLAGS_MASK)))
if (vol_information->flags & (~VOLUME_FLAGS_MASK))
printf("\t\t\t\t Unknown Flags: 0x%04x\n",
le16_to_cpu(le16_and(vol_information->flags,
le16_not(VOLUME_FLAGS_MASK))));
le16_to_cpu(vol_information->flags &
(~VOLUME_FLAGS_MASK)));
}
static ntfschar NTFS_DATA_SDS[5] = { const_cpu_to_le16('$'),
@ -1277,7 +1277,7 @@ static void ntfs_dump_sds(ATTR_RECORD *attr, ntfs_inode *ni)
* FIXME: The right way is based on the indexes, so we couldn't
* miss real entries. For now, dump until it makes sense.
*/
while (!le32_cmpz(sd->length) && !le32_cmpz(sd->hash) &&
while (sd->length && sd->hash &&
le64_to_cpu(sd->offset) < (u64)data_size &&
le32_to_cpu(sd->length) < (u64)data_size &&
le64_to_cpu(sd->offset) +
@ -1291,25 +1291,25 @@ static void ntfs_dump_sds(ATTR_RECORD *attr, ntfs_inode *ni)
static const char *get_attribute_type_name(le32 type)
{
/* switch(type) */ {
if (le32_eq(type, AT_UNUSED)) return "$UNUSED";
else if (le32_eq(type, AT_STANDARD_INFORMATION)) return "$STANDARD_INFORMATION";
else if (le32_eq(type, AT_ATTRIBUTE_LIST)) return "$ATTRIBUTE_LIST";
else if (le32_eq(type, AT_FILE_NAME)) return "$FILE_NAME";
else if (le32_eq(type, AT_OBJECT_ID)) return "$OBJECT_ID";
else if (le32_eq(type, AT_SECURITY_DESCRIPTOR)) return "$SECURITY_DESCRIPTOR";
else if (le32_eq(type, AT_VOLUME_NAME)) return "$VOLUME_NAME";
else if (le32_eq(type, AT_VOLUME_INFORMATION)) return "$VOLUME_INFORMATION";
else if (le32_eq(type, AT_DATA)) return "$DATA";
else if (le32_eq(type, AT_INDEX_ROOT)) return "$INDEX_ROOT";
else if (le32_eq(type, AT_INDEX_ALLOCATION)) return "$INDEX_ALLOCATION";
else if (le32_eq(type, AT_BITMAP)) return "$BITMAP";
else if (le32_eq(type, AT_REPARSE_POINT)) return "$REPARSE_POINT";
else if (le32_eq(type, AT_EA_INFORMATION)) return "$EA_INFORMATION";
else if (le32_eq(type, AT_EA)) return "$EA";
else if (le32_eq(type, AT_PROPERTY_SET)) return "$PROPERTY_SET";
else if (le32_eq(type, AT_LOGGED_UTILITY_STREAM)) return "$LOGGED_UTILITY_STREAM";
else if (le32_eq(type, AT_END)) return "$END";
switch (type) {
case AT_UNUSED: return "$UNUSED";
case AT_STANDARD_INFORMATION: return "$STANDARD_INFORMATION";
case AT_ATTRIBUTE_LIST: return "$ATTRIBUTE_LIST";
case AT_FILE_NAME: return "$FILE_NAME";
case AT_OBJECT_ID: return "$OBJECT_ID";
case AT_SECURITY_DESCRIPTOR: return "$SECURITY_DESCRIPTOR";
case AT_VOLUME_NAME: return "$VOLUME_NAME";
case AT_VOLUME_INFORMATION: return "$VOLUME_INFORMATION";
case AT_DATA: return "$DATA";
case AT_INDEX_ROOT: return "$INDEX_ROOT";
case AT_INDEX_ALLOCATION: return "$INDEX_ALLOCATION";
case AT_BITMAP: return "$BITMAP";
case AT_REPARSE_POINT: return "$REPARSE_POINT";
case AT_EA_INFORMATION: return "$EA_INFORMATION";
case AT_EA: return "$EA";
case AT_PROPERTY_SET: return "$PROPERTY_SET";
case AT_LOGGED_UTILITY_STREAM: return "$LOGGED_UTILITY_STREAM";
case AT_END: return "$END";
}
return "$UNKNOWN";
@ -1406,7 +1406,7 @@ static void ntfs_dump_attribute_header(ntfs_attr_search_ctx *ctx,
(unsigned)a->compression_unit);
/* TODO: dump the 5 reserved bytes here in verbose mode */
if (sle64_cmpz(a->lowest_vcn)) {
if (!a->lowest_vcn) {
printf("\tData size:\t\t %llu (0x%llx)\n",
(long long)sle64_to_cpu(a->data_size),
(unsigned long long)sle64_to_cpu(a->data_size));
@ -1418,8 +1418,8 @@ static void ntfs_dump_attribute_header(ntfs_attr_search_ctx *ctx,
(long long)sle64_to_cpu(a->initialized_size),
(unsigned long long)
sle64_to_cpu(a->initialized_size));
if (a->compression_unit || !le16_andz(a->flags, ATTR_IS_COMPRESSED) ||
!le16_andz(a->flags, ATTR_IS_SPARSE))
if (a->compression_unit || a->flags & ATTR_IS_COMPRESSED ||
a->flags & ATTR_IS_SPARSE)
printf("\tCompressed size:\t %llu (0x%llx)\n",
(signed long long)
sle64_to_cpu(a->compressed_size),
@ -1677,7 +1677,7 @@ static int ntfs_dump_index_entries(INDEX_ENTRY *entry, INDEX_ATTR_TYPE type)
int numb_entries = 1;
while (1) {
if (!opts.verbose) {
if (!le16_andz(entry->ie_flags, INDEX_ENTRY_END))
if (entry->ie_flags & INDEX_ENTRY_END)
break;
entry = (INDEX_ENTRY *)((u8 *)entry +
le16_to_cpu(entry->length));
@ -1693,11 +1693,11 @@ static int ntfs_dump_index_entries(INDEX_ENTRY *entry, INDEX_ATTR_TYPE type)
ntfs_log_verbose("\t\tIndex entry flags:\t 0x%02x\n",
(unsigned)le16_to_cpu(entry->ie_flags));
if (!le16_andz(entry->ie_flags, INDEX_ENTRY_NODE))
if (entry->ie_flags & INDEX_ENTRY_NODE)
ntfs_log_verbose("\t\tSubnode VCN:\t\t %lld (0x%llx)\n",
(long long)ntfs_ie_get_vcn(entry),
(long long)ntfs_ie_get_vcn(entry));
if (!le16_andz(entry->ie_flags, INDEX_ENTRY_END))
if (entry->ie_flags & INDEX_ENTRY_END)
break;
switch (type) {
@ -1725,7 +1725,7 @@ static int ntfs_dump_index_entries(INDEX_ENTRY *entry, INDEX_ATTR_TYPE type)
ntfs_dump_index_data(entry, type);
break;
}
if (le16_cmpz(entry->length)) {
if (!entry->length) {
ntfs_log_verbose("\tWARNING: Corrupt index entry, "
"skipping the remainder of this index "
"block.\n");
@ -1752,8 +1752,8 @@ static INDEX_ATTR_TYPE get_index_attr_type(ntfs_inode *ni, ATTR_RECORD *attr,
if (!attr->name_length)
return INDEX_ATTR_UNKNOWN;
if (!le32_cmpz(index_root->type)) {
if (le32_eq(index_root->type, AT_FILE_NAME))
if (index_root->type) {
if (index_root->type == AT_FILE_NAME)
return INDEX_ATTR_DIRECTORY_I30;
else
/* weird, this should be illegal */
@ -2166,7 +2166,7 @@ static void ntfs_dump_attr_ea(ATTR_RECORD *attr, ntfs_volume *vol)
else
printf("\n");
}
if (!le32_cmpz(ea->next_entry_offset)) {
if (ea->next_entry_offset) {
offset += le32_to_cpu(ea->next_entry_offset);
ea = (const EA_ATTR*)((const u8*)ea
+ le32_to_cpu(ea->next_entry_offset));
@ -2291,25 +2291,25 @@ static void ntfs_dump_inode_general_info(ntfs_inode *inode)
(unsigned)le16_to_cpu(mrec->attrs_offset));
printf("MFT Record Flags:\t ");
if (!le16_cmpz(inode_flags)) {
if (!le16_andz(MFT_RECORD_IN_USE, inode_flags)) {
if (inode_flags) {
if (MFT_RECORD_IN_USE & inode_flags) {
printf("IN_USE ");
inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IN_USE));
inode_flags &= ~MFT_RECORD_IN_USE;
}
if (!le16_andz(MFT_RECORD_IS_DIRECTORY, inode_flags)) {
if (MFT_RECORD_IS_DIRECTORY & inode_flags) {
printf("DIRECTORY ");
inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IS_DIRECTORY));
inode_flags &= ~MFT_RECORD_IS_DIRECTORY;
}
/* The meaning of IS_4 is illusive but not its existence. */
if (!le16_andz(MFT_RECORD_IS_4, inode_flags)) {
if (MFT_RECORD_IS_4 & inode_flags) {
printf("IS_4 ");
inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IS_4));
inode_flags &= ~MFT_RECORD_IS_4;
}
if (!le16_andz(MFT_RECORD_IS_VIEW_INDEX, inode_flags)) {
if (MFT_RECORD_IS_VIEW_INDEX & inode_flags) {
printf("VIEW_INDEX ");
inode_flags = le16_and(inode_flags, le16_not(MFT_RECORD_IS_VIEW_INDEX));
inode_flags &= ~MFT_RECORD_IS_VIEW_INDEX;
}
if (!le16_cmpz(inode_flags))
if (inode_flags)
printf("UNKNOWN: 0x%04x", (unsigned)le16_to_cpu(
inode_flags));
} else {
@ -2324,7 +2324,7 @@ static void ntfs_dump_inode_general_info(ntfs_inode *inode)
(unsigned)le32_to_cpu(mrec->bytes_allocated),
(unsigned)le32_to_cpu(mrec->bytes_allocated));
if (!le64_cmpz(mrec->base_mft_record)) {
if (mrec->base_mft_record) {
printf("Base MFT Record:\t %llu (0x%llx)\n",
(unsigned long long)
MREF_LE(mrec->base_mft_record),
@ -2357,7 +2357,7 @@ static void ntfs_dump_file_attributes(ntfs_inode *inode)
ctx = ntfs_attr_get_search_ctx(inode, NULL);
while (!ntfs_attr_lookup(AT_UNUSED, NULL, 0, CASE_SENSITIVE,
0, NULL, 0, ctx)) {
if (le32_eq(ctx->attr->type, AT_END) || le32_eq(ctx->attr->type, AT_UNUSED)) {
if (ctx->attr->type == AT_END || ctx->attr->type == AT_UNUSED) {
printf("Weird: %s attribute type was found, please "
"report this.\n",
get_attribute_type_name(
@ -2367,57 +2367,57 @@ static void ntfs_dump_file_attributes(ntfs_inode *inode)
ntfs_dump_attribute_header(ctx, inode->vol, &runcount);
if (le32_eq(ctx->attr->type, AT_STANDARD_INFORMATION)) {
switch (ctx->attr->type) {
case AT_STANDARD_INFORMATION:
ntfs_dump_attr_standard_information(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_ATTRIBUTE_LIST)) {
break;
case AT_ATTRIBUTE_LIST:
ntfs_dump_attr_list(ctx->attr, inode->vol);
}
else if (le32_eq(ctx->attr->type, AT_FILE_NAME)) {
break;
case AT_FILE_NAME:
ntfs_dump_attr_file_name(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_OBJECT_ID)) {
break;
case AT_OBJECT_ID:
ntfs_dump_attr_object_id(ctx->attr, inode->vol);
}
else if (le32_eq(ctx->attr->type, AT_SECURITY_DESCRIPTOR)) {
break;
case AT_SECURITY_DESCRIPTOR:
ntfs_dump_attr_security_descriptor(ctx->attr,
inode->vol);
}
else if (le32_eq(ctx->attr->type, AT_VOLUME_NAME)) {
break;
case AT_VOLUME_NAME:
ntfs_dump_attr_volume_name(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_VOLUME_INFORMATION)) {
break;
case AT_VOLUME_INFORMATION:
ntfs_dump_attr_volume_information(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_DATA)) {
break;
case AT_DATA:
ntfs_dump_attr_data(ctx->attr, inode);
}
else if (le32_eq(ctx->attr->type, AT_INDEX_ROOT)) {
break;
case AT_INDEX_ROOT:
ntfs_dump_attr_index_root(ctx->attr, inode);
}
else if (le32_eq(ctx->attr->type, AT_INDEX_ALLOCATION)) {
break;
case AT_INDEX_ALLOCATION:
ntfs_dump_attr_index_allocation(ctx->attr, inode);
}
else if (le32_eq(ctx->attr->type, AT_BITMAP)) {
break;
case AT_BITMAP:
ntfs_dump_attr_bitmap(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_REPARSE_POINT)) {
break;
case AT_REPARSE_POINT:
ntfs_dump_attr_reparse_point(ctx->attr, inode);
}
else if (le32_eq(ctx->attr->type, AT_EA_INFORMATION)) {
break;
case AT_EA_INFORMATION:
ntfs_dump_attr_ea_information(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_EA)) {
break;
case AT_EA:
ntfs_dump_attr_ea(ctx->attr, inode->vol);
}
else if (le32_eq(ctx->attr->type, AT_PROPERTY_SET)) {
break;
case AT_PROPERTY_SET:
ntfs_dump_attr_property_set(ctx->attr);
}
else if (le32_eq(ctx->attr->type, AT_LOGGED_UTILITY_STREAM)) {
break;
case AT_LOGGED_UTILITY_STREAM:
ntfs_dump_attr_logged_utility_stream(ctx->attr, inode);
}
else {
break;
default:
ntfs_dump_attr_unknown(ctx->attr);
}
}

View File

@ -112,7 +112,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR mkntfs (8),

View File

@ -258,8 +258,8 @@ static int change_serial(ntfs_volume *vol, u64 sector, le64 serial_number,
else {
mask = const_cpu_to_le64(~0x0ffffffffULL);
bs->volume_serial_number
= le64_or(le64_and(serial_number, mask),
le64_and(bs->volume_serial_number, le64_not(mask)));
= (serial_number & mask)
| (bs->volume_serial_number & ~mask);
}
if (opts.noaction
|| (ntfs_pwrite(vol->dev,

View File

@ -166,7 +166,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfsprogs (8)

View File

@ -671,7 +671,7 @@ int main(int argc, char **argv)
pos = 0;
memset(&dirent, 0, sizeof(dirent));
dirent.vol = vol;
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
if (opts.recursive)
readdir_recursive(ni, &pos, &dirent);
else

View File

@ -236,11 +236,11 @@ static void dump_mft_record(MFT_RECORD *m)
u = le16_to_cpu(m->attrs_offset);
ntfs_log_info("First attribute offset = %u (0x%x)\n", u, u);
ntfs_log_info("Flags = %u: ", le16_to_cpu(m->flags));
if (!le16_andz(m->flags, MFT_RECORD_IN_USE))
if (m->flags & MFT_RECORD_IN_USE)
ntfs_log_info("MFT_RECORD_IN_USE");
else
ntfs_log_info("MFT_RECORD_NOT_IN_USE");
if (!le16_andz(m->flags, MFT_RECORD_IS_DIRECTORY))
if (m->flags & MFT_RECORD_IS_DIRECTORY)
ntfs_log_info(" | MFT_RECORD_IS_DIRECTORY");
ntfs_log_info("\n");
u = le32_to_cpu(m->bytes_in_use);
@ -256,7 +256,7 @@ static void dump_mft_record(MFT_RECORD *m)
a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
ntfs_log_info("-- Beginning dump of attributes within mft record. --\n");
while ((char*)a < (char*)m + le32_to_cpu(m->bytes_in_use)) {
if (le32_eq(a->type, AT_END))
if (a->type == AT_END)
break;
a = (ATTR_RECORD*)((char*)a + le32_to_cpu(a->length));
};

View File

@ -904,8 +904,8 @@ int main(int argc, char *argv[])
* This means that the dirty flag is possibly not set, but
* should be set. So we explicitly set it with a call to
* ntfs_volume_write_flags. */
if(le16_andz(vol->flags, VOLUME_IS_DIRTY) && ntfs_volume_write_flags(
vol, le16_or(vol->flags, VOLUME_IS_DIRTY))) {
if(!(vol->flags & VOLUME_IS_DIRTY) && ntfs_volume_write_flags(
vol, vol->flags | VOLUME_IS_DIRTY)) {
ntfs_log_error("Error: Failed to set volume dirty "
"flag (%d (%s))!\n", errno, strerror(errno));
}

View File

@ -74,7 +74,7 @@ are part of the
package which can be downloaded from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfs\-3g (8)

View File

@ -164,7 +164,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfs-3g (8),

View File

@ -480,7 +480,7 @@ void showname(const char *prefix, const char *name, int cnt)
printf("%s",prefix);
n = (const le16*)name;
for (i=0; (i<cnt) && !le16_cmpz(n[i]); i++) {
for (i=0; (i<cnt) && n[i]; i++) {
c = le16_to_cpu(n[i]);
if (c < 0x20)
printf(".");
@ -695,62 +695,62 @@ const char *mftattrname(ATTR_TYPES attr)
static char badattr[24];
const char *p;
/* switch (attr) { */
if (le32_eq(attr, AT_STANDARD_INFORMATION)) {
switch (attr) {
case AT_STANDARD_INFORMATION :
p = "Standard-Information";
}
else if (le32_eq(attr, AT_ATTRIBUTE_LIST)) {
break;
case AT_ATTRIBUTE_LIST :
p = "Attribute-List";
}
else if (le32_eq(attr, AT_FILE_NAME)) {
break;
case AT_FILE_NAME :
p = "Name";
}
else if (le32_eq(attr, AT_OBJECT_ID)) {
break;
case AT_OBJECT_ID :
p = "Volume-Version";
}
else if (le32_eq(attr, AT_SECURITY_DESCRIPTOR)) {
break;
case AT_SECURITY_DESCRIPTOR :
p = "Security-Descriptor";
}
else if (le32_eq(attr, AT_VOLUME_NAME)) {
break;
case AT_VOLUME_NAME :
p = "Volume-Name";
}
else if (le32_eq(attr, AT_VOLUME_INFORMATION)) {
break;
case AT_VOLUME_INFORMATION :
p = "Volume-Information";
}
else if (le32_eq(attr, AT_DATA)) {
break;
case AT_DATA :
p = "Data";
}
else if (le32_eq(attr, AT_INDEX_ROOT)) {
break;
case AT_INDEX_ROOT :
p = "Index-Root";
}
else if (le32_eq(attr, AT_INDEX_ALLOCATION)) {
break;
case AT_INDEX_ALLOCATION :
p = "Index-Allocation";
}
else if (le32_eq(attr, AT_BITMAP)) {
break;
case AT_BITMAP :
p = "Bitmap";
}
else if (le32_eq(attr, AT_REPARSE_POINT)) {
break;
case AT_REPARSE_POINT :
p = "Reparse-Point";
}
else if (le32_eq(attr, AT_EA_INFORMATION)) {
break;
case AT_EA_INFORMATION :
p = "EA-Information";
}
else if (le32_eq(attr, AT_EA)) {
break;
case AT_EA :
p = "EA";
}
else if (le32_eq(attr, AT_PROPERTY_SET)) {
break;
case AT_PROPERTY_SET :
p = "Property-Set";
}
else if (le32_eq(attr, AT_LOGGED_UTILITY_STREAM)) {
break;
case AT_LOGGED_UTILITY_STREAM :
p = "Logged-Utility-Stream";
}
else if (le32_eq(attr, AT_END)) {
break;
case AT_END :
p = "End";
}
else {
sprintf(badattr, "*0x%x-Unknown*", le32_to_cpu(attr));
break;
default :
sprintf(badattr,"*0x%x-Unknown*",attr);
p = badattr;
/* break; */
break;
}
return (p);
}
@ -758,7 +758,7 @@ const char *mftattrname(ATTR_TYPES attr)
static void showattribute(const char *prefix, const struct ATTR *pa)
{
if (pa) {
if (!le32_cmpz(pa->type)) {
if (pa->type) {
printf("%sattr 0x%x : inode %lld type %s",
prefix, pa->key, (long long)pa->inode,
mftattrname(pa->type));
@ -815,7 +815,7 @@ u32 get_undo_offset(const LOG_RECORD *logr)
{
u32 offset;
if (!le16_cmpz(logr->lcns_to_follow))
if (logr->lcns_to_follow)
offset = 0x30 + le16_to_cpu(logr->undo_offset);
else
offset = 0x28 + le16_to_cpu(logr->undo_offset);
@ -826,7 +826,7 @@ u32 get_redo_offset(const LOG_RECORD *logr)
{
u32 offset;
if (!le16_cmpz(logr->lcns_to_follow))
if (logr->lcns_to_follow)
offset = 0x30 + le16_to_cpu(logr->redo_offset);
else
offset = 0x28 + le16_to_cpu(logr->redo_offset);
@ -849,8 +849,8 @@ static BOOL likelyop(const LOG_RECORD *logr)
{
BOOL likely;
do {
if (le32_eq(logr->record_type, LOG_STANDARD)) { /* standard record */
switch (logr->record_type) {
case LOG_STANDARD : /* standard record */
/* Operations in range 0..LastAction-1, can be both null */
likely = ((unsigned int)le16_to_cpu(logr->redo_operation)
< LastAction)
@ -860,7 +860,7 @@ static BOOL likelyop(const LOG_RECORD *logr)
&& !(le16_to_cpu(logr->redo_offset) & 7)
&& !(le16_to_cpu(logr->undo_offset) & 7)
/* transaction id must not be null */
&& !le32_cmpz(logr->transaction_id)
&& logr->transaction_id
/* client data length aligned to 8 bytes */
&& !(le32_to_cpu(logr->client_data_length) & 7)
/* client data length less than 64K (131K ?) */
@ -872,10 +872,10 @@ static BOOL likelyop(const LOG_RECORD *logr)
&& (!le16_to_cpu(logr->undo_length)
|| ((unsigned int)le16_to_cpu(logr->undo_offset) >= 0x28));
/* undo data and redo data should be contiguous when both present */
if (likely && !le16_cmpz(logr->redo_length) && !le16_cmpz(logr->undo_length)) {
if (likely && logr->redo_length && logr->undo_length) {
/* undo and redo data may be the same when both present and same size */
if (le16_eq(logr->undo_offset, logr->redo_offset)) {
if (!le16_eq(logr->redo_length, logr->undo_length))
if (logr->undo_offset == logr->redo_offset) {
if (logr->redo_length != logr->undo_length)
likely = FALSE;
} else {
if (le16_to_cpu(logr->redo_offset)
@ -897,27 +897,27 @@ static BOOL likelyop(const LOG_RECORD *logr)
}
}
break;
} else if (le32_eq(logr->record_type, LOG_CHECKPOINT)) { /* check-point */
case LOG_CHECKPOINT : /* check-point */
/*
* undo and redo operations are null
* or CompensationlogRecord with no data
*/
likely = (le16_cmpz(logr->redo_operation)
|| (le16_eq(logr->redo_operation, const_cpu_to_le16(1))
&& le16_cmpz(logr->redo_length)))
&& (le16_cmpz(logr->undo_operation)
|| (le16_eq(logr->undo_operation, const_cpu_to_le16(1))
&& le16_cmpz(logr->undo_length)))
likely = (!logr->redo_operation
|| ((logr->redo_operation == const_cpu_to_le16(1))
&& !logr->redo_length))
&& (!logr->undo_operation
|| ((logr->undo_operation == const_cpu_to_le16(1))
&& !logr->undo_length))
/* transaction id must be null */
&& le32_cmpz(logr->transaction_id)
&& !logr->transaction_id
/* client_data_length is 0x68 or 0x70 (Vista and subsequent) */
&& ((le32_to_cpu(logr->client_data_length) == 0x68)
|| (le32_to_cpu(logr->client_data_length) == 0x70));
break;
} else {
default :
likely = FALSE;
break;
} } while(0);
}
return (likely);
}
@ -996,7 +996,7 @@ static u16 firstrecord(int skipped, const struct BUFFER *buf,
/* Minimal size is apparently 48 : offset of redo_operation */
if (k && ((blocksz - k) >= LOG_RECORD_HEAD_SZ)) {
logr = (const LOG_RECORD*)&prevdata[k];
if (le32_cmpz(logr->client_data_length)) {
if (!logr->client_data_length) {
/*
* Sometimes the end of record is free space.
* This apparently means reaching the end of
@ -1145,9 +1145,9 @@ static const struct BUFFER *findprevious(CONTEXT *ctx, const struct BUFFER *buf)
prevbuf = read_buffer(ctx, prevblk);
if (prevbuf) {
rph = &prevbuf->block.record;
prevmiddle = le32_andz(rph->flags,
const_cpu_to_le32(1))
|| le16_cmpz(rph->next_record_offset);
prevmiddle = !(rph->flags
& const_cpu_to_le32(1))
|| !rph->next_record_offset;
if (prevmiddle) {
savebuf = prevbuf;
skipped++;
@ -1221,7 +1221,7 @@ static int refresh_attributes(const struct ACTION_RECORD *firstaction)
case OpenNonResidentAttribute :
extra = get_extra_offset(logr)
- get_redo_offset(logr);
if (!le16_cmpz(logr->undo_length)) {
if (logr->undo_length) {
len = le32_to_cpu(logr->client_data_length)
+ LOG_RECORD_HEAD_SZ
- get_extra_offset(logr);
@ -1376,7 +1376,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
printf(" attrib 0x%lx (%s) at offset 0x%x\n",
(long)le32_to_cpu(mftattr),
mftattrname(mftattr), (int)base);
if (le32_eq(mftattr, AT_FILE_NAME)) {
if (mftattr == AT_FILE_NAME) {
showname(" name ",&buf[base + 90],
buf[base + 88] & 255);
inode = feedle64(buf, base + 24);
@ -1455,7 +1455,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
firstpos = 0x30 + (((mftrecsz/512 + 1)*2 - 1 ) | 7) + 1;
if (pa
&& !pa->inode
&& le32_eq(pa->type, const_cpu_to_le32(0x80))
&& (pa->type == const_cpu_to_le32(0x80))
&& !(offs & 3)
&& (le16_to_cpu(logr->record_offset) == firstpos)) {
printf(" set standard information, attr 0x%x\n",attr);
@ -1598,8 +1598,8 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
inode = feedle64(buf,16);
printf(" parent dir inode %lld\n",
(long long)MREF(le64_to_cpu(inode)));
if (!le32_andz(feedle32(buf,72),
const_cpu_to_le32(0x10000000)))
if (feedle32(buf,72)
& const_cpu_to_le32(0x10000000))
showname(" file (dir) ",
&buf[base + 82],
buf[base + 80] & 255);
@ -1648,7 +1648,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
showattribute(" ",pa);
if (pa
&& !pa->inode
&& le32_eq(pa->type, const_cpu_to_le32(0x80))
&& (pa->type == const_cpu_to_le32(0x80))
&& !(offs & 3)) {
if (base >= -24)
showdate(" created ",feedle64(buf,
@ -1679,7 +1679,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
}
} else {
/* Usually caused by attr not yet defined */
if (pa && !le32_cmpz(pa->type))
if (pa && pa->type)
printf("** Unexpected index parameters\n");
}
break;
@ -1735,7 +1735,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
extra = get_extra_offset(logr)
- (redo ? get_redo_offset(logr)
: get_undo_offset(logr));
if (!le16_cmpz(logr->undo_length)) {
if (logr->undo_length) {
len = le32_to_cpu(logr->client_data_length)
+ LOG_RECORD_HEAD_SZ
- get_extra_offset(logr);
@ -1761,7 +1761,7 @@ static void fixup(CONTEXT *ctx, const LOG_RECORD *logr, const char *buf,
printf(" inode %lld\n",
(long long)pa->inode);
}
if (!le16_cmpz(logr->undo_length))
if (logr->undo_length)
showname(" extra : attr name ", &buf[extra], len/2);
if (!redo && length) {
printf(" * undo attr not shown\n");
@ -1870,9 +1870,9 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
unsigned int listsize;
BOOL onmft;
do {
if (le32_eq(logr->record_type, LOG_STANDARD)) {
onmft = !le16_cmpz(logr->cluster_index)
switch (logr->record_type) {
case LOG_STANDARD :
onmft = logr->cluster_index
|| acts_on_mft(le16_to_cpu(logr->redo_operation))
|| acts_on_mft(le16_to_cpu(logr->undo_operation));
printf("redo_operation %04x %s\n",
@ -1949,7 +1949,7 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
* 4) extra : unknown data (end of undo to data_length)
*/
end = le32_to_cpu(logr->client_data_length) + LOG_RECORD_HEAD_SZ;
if (!le16_cmpz(logr->redo_length) && !le16_cmpz(logr->undo_length))
if (logr->redo_length && logr->undo_length)
{
/* both undo and redo are present */
if (le16_to_cpu(logr->undo_offset) <=
@ -1957,7 +1957,7 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
{
undo = sizeof(LOG_RECORD) - 8
+ 8*le16_to_cpu(logr->lcns_to_follow);
if (le16_eq(logr->redo_offset, logr->undo_offset))
if (logr->redo_offset == logr->undo_offset)
redo = undo;
else
redo = undo + ((le16_to_cpu(logr->undo_length) - 1) | 7) + 1;
@ -1972,7 +1972,7 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
}
}
else
if (!le16_cmpz(logr->redo_length))
if (logr->redo_length)
{
/* redo and not undo */
redo = undo = sizeof(LOG_RECORD) - 8
@ -1992,11 +1992,11 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
undo,(int)(((le16_to_cpu(logr->undo_length) - 1) | 7) + 1),
extra,(int)(end > extra ? end - extra : 0));
if (!le16_cmpz(logr->redo_length) && (get_redo_offset(logr) != redo))
if (logr->redo_length && (get_redo_offset(logr) != redo))
printf("** Unexpected redo offset 0x%x %u (%u)\n",
get_redo_offset(logr),(int)redo,
(int)le16_to_cpu(logr->lcns_to_follow));
if (!le16_cmpz(logr->undo_length) && (get_undo_offset(logr) != undo))
if (logr->undo_length && (get_undo_offset(logr) != undo))
printf("** Unexpected undo offset 0x%x %u (%u)\n",
get_undo_offset(logr),(int)undo,
(int)le16_to_cpu(logr->lcns_to_follow));
@ -2008,9 +2008,9 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
if (extra <= end)
{
/* show redo data */
if (!le16_cmpz(logr->redo_length))
if (logr->redo_length)
{
if (!le16_cmpz(logr->lcns_to_follow))
if (logr->lcns_to_follow)
{
off = le16_to_cpu(logr->record_offset)
+ le16_to_cpu(logr->attribute_offset);
@ -2037,9 +2037,9 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
}
/* show undo data */
if (!le16_cmpz(logr->undo_length))
if (logr->undo_length)
{
if (!le16_cmpz(logr->lcns_to_follow))
if (logr->lcns_to_follow)
{
off = le16_to_cpu(logr->record_offset)
+ le16_to_cpu(logr->attribute_offset);
@ -2083,15 +2083,15 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
else
{
/* sometimes the designated data overflows */
if (!le16_cmpz(logr->redo_length)
if (logr->redo_length
&& ((u32)(redo + le16_to_cpu(logr->redo_length)) > end))
printf("* redo data overflows from record\n");
if (!le16_cmpz(logr->undo_length)
if (logr->undo_length
&& ((u32)(undo + le16_to_cpu(logr->undo_length)) > end))
printf("* undo data overflows from record\n");
}
break;
} else if (le32_eq(logr->record_type, LOG_CHECKPOINT)) {
case LOG_CHECKPOINT :
printf("---> checkpoint record\n");
printf("redo_operation %04x %s\n",
(int)le16_to_cpu(logr->redo_operation),
@ -2120,7 +2120,7 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
printf("unknown-%u %016llx\n",i,
(long long)le64_to_cpu(logr->unknown_list[i]));
break;
} else {
default :
printf("** Unknown action type\n");
if (le32_to_cpu(logr->client_data_length) < blocksz) {
printf("client_data for record type %ld\n",
@ -2130,7 +2130,7 @@ static void detaillogr(CONTEXT *ctx, const LOG_RECORD *logr)
} else
printf("** Bad client data\n");
break;
} } while(0);
}
}
BOOL within_lcn_range(const LOG_RECORD *logr)
@ -2140,17 +2140,17 @@ BOOL within_lcn_range(const LOG_RECORD *logr)
BOOL within;
within = FALSE;
do {
if (le32_eq(logr->record_type, LOG_STANDARD)) {
switch (logr->record_type) {
case LOG_STANDARD :
for (i=0; i<le16_to_cpu(logr->lcns_to_follow); i++) {
lcn = MREF(sle64_to_cpu(logr->lcn_list[i]));
if ((lcn >= firstlcn) && (lcn <= lastlcn))
within = TRUE;
}
break;
} else {
default :
break;
} } while(0);
}
return (within);
}
@ -2189,7 +2189,7 @@ static void showlogr(CONTEXT *ctx, int k, const LOG_RECORD *logr)
if (optt) {
const char *state;
if (le32_eq(logr->record_type, LOG_CHECKPOINT))
if (logr->record_type == LOG_CHECKPOINT)
state = "--checkpoint--";
else
state = commitment(sle64_to_cpu(logr->this_lsn));
@ -2198,9 +2198,9 @@ static void showlogr(CONTEXT *ctx, int k, const LOG_RECORD *logr)
state,
(long)(sle64_to_cpu(logr->this_lsn) - synced_lsn),
actionname(le16_to_cpu(logr->redo_operation)));
if (!sle64_cmpz(logr->client_previous_lsn) || !sle64_cmpz(logr->client_undo_next_lsn)) {
if (sle64_eq(logr->client_previous_lsn,
logr->client_undo_next_lsn)) {
if (logr->client_previous_lsn || logr->client_undo_next_lsn) {
if (logr->client_previous_lsn
== logr->client_undo_next_lsn) {
printf(" "
" previous and undo %016llx\n",
(long long)sle64_to_cpu(
@ -2211,7 +2211,7 @@ static void showlogr(CONTEXT *ctx, int k, const LOG_RECORD *logr)
(long long)sle64_to_cpu(
logr->client_previous_lsn));
if (!sle64_cmpz(logr->client_undo_next_lsn))
if (logr->client_undo_next_lsn)
printf(" undo %016llx\n",
(long long)sle64_to_cpu(
logr->client_undo_next_lsn));
@ -2241,10 +2241,10 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
id = const_cpu_to_le32(0);
for (action=lastaction; action; action=action->prev) {
logr = &action->record;
if (le16_eq(logr->redo_operation,
const_cpu_to_le16(ForgetTransaction))
if ((logr->redo_operation
== const_cpu_to_le16(ForgetTransaction))
&& !(action->flags & ACTION_TO_REDO)
&& le32_cmpz(id)) {
&& !id) {
id = logr->transaction_id;
action->flags |= ACTION_TO_REDO;
if (optv)
@ -2253,11 +2253,11 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
}
committed = ((s64)(sle64_to_cpu(logr->this_lsn)
- committed_lsn)) <= 0;
if (le32_cmpz(logr->transaction_id)
if (!logr->transaction_id
&& committed)
action->flags |= ACTION_TO_REDO;
if (!le32_cmpz(id)
&& le32_eq(logr->transaction_id, id)
if (id
&& (logr->transaction_id == id)
&& committed) {
action->flags |= ACTION_TO_REDO;
more = TRUE;
@ -2272,7 +2272,7 @@ static void mark_transactions(struct ACTION_RECORD *lastaction)
if (optv) {
for (action=lastaction; action; action=action->prev) {
logr = &action->record;
if (!le32_cmpz(logr->transaction_id)
if (logr->transaction_id
&& !(action->flags & ACTION_TO_REDO))
printf("** Action %d was aborted\n",
(int)action->num);
@ -2313,7 +2313,7 @@ static TRISTATE enqueue_action(CONTEXT *ctx, const LOG_RECORD *logr,
err = 0;
state = T_OK;
if ((optp || optu)
&& le32_eq(logr->record_type, LOG_CHECKPOINT)) {
&& (logr->record_type == LOG_CHECKPOINT)) {
/* if chkp process queue, and increment count */
playedactions++;
if (playedactions <= playcount) {
@ -2620,7 +2620,7 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
BOOL stop;
rph = &buf->block.record;
if (rph && le32_eq(rph->magic, magic_RCRD)) {
if (rph && (rph->magic == magic_RCRD)) {
data = buf->block.data;
showheadrcrd(blk, rph);
k = buf->headsz;
@ -2677,7 +2677,7 @@ static u16 forward_rcrd(CONTEXT *ctx, u32 blk, u16 pos,
k + size);
}
showlogr(ctx, k, logr);
if (le32_cmpz(logr->client_data_length)) {
if (!logr->client_data_length) {
printf("** Bad"
" client_data_length\n");
stop = TRUE;
@ -2714,8 +2714,8 @@ static void showrest(const RESTART_PAGE_HEADER *rest)
const char *data;
data = (const char*)rest;
if (le32_eq(rest->magic, magic_RSTR)
|| le32_eq(rest->magic, magic_CHKD)) {
if ((rest->magic == magic_RSTR)
|| (rest->magic == magic_CHKD)) {
if (optv) {
printf("magic %08lx\n",
(long)le32_to_cpu(rest->magic));
@ -2843,7 +2843,7 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
offs += le16_to_cpu(restart.client_array_offset);
memcpy(&client, &data[offs],
sizeof(LOG_CLIENT_RECORD));
dirty = le16_andz(resa->flags, RESTART_VOLUME_IS_CLEAN);
dirty = !(resa->flags & RESTART_VOLUME_IS_CLEAN);
if (optv || optt)
printf("* Using initial restart page,"
" syncing from 0x%llx, %s\n",
@ -2870,7 +2870,7 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
}
showrest(rph);
/* Information from an older restart block if requested */
dirty = le16_andz(restart.flags, RESTART_VOLUME_IS_CLEAN);
dirty = !(restart.flags & RESTART_VOLUME_IS_CLEAN);
diff = sle64_to_cpu(rcli->client_restart_lsn) - committed_lsn;
if (ctx->vol) {
change = (opts > 1) && (diff < 0);
@ -2889,7 +2889,7 @@ static BOOL dorest(CONTEXT *ctx, unsigned long blk,
offs += le16_to_cpu(restart.client_array_offset);
memcpy(&client, &data[offs],
sizeof(LOG_CLIENT_RECORD));
dirty = le16_andz(resa->flags, RESTART_VOLUME_IS_CLEAN);
dirty = !(resa->flags & RESTART_VOLUME_IS_CLEAN);
if (optv || optt)
printf("* Using %s restart page,"
" syncing from 0x%llx, %s\n",
@ -2956,21 +2956,21 @@ static const struct BUFFER *read_restart(CONTEXT *ctx)
NTFS_RECORD_TYPES magic;
magic = buf->block.restart.magic;
/* switch (magic) { */
if (le32_eq(magic, magic_RSTR)) {
}
else if (le32_eq(magic, magic_CHKD)) {
switch (magic) {
case magic_RSTR :
break;
case magic_CHKD :
printf("** The log file has been obsoleted by chkdsk\n");
bad = TRUE;
}
else if (le32_eq(magic, magic_empty)) {
break;
case magic_empty :
printf("** The log file has been wiped out\n");
bad = TRUE;
}
else {
break;
default :
printf("** Invalid restart block\n");
bad = TRUE;
/* break; */
break;
}
if (!bad && !ctx->vol)
dorest(ctx, 0, &buf->block.restart, TRUE);
@ -3013,7 +3013,7 @@ static int reset_logfile(CONTEXT *ctx __attribute__((unused)))
if (buffer) {
memset(buffer, 0, blocksz);
restart.client_in_use_list = LOGFILE_NO_CLIENT;
restart.flags = le16_or(restart.flags, RESTART_VOLUME_IS_CLEAN);
restart.flags |= RESTART_VOLUME_IS_CLEAN;
client.oldest_lsn = cpu_to_sle64(restart_lsn);
/* Set $LogFile version to 1.1 so that volume can be mounted */
log_header.major_ver = const_cpu_to_sle16(1);
@ -3062,7 +3062,7 @@ static const struct BUFFER *best_start(const struct BUFFER *buf,
else
best = buf;
}
if (best && !le32_eq(best->block.record.magic, magic_RCRD))
if (best && (best->block.record.magic != magic_RCRD))
best = (const struct BUFFER*)NULL;
return (best);
}
@ -3244,8 +3244,8 @@ static BOOL getvolumedata(CONTEXT *ctx, char *boot)
}
// TODO get rest ?, meaningful ?
if (ok && rest) {
if (!le16_cmpz(rest->client_in_use_list)
|| le16_andz(rest->flags, const_cpu_to_le16(2)))
if (rest->client_in_use_list
|| !(rest->flags & const_cpu_to_le16(2)))
printf("Volume was not unmounted safely\n");
else
printf("Volume was unmounted safely\n");
@ -3453,8 +3453,8 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
if (prevbuf)
prevrph = &prevbuf->block.record;
data = buf->block.data;
if (rph && le32_eq(rph->magic, magic_RCRD)
&& (!prevrph || le32_eq(prevrph->magic, magic_RCRD))) {
if (rph && (rph->magic == magic_RCRD)
&& (!prevrph || (prevrph->magic == magic_RCRD))) {
if (optv) {
if (optv >= 2)
hexdump(data,blocksz);
@ -3521,7 +3521,7 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
if (((u32)(k + size) <= blocksz)
&& ((u32)(k + size) <= endoff)) {
poslist[cnt++] = k;
if (le32_cmpz(logr->client_data_length))
if (!logr->client_data_length)
stop = TRUE;
k += size;
if ((u32)(k
@ -3561,14 +3561,14 @@ static TRISTATE backward_rcrd(CONTEXT *ctx, u32 blk, int skipped,
if ((optv | optt)
&& (!nextbuf && (j == (cnt - 1)))) {
printf("* This is the latest record\n");
if (sle64_eq(logr->this_lsn, restart.current_lsn))
if (logr->this_lsn == restart.current_lsn)
printf(" its lsn matches the global"
" restart lsn\n");
if (sle64_eq(logr->this_lsn, client.client_restart_lsn))
if (logr->this_lsn == client.client_restart_lsn)
printf(" its lsn matches the client"
" restart lsn\n");
if (le32_eq(logr->client_data_length,
restart.last_lsn_data_length))
if (logr->client_data_length
== restart.last_lsn_data_length)
printf(" its length matches the"
" last record length\n");
}
@ -3623,18 +3623,18 @@ static int walkback(CONTEXT *ctx, const struct BUFFER *buf, u32 blk,
- (log_major < 2 ? BASEBLKS
: BASEBLKS2);
magic = prevbuf->block.record.magic;
/* switch (magic) { */
if (le32_eq(magic, magic_RCRD)) {
}
else if (le32_eq(magic, magic_CHKD)) {
switch (magic) {
case magic_RCRD :
break;
case magic_CHKD :
printf("** Unexpected block type CHKD\n");
}
else if (le32_eq(magic, magic_RSTR)) {
break;
case magic_RSTR :
printf("** Unexpected block type RSTR\n");
}
else {
break;
default :
printf("** Invalid block %d\n",(int)prevblk);
/* break; */
break;
}
if (optv) {
if (skipped)
@ -3888,24 +3888,24 @@ static int walk(CONTEXT *ctx)
record = (const NTFS_RECORD*)&nextbuf->block.data;
blkheadsz = nextbuf->headsz;
magic = record->magic;
/* switch (magic) { */
if (le32_eq(magic, magic_CHKD) ||
le32_eq(magic, magic_RSTR) ||
le32_eq(magic, magic_RCRD)) {
}
else {
switch (magic) {
case magic_CHKD :
case magic_RSTR :
case magic_RCRD :
break;
default :
printf("** Invalid block\n");
err = 1;
/* break; */
break;
}
magic = buf->block.record.magic;
/* switch (magic) { */
if (le32_eq(magic, magic_CHKD) ||
le32_eq(magic, magic_RSTR)) {
switch (magic) {
case magic_CHKD :
case magic_RSTR :
dirty = dorest(ctx, blk, &buf->block.restart,
FALSE);
}
else if (le32_eq(magic, magic_RCRD)) {
break;
case magic_RCRD :
if (blk < BASEBLKS)
pos = buf->headsz;
pos = dorcrd(ctx, blk, pos, buf, nextbuf);
@ -3924,13 +3924,13 @@ static int walk(CONTEXT *ctx)
if (nextblk != (blk + 1)) {
nextbuf = read_buffer(ctx,nextblk);
}
}
else {
if (le32_cmpz(le32_not(magic))) {
break;
default :
if (!~magic) {
if (optv)
printf(" empty block\n");
}
/* break; */
break;
}
} else {
fprintf(stderr,"* Could not read block %d\n",nextblk);
@ -4063,21 +4063,21 @@ static int walk(CONTEXT *ctx)
if (prevbuf) {
prevblk = prevbuf->num;
magic = prevbuf->block.record.magic;
/* switch (magic) { */
if (le32_eq(magic, magic_RCRD)) {
}
else if (le32_eq(magic, magic_CHKD)) {
switch (magic) {
case magic_RCRD :
break;
case magic_CHKD :
printf("** Unexpected block type CHKD\n");
err = 1;
}
else if (le32_eq(magic, magic_RSTR)) {
break;
case magic_RSTR :
err = 1;
printf("** Unexpected block type RSTR\n");
}
else {
break;
default :
err = 1;
printf("** Invalid block\n");
/* break; */
break;
}
} else
prevblk = BASEBLKS;

View File

@ -305,7 +305,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR fdisk (8),

View File

@ -728,7 +728,7 @@ static void collect_resize_constraints(ntfs_resize_t *resize, runlist *rl)
if (inode == FILE_Bitmap) {
llcn = &resize->last_lcn;
if (le32_eq(atype, AT_DATA) && NInoAttrList(resize->ni))
if (atype == AT_DATA && NInoAttrList(resize->ni))
err_exit("Highly fragmented $Bitmap isn't supported yet.");
supported = 1;
@ -739,11 +739,11 @@ static void collect_resize_constraints(ntfs_resize_t *resize, runlist *rl)
if (inode != FILE_MFTMirr)
supported = 1;
} else if (!le16_andz(flags, ATTR_IS_SPARSE)) {
} else if (flags & ATTR_IS_SPARSE) {
llcn = &resize->last_sparse;
supported = 1;
} else if (!le16_andz(flags, ATTR_IS_COMPRESSED)) {
} else if (flags & ATTR_IS_COMPRESSED) {
llcn = &resize->last_compressed;
supported = 1;
@ -752,7 +752,7 @@ static void collect_resize_constraints(ntfs_resize_t *resize, runlist *rl)
supported = 1;
/* Fragmented $MFTMirr DATA attribute isn't supported yet */
if (le32_eq(atype, AT_DATA))
if (atype == AT_DATA)
if (rl[1].length != 0 || rl->vcn)
supported = 0;
} else {
@ -786,7 +786,7 @@ static void collect_relocation_info(ntfs_resize_t *resize, runlist *rl)
if (lcn + lcn_length <= new_vol_size)
return;
if (inode == FILE_Bitmap && le32_eq(resize->ctx->attr->type, AT_DATA))
if (inode == FILE_Bitmap && resize->ctx->attr->type == AT_DATA)
return;
start = lcn;
@ -915,7 +915,7 @@ static int walk_attributes(ntfs_volume *vol, ntfsck_t *fsck)
return -1;
while (!ntfs_attrs_walk(fsck->ctx)) {
if (le32_eq(fsck->ctx->attr->type, AT_END))
if (fsck->ctx->attr->type == AT_END)
break;
build_lcn_usage_bitmap(vol, fsck);
}
@ -1087,7 +1087,7 @@ static int build_allocation_bitmap(ntfs_volume *vol, ntfsck_t *fsck)
return -1;
}
if (!le64_cmpz(ni->mrec->base_mft_record))
if (ni->mrec->base_mft_record)
goto close_inode;
fsck->ni = ni;
@ -1132,7 +1132,7 @@ static void resize_constraints_by_attributes(ntfs_resize_t *resize)
exit(1);
while (!ntfs_attrs_walk(resize->ctx)) {
if (le32_eq(resize->ctx->attr->type, AT_END))
if (resize->ctx->attr->type == AT_END)
break;
build_resize_constraints(resize);
}
@ -1161,7 +1161,7 @@ static void set_resize_constraints(ntfs_resize_t *resize)
(long long)inode);
}
if (!le64_cmpz(ni->mrec->base_mft_record))
if (ni->mrec->base_mft_record)
goto close_inode;
resize->ni = ni;
@ -1339,7 +1339,7 @@ static void expand_attribute_runlist(ntfs_volume *vol, struct DELAYED *delayed)
ni = ntfs_inode_open(vol,mref);
if (ni) {
if (mref == FILE_MFT)
na = (le32_eq(type, AT_DATA) ? vol->mft_na : vol->mftbmp_na);
na = (type == AT_DATA ? vol->mft_na : vol->mftbmp_na);
else
na = ntfs_attr_open(ni, type,
delayed->attr_name, delayed->name_len);
@ -1496,7 +1496,7 @@ static void delayed_updates(ntfs_resize_t *resize)
if (opt.ro_flag
&& resize->delayed_runlists
&& (resize->delayed_runlists->mref == FILE_MFT)
&& le32_eq(resize->delayed_runlists->type, AT_DATA)) {
&& (resize->delayed_runlists->type == AT_DATA)) {
/* Update the MFT data runlist later */
delayed_mft_data = resize->delayed_runlists;
resize->delayed_runlists = resize->delayed_runlists->next;
@ -1506,9 +1506,9 @@ static void delayed_updates(ntfs_resize_t *resize)
delayed = resize->delayed_runlists;
expand_attribute_runlist(resize->vol, delayed);
if (delayed->mref == FILE_MFT) {
if (le32_eq(delayed->type, AT_BITMAP))
if (delayed->type == AT_BITMAP)
record_mft_in_bitmap(resize);
if (le32_eq(delayed->type, AT_DATA))
if (delayed->type == AT_DATA)
resize->mirr_from = MIRR_MFT;
}
resize->delayed_runlists = resize->delayed_runlists->next;
@ -1563,7 +1563,7 @@ static void replace_later(ntfs_resize_t *resize, runlist *rl, runlist *head_rl)
delayed = (struct DELAYED*)ntfs_malloc(sizeof(struct DELAYED));
if (delayed && (attr_name || !name_len)) {
lemref = resize->ctx->mrec->base_mft_record;
if (!le64_cmpz(lemref))
if (lemref)
mref = le64_to_cpu(lemref);
else
mref = resize->mref;
@ -1928,7 +1928,7 @@ static void copy_clusters(ntfs_resize_t *resize, s64 dest, s64 src, s64 len)
static void relocate_clusters(ntfs_resize_t *r, runlist *dest_rl, s64 src_lcn)
{
/* collect_shrink_constraints() ensured $MFTMir DATA is one run */
if (r->mref == FILE_MFTMirr && le32_eq(r->ctx->attr->type, AT_DATA)) {
if (r->mref == FILE_MFTMirr && r->ctx->attr->type == AT_DATA) {
if (!r->mftmir_old) {
r->mftmir_rl.lcn = dest_rl->lcn;
r->mftmir_rl.length = dest_rl->length;
@ -2026,7 +2026,7 @@ static void relocate_run(ntfs_resize_t *resize, runlist **rl, int run)
hint = (resize->mref == FILE_MFTMirr) ? 1 : 0;
if ((resize->mref == FILE_MFT)
&& le32_eq(resize->ctx->attr->type, AT_DATA)
&& (resize->ctx->attr->type == AT_DATA)
&& !run
&& resize->new_mft_start) {
relocate_rl = resize->new_mft_start;
@ -2054,7 +2054,7 @@ static void relocate_run(ntfs_resize_t *resize, runlist **rl, int run)
/* Do not free the relocated MFT start */
if ((resize->mref != FILE_MFT)
|| !le32_eq(resize->ctx->attr->type, AT_DATA)
|| (resize->ctx->attr->type != AT_DATA)
|| run
|| !resize->new_mft_start)
free(relocate_rl);
@ -2110,7 +2110,7 @@ static int is_mftdata(ntfs_resize_t *resize)
* the other files.
*/
if (!le32_eq(resize->ctx->attr->type, AT_DATA))
if (resize->ctx->attr->type != AT_DATA)
return 0;
if (resize->mref == 0)
@ -2167,12 +2167,12 @@ static void relocate_attributes(ntfs_resize_t *resize, int do_mftdata)
exit(1);
lemref = resize->mrec->base_mft_record;
if (!le64_cmpz(lemref))
if (lemref)
base_mref = MREF(le64_to_cpu(lemref));
else
base_mref = resize->mref;
while (!ntfs_attrs_walk(resize->ctx)) {
if (le32_eq(resize->ctx->attr->type, AT_END))
if (resize->ctx->attr->type == AT_END)
break;
if (handle_mftdata(resize, do_mftdata) == 0)
@ -2185,12 +2185,12 @@ static void relocate_attributes(ntfs_resize_t *resize, int do_mftdata)
continue;
if (resize->mref == FILE_Bitmap &&
le32_eq(resize->ctx->attr->type, AT_DATA))
resize->ctx->attr->type == AT_DATA)
continue;
/* Do not relocate bad clusters */
if ((base_mref == FILE_BadClus)
&& (le32_eq(resize->ctx->attr->type, AT_DATA)))
&& (resize->ctx->attr->type == AT_DATA))
continue;
relocate_attribute(resize);
@ -2211,7 +2211,7 @@ static void relocate_inode(ntfs_resize_t *resize, MFT_REF mref, int do_mftdata)
perr_exit("ntfs_file_record_record");
}
if (le16_andz(resize->mrec->flags, MFT_RECORD_IN_USE))
if (!(resize->mrec->flags & MFT_RECORD_IN_USE))
return;
resize->mref = mref;
@ -2290,8 +2290,8 @@ static void relocate_inodes(ntfs_resize_t *resize)
err_exit("Could not read the base record of MFT\n");
}
while (!ntfs_attrs_walk(resize->ctx)
&& !le32_eq(resize->ctx->attr->type, AT_DATA)) { }
if (le32_eq(resize->ctx->attr->type, AT_DATA)) {
&& (resize->ctx->attr->type != AT_DATA)) { }
if (resize->ctx->attr->type == AT_DATA) {
sle64 high_le;
high_le = resize->ctx->attr->highest_vcn;
@ -2441,9 +2441,8 @@ static void truncate_badclust_bad_attr(ntfs_resize_t *resize)
exit(1);
}
/* Clear the sparse flags, even if there are bad clusters */
na->ni->flags =
le32_and(na->ni->flags, le32_not(FILE_ATTR_SPARSE_FILE));
na->data_flags = le16_and(na->data_flags, le16_not(ATTR_IS_SPARSE));
na->ni->flags &= ~FILE_ATTR_SPARSE_FILE;
na->data_flags &= ~ATTR_IS_SPARSE;
ctx = resize->ctx;
ctx->attr->data_size = cpu_to_sle64(na->data_size);
ctx->attr->initialized_size = cpu_to_sle64(na->initialized_size);
@ -2944,7 +2943,7 @@ static ntfs_volume *mount_volume(void)
}
vol = check_volume();
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY))
if (vol->flags & VOLUME_IS_DIRTY)
if (opt.force-- <= 0)
err_exit("Volume is scheduled for check.\nRun chkdsk /f"
" and please try again, or see option -f.\n");
@ -2985,7 +2984,7 @@ static void prepare_volume_fixup(ntfs_volume *vol)
{
printf("Schedule chkdsk for NTFS consistency check at Windows boot "
"time ...\n");
vol->flags = le16_or(vol->flags, VOLUME_IS_DIRTY);
vol->flags |= VOLUME_IS_DIRTY;
if (ntfs_volume_write_flags(vol, vol->flags))
perr_exit("Failed to set the volume dirty");
@ -3129,8 +3128,8 @@ static ATTR_RECORD *find_attr(MFT_RECORD *mrec, ATTR_TYPES type,
offset = le16_to_cpu(mrec->attrs_offset);
a = (ATTR_RECORD*)((char*)mrec + offset);
attrname = (ntfschar*)((char*)a + le16_to_cpu(a->name_offset));
while (!le32_eq(a->type, AT_END)
&& (!le32_eq(a->type, type)
while ((a->type != AT_END)
&& ((a->type != type)
|| (a->name_length != namelen)
|| (namelen && memcmp(attrname,name,2*namelen)))
&& (offset < le32_to_cpu(mrec->bytes_in_use))) {
@ -3140,7 +3139,7 @@ static ATTR_RECORD *find_attr(MFT_RECORD *mrec, ATTR_TYPES type,
attrname = (ntfschar*)((char*)a
+ le16_to_cpu(a->name_offset));
}
if (!le32_eq(a->type, type)
if ((a->type != type)
|| (a->name_length != namelen)
|| (namelen && memcmp(attrname,name,2*namelen)))
a = (ATTR_RECORD*)NULL;
@ -3171,12 +3170,12 @@ static ATTR_RECORD *get_unnamed_attr(expand_t *expand, ATTR_TYPES type,
+ (inum << vol->mft_record_size_bits)
+ expand->byte_increment;
got = ntfs_mst_pread(vol->dev, pos, 1, vol->mft_record_size, mrec);
if ((got == 1) && !le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
if ((got == 1) && (mrec->flags & MFT_RECORD_IN_USE)) {
a = find_attr(expand->mrec, type, NULL, 0);
found = a && le32_eq(a->type, type) && !a->name_length;
found = a && (a->type == type) && !a->name_length;
}
/* not finding the attribute list is not an error */
if (!found && !le32_eq(type, AT_ATTRIBUTE_LIST)) {
if (!found && (type != AT_ATTRIBUTE_LIST)) {
err_printf("Could not find attribute 0x%lx in inode %lld\n",
(long)le32_to_cpu(type), (long long)inum);
a = (ATTR_RECORD*)NULL;
@ -3206,7 +3205,7 @@ static ATTR_RECORD *read_and_get_attr(expand_t *expand, ATTR_TYPES type,
+ (inum << vol->mft_record_size_bits)
+ expand->byte_increment;
got = ntfs_mst_pread(vol->dev, pos, 1, vol->mft_record_size, mrec);
if ((got == 1) && !le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
if ((got == 1) && (mrec->flags & MFT_RECORD_IN_USE)) {
a = find_attr(expand->mrec, type, name, namelen);
}
if (!a) {
@ -3409,7 +3408,7 @@ static int check_expand_constraints(expand_t *expand)
volinfo = (VOLUME_INFORMATION*)
(le16_to_cpu(a->value_offset) + (char*)a);
flags = volinfo->flags;
if (!le16_andz(flags, VOLUME_IS_DIRTY) && (opt.force-- <= 0)) {
if ((flags & VOLUME_IS_DIRTY) && (opt.force-- <= 0)) {
err_printf("Volume is scheduled for check.\nRun chkdsk /f"
" and please try again, or see option -f.\n");
res = -1;
@ -3789,7 +3788,7 @@ static int copy_boot(expand_t *expand)
/* the hidden sectors are needed to boot into windows */
memcpy(&hidden_sectors_le,&bs->bpb.hidden_sectors,4);
/* alignment messed up on the Sparc */
if (!le32_cmpz(hidden_sectors_le)) {
if (hidden_sectors_le) {
hidden_sectors = le32_to_cpu(hidden_sectors_le);
if (hidden_sectors >= expand->sector_increment)
hidden_sectors -= expand->sector_increment;
@ -4037,7 +4036,7 @@ static int rebase_runlists(expand_t *expand, s64 inum)
mrec = expand->mrec;
offset = le16_to_cpu(mrec->attrs_offset);
a = (ATTR_RECORD*)((char*)mrec + offset);
while (!res && !le32_eq(a->type, AT_END)
while (!res && (a->type != AT_END)
&& (offset < le32_to_cpu(mrec->bytes_in_use))) {
if (a->non_resident) {
rl = ntfs_mapping_pairs_decompress(expand->vol, a,
@ -4122,7 +4121,7 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
allocated_size = lth << vol->cluster_size_bits;
offset = le16_to_cpu(mrec->attrs_offset);
a = (ATTR_RECORD*)((char*)mrec + offset);
while (!res && !le32_eq(a->type, AT_END)
while (!res && (a->type != AT_END)
&& (offset < le32_to_cpu(mrec->bytes_in_use))) {
if (a->non_resident) {
keeprl = FALSE;
@ -4133,12 +4132,12 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
for (prl=rl; prl->length; prl++)
if (prl->lcn >= 0) {
prl->lcn += expand->cluster_increment;
if (!le32_eq(a->type, AT_DATA)
if ((a->type != AT_DATA)
&& set_bitmap(expand,prl))
res = -1;
}
/* relocated unnamed data (not $BadClus) */
if (le32_eq(a->type, AT_DATA)
if ((a->type == AT_DATA)
&& !a->name_length
&& (inum != FILE_BadClus)) {
old_rl = rl;
@ -4159,7 +4158,7 @@ static runlist_element *rebase_runlists_meta(expand_t *expand, s64 inum)
a->highest_vcn = cpu_to_sle64(lth - 1);
}
/* expand the named data for $BadClus */
if (le32_eq(a->type, AT_DATA)
if ((a->type == AT_DATA)
&& a->name_length
&& (inum == FILE_BadClus)) {
old_rl = rl;
@ -4222,7 +4221,7 @@ static int rebase_inode(expand_t *expand, const runlist_element *prl,
+ ((inum - jnum) << vol->mft_record_size_bits);
if ((ntfs_mst_pread(vol->dev, pos, 1,
vol->mft_record_size, mrec) == 1)
&& !le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
&& (mrec->flags & MFT_RECORD_IN_USE)) {
switch (inum) {
case FILE_Bitmap :
case FILE_Boot :
@ -4296,7 +4295,7 @@ static int rebase_all_inodes(expand_t *expand)
<< vol->cluster_size_bits;
got = ntfs_mst_pread(vol->dev, pos, 1,
vol->mft_record_size, mrec);
if ((got == 1) && !le16_andz(mrec->flags, MFT_RECORD_IN_USE)) {
if ((got == 1) && (mrec->flags & MFT_RECORD_IN_USE)) {
pos = expand->mft_lcn << vol->cluster_size_bits;
if (opt.verbose)
ntfs_log_verbose("Rebasing inode %lld cluster 0x%llx\n",

View File

@ -160,7 +160,7 @@ of 1 when an error was detected.
Please see
.RS
.sp
http://www.tuxera.com/community/ntfs-3g-faq/
https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ/
.sp
.RE
for common questions and known issues.

View File

@ -366,15 +366,15 @@ typedef enum { CMD_AUDIT, CMD_BACKUP, CMD_HEX, CMD_HELP, CMD_SET,
/* standard owner (and administrator) rights */
#define OWNER_RIGHTS le32_or(DELETE, le32_or(READ_CONTROL, le32_or(WRITE_DAC, le32_or(WRITE_OWNER, \
le32_or(SYNCHRONIZE, \
le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_WRITE_ATTRIBUTES, \
le32_or(FILE_READ_EA, FILE_WRITE_EA))))))))
#define OWNER_RIGHTS (DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER \
| SYNCHRONIZE \
| FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES \
| FILE_READ_EA | FILE_WRITE_EA)
/* standard world rights */
#define WORLD_RIGHTS le32_or(READ_CONTROL, le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_READ_EA, \
SYNCHRONIZE)))
#define WORLD_RIGHTS (READ_CONTROL | FILE_READ_ATTRIBUTES | FILE_READ_EA \
| SYNCHRONIZE)
/* inheritance flags for files and directories */
@ -812,7 +812,7 @@ static unsigned int utf8size(const ntfschar *utf16, int length)
surrog = FALSE;
fail = FALSE;
for (i = 0; i < length && !le16_cmpz(utf16[i]) && !fail; i++) {
for (i = 0; i < length && utf16[i] && !fail; i++) {
unsigned short c = le16_to_cpu(utf16[i]);
if (surrog) {
if ((c >= 0xdc00) && (c < 0xe000)) {
@ -1391,7 +1391,7 @@ static void showace(const char *attr, int off, int isdir, int level)
printf(" grant");
if (attr[off] == 1)
printf(" deny");
if (rights & le32_to_cpu(le32_or(FILE_GREAD, le32_or(FILE_GWRITE, FILE_GEXEC)))) {
if (rights & le32_to_cpu(FILE_GREAD | FILE_GWRITE | FILE_GEXEC)) {
printf(" ");
if (rights & le32_to_cpu(FILE_GREAD))
printf("r");
@ -2399,8 +2399,8 @@ static BOOL restore(FILE *fd)
if (fullname[0]) {
phead = (SECURITY_DESCRIPTOR_RELATIVE*)attr;
/* set the request for auto-inheritance */
if (!le16_andz(phead->control, SE_DACL_AUTO_INHERITED))
phead->control = le16_or(phead->control, SE_DACL_AUTO_INHERIT_REQ);
if (phead->control & SE_DACL_AUTO_INHERITED)
phead->control |= SE_DACL_AUTO_INHERIT_REQ;
if (!applyattr(fullname,attr,withattr,
attrib,key))
errors++;
@ -2670,8 +2670,8 @@ static char *build_dummy_descr(BOOL isdir __attribute__((unused)),
* The flag SE_DACL_PROTECTED prevents the ACL
* to be changed in an inheritance after creation
*/
pnhead->control = le16_or(SE_DACL_PRESENT, le16_or(SE_DACL_PROTECTED,
SE_SELF_RELATIVE));
pnhead->control = SE_DACL_PRESENT | SE_DACL_PROTECTED
| SE_SELF_RELATIVE;
/*
* Windows prefers ACL first, do the same to
* get the same hash value and avoid duplication
@ -3025,11 +3025,11 @@ static void check_samples(void)
(const SID*)owner3, (const SID*)group3,
4,
(int)TRUE, (const SID*)owner3, 0,
le32_to_cpu(le32_or(FILE_READ_DATA, OWNER_RIGHTS)),
le32_to_cpu(FILE_READ_DATA | OWNER_RIGHTS),
(int)TRUE, (const SID*)group3, 0,
le32_to_cpu(FILE_WRITE_DATA),
(int)TRUE, (const SID*)group2, 0,
le32_to_cpu(le32_or(FILE_WRITE_DATA, FILE_READ_DATA)),
le32_to_cpu(FILE_WRITE_DATA | FILE_READ_DATA),
(int)TRUE, (const SID*)worldsid, 0,
le32_to_cpu(FILE_EXECUTE));
expect = 0731;
@ -3706,9 +3706,9 @@ static unsigned int getfull(char *attr, const char *fullname)
memcpy(&attr[attrsz],&part[20],partsz-20);
set4l(&attr[16],(partsz > 20 ? attrsz : 0));
set2l(&attr[2],get2l(attr,2) | (get2l(part,2)
& const_le16_to_cpu(le16_or(SE_DACL_PROTECTED,
le16_or(SE_DACL_AUTO_INHERITED,
SE_DACL_PRESENT)))));
& const_le16_to_cpu(SE_DACL_PROTECTED
| SE_DACL_AUTO_INHERITED
| SE_DACL_PRESENT)));
attrsz += partsz - 20;
} else
overflow = TRUE;
@ -4695,9 +4695,9 @@ static int callback(void *ctx, const ntfschar *ntfsname,
&& (type != 2) /* 2 : dos name (8+3) */
&& (size > 0) /* chars convertible to utf8 */
&& ((length > 2)
|| !le16_eq(ntfsname[0], const_cpu_to_le16('.'))
|| (ntfsname[0] != const_cpu_to_le16('.'))
|| ((length > 1)
&& !le16_eq(ntfsname[1], const_cpu_to_le16('.'))))) {
&& (ntfsname[1] != const_cpu_to_le16('.'))))) {
linkage = (struct LINK*)malloc(sizeof(struct LINK)
+ strlen(dircontext->dir)
+ size + 2);

View File

@ -116,7 +116,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfs-3g (8),

View File

@ -317,28 +317,28 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
VOLUME_FLAGS flags;
u32 u;
/* switch (type) { */
if (le32_eq(type, AT_STANDARD_INFORMATION)) {
switch (type) {
case AT_STANDARD_INFORMATION:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_ATTRIBUTE_LIST)) {
case AT_ATTRIBUTE_LIST:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_FILE_NAME)) {
case AT_FILE_NAME:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_OBJECT_ID)) {
case AT_OBJECT_ID:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_SECURITY_DESCRIPTOR)) {
case AT_SECURITY_DESCRIPTOR:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_VOLUME_NAME)) {
case AT_VOLUME_NAME:
printf("Volume name length = %u\n", (unsigned int)val_len);
if (val_len) {
buf = calloc(1, val_len);
@ -353,58 +353,58 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
free(buf);
}
return;
} else if (le32_eq(type, AT_VOLUME_INFORMATION)) {
case AT_VOLUME_INFORMATION:
#define VOL_INF(x) ((VOLUME_INFORMATION *)(x))
printf("NTFS version %i.%i\n", VOL_INF(val)->major_ver,
VOL_INF(val)->minor_ver);
flags = VOL_INF(val)->flags;
#undef VOL_INF
printf("Volume flags = 0x%x: ", le16_to_cpu(flags));
if (le16_cmpz(flags)) {
if (!flags) {
printf("NONE\n");
return;
}
j = 0;
if (!le16_andz(flags, VOLUME_MODIFIED_BY_CHKDSK)) {
if (flags & VOLUME_MODIFIED_BY_CHKDSK) {
j = 1;
printf("VOLUME_MODIFIED_BY_CHKDSK");
}
if (!le16_andz(flags, VOLUME_REPAIR_OBJECT_ID)) {
if (flags & VOLUME_REPAIR_OBJECT_ID) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_REPAIR_OBJECT_ID");
}
if (!le16_andz(flags, VOLUME_DELETE_USN_UNDERWAY)) {
if (flags & VOLUME_DELETE_USN_UNDERWAY) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_DELETE_USN_UNDERWAY");
}
if (!le16_andz(flags, VOLUME_MOUNTED_ON_NT4)) {
if (flags & VOLUME_MOUNTED_ON_NT4) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_MOUNTED_ON_NT4");
}
if (!le16_andz(flags, VOLUME_UPGRADE_ON_MOUNT)) {
if (flags & VOLUME_UPGRADE_ON_MOUNT) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_UPGRADE_ON_MOUNT");
}
if (!le16_andz(flags, VOLUME_RESIZE_LOG_FILE)) {
if (flags & VOLUME_RESIZE_LOG_FILE) {
if (j)
printf(" | ");
else
j = 0;
printf("VOLUME_RESIZE_LOG_FILE");
}
if (!le16_andz(flags, VOLUME_IS_DIRTY)) {
if (flags & VOLUME_IS_DIRTY) {
if (j)
printf(" | ");
else
@ -413,37 +413,37 @@ static void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len)
}
printf("\n");
return;
} else if (le32_eq(type, AT_DATA)) {
case AT_DATA:
printf(skip, "DATA");
return;
} else if (le32_eq(type, AT_INDEX_ROOT)) {
case AT_INDEX_ROOT:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_INDEX_ALLOCATION)) {
case AT_INDEX_ALLOCATION:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_BITMAP)) {
case AT_BITMAP:
printf(skip, "BITMAP");
return;
} else if (le32_eq(type, AT_REPARSE_POINT)) {
case AT_REPARSE_POINT:
// TODO
printf("%s\n", todo);
return;
} else if (le32_eq(type, AT_EA_INFORMATION)) {
case AT_EA_INFORMATION:
// TODO
printf("%s\n", don_t_know);
return;
} else if (le32_eq(type, AT_EA)) {
case AT_EA:
// TODO
printf("%s\n", don_t_know);
return;
} else if (le32_eq(type, AT_LOGGED_UTILITY_STREAM)) {
case AT_LOGGED_UTILITY_STREAM:
// TODO
printf("%s\n", don_t_know);
return;
} else {
default:
u = le32_to_cpu(type);
printf("Cannot display unknown %s defined attribute type 0x%x"
".\n", u >=
@ -515,7 +515,7 @@ static void dump_non_resident_attr(ATTR_RECORD *a)
l = sle64_to_cpu(a->initialized_size);
printf("Initialized size = %lli (0x%llx)\n", (long long)l,
(unsigned long long)l);
if (!le16_andz(a->flags, ATTR_COMPRESSION_MASK)) {
if (a->flags & ATTR_COMPRESSION_MASK) {
l = sle64_to_cpu(a->compressed_size);
printf("Compressed size = %lli (0x%llx)\n", (long long)l,
(unsigned long long)l);
@ -536,7 +536,7 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
printf("-- Beginning dump of attribute record at offset 0x%x. --\n",
(unsigned)((u8*)a - (u8*)m));
if (le32_eq(a->type, AT_END)) {
if (a->type == AT_END) {
printf("Attribute type = 0x%x ($END)\n",
(unsigned int)le32_to_cpu(AT_END));
u = le32_to_cpu(a->length);
@ -544,10 +544,10 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
return;
}
u = le32_to_cpu(a->type);
for (i = 0; !le32_cmpz(attr_defs[i].type); i++)
for (i = 0; attr_defs[i].type; i++)
if (le32_to_cpu(attr_defs[i].type) >= u)
break;
if (!le32_cmpz(attr_defs[i].type)) {
if (attr_defs[i].type) {
// printf("type = 0x%x\n", le32_to_cpu(attr_defs[i].type));
// { char *p = (char*)attr_defs[i].name;
// printf("name = %c%c%c%c%c\n", *p, p[1], p[2], p[3], p[4]);
@ -582,16 +582,16 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
printf("Name = %s\n", s);
}
printf("Attribute flags = 0x%x: ", le16_to_cpu(flags));
if (le16_cmpz(flags))
if (!flags)
printf("NONE");
else {
int first = TRUE;
if (!le16_andz(flags, ATTR_COMPRESSION_MASK)) {
if (!le16_andz(flags, ATTR_IS_COMPRESSED)) {
if (flags & ATTR_COMPRESSION_MASK) {
if (flags & ATTR_IS_COMPRESSED) {
printf("ATTR_IS_COMPRESSED");
first = FALSE;
}
if (!le16_andz(le16_and(flags, ATTR_COMPRESSION_MASK), le16_not(ATTR_IS_COMPRESSED))) {
if ((flags & ATTR_COMPRESSION_MASK) & ~ATTR_IS_COMPRESSED) {
if (!first)
printf(" | ");
else
@ -599,14 +599,14 @@ static void dump_attr_record(MFT_RECORD *m, ATTR_RECORD *a)
printf("ATTR_UNKNOWN_COMPRESSION");
}
}
if (!le16_andz(flags, ATTR_IS_ENCRYPTED)) {
if (flags & ATTR_IS_ENCRYPTED) {
if (!first)
printf(" | ");
else
first = FALSE;
printf("ATTR_IS_ENCRYPTED");
}
if (!le16_andz(flags, ATTR_IS_SPARSE)) {
if (flags & ATTR_IS_SPARSE) {
if (!first)
printf(" | ");
else
@ -647,11 +647,11 @@ static void dump_mft_record(MFT_RECORD *m)
u = le16_to_cpu(m->attrs_offset);
printf("First attribute offset = %u (0x%x)\n", u, u);
printf("Flags = %u: ", le16_to_cpu(m->flags));
if (!le16_andz(m->flags, MFT_RECORD_IN_USE))
if (m->flags & MFT_RECORD_IN_USE)
printf("MFT_RECORD_IN_USE");
else
printf("MFT_RECORD_NOT_IN_USE");
if (!le16_andz(m->flags, MFT_RECORD_IS_DIRECTORY))
if (m->flags & MFT_RECORD_IS_DIRECTORY)
printf(" | MFT_RECORD_IS_DIRECTORY");
printf("\n");
u = le32_to_cpu(m->bytes_in_use);
@ -667,9 +667,9 @@ static void dump_mft_record(MFT_RECORD *m)
a = (ATTR_RECORD*)((char*)m + le16_to_cpu(m->attrs_offset));
printf("-- Beginning dump of attributes within mft record. --\n");
while ((char*)a < (char*)m + le32_to_cpu(m->bytes_in_use)) {
if (le32_eq(a->type, attr_type))
if (a->type == attr_type)
dump_attr_record(m, a);
if (le32_eq(a->type, AT_END))
if (a->type == AT_END)
break;
a = (ATTR_RECORD*)((char*)a + le32_to_cpu(a->length));
};

View File

@ -317,7 +317,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfsinfo (8),

View File

@ -960,7 +960,7 @@ static FILE_NAME_ATTR* verify_parent(struct filename* name, MFT_RECORD* rec)
if (!name || !rec)
return NULL;
if (le16_andz(rec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (!(rec->flags & MFT_RECORD_IS_DIRECTORY)) {
return NULL;
}
@ -1283,8 +1283,8 @@ static int get_data(struct ufile *file, ntfs_volume *vol)
}
data->resident = !rec->non_resident;
data->compressed = !le16_andz(rec->flags, ATTR_IS_COMPRESSED) ? 1 : 0;
data->encrypted = !le16_andz(rec->flags, ATTR_IS_ENCRYPTED) ? 1 : 0;
data->compressed = (rec->flags & ATTR_IS_COMPRESSED) ? 1 : 0;
data->encrypted = (rec->flags & ATTR_IS_ENCRYPTED) ? 1 : 0;
if (rec->name_length) {
data->uname = (ntfschar *)((char *)rec +
@ -1583,21 +1583,21 @@ static void dump_record(struct ufile *file)
ntfs_log_quiet("Filename: (%d) %s\n", f->name_space, f->name);
ntfs_log_quiet("File Flags: ");
if (!le32_andz(f->flags, FILE_ATTR_SYSTEM))
if (f->flags & FILE_ATTR_SYSTEM)
ntfs_log_quiet("System ");
if (!le32_andz(f->flags, FILE_ATTR_DIRECTORY))
if (f->flags & FILE_ATTR_DIRECTORY)
ntfs_log_quiet("Directory ");
if (!le32_andz(f->flags, FILE_ATTR_SPARSE_FILE))
if (f->flags & FILE_ATTR_SPARSE_FILE)
ntfs_log_quiet("Sparse ");
if (!le32_andz(f->flags, FILE_ATTR_REPARSE_POINT))
if (f->flags & FILE_ATTR_REPARSE_POINT)
ntfs_log_quiet("Reparse ");
if (!le32_andz(f->flags, FILE_ATTR_COMPRESSED))
if (f->flags & FILE_ATTR_COMPRESSED)
ntfs_log_quiet("Compressed ");
if (!le32_andz(f->flags, FILE_ATTR_ENCRYPTED))
if (f->flags & FILE_ATTR_ENCRYPTED)
ntfs_log_quiet("Encrypted ");
if (le32_andz(f->flags, le32_or(FILE_ATTR_SYSTEM, le32_or(FILE_ATTR_DIRECTORY,
le32_or(FILE_ATTR_SPARSE_FILE, le32_or(FILE_ATTR_REPARSE_POINT,
le32_or(FILE_ATTR_COMPRESSED, FILE_ATTR_ENCRYPTED))))))) {
if (!(f->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_DIRECTORY |
FILE_ATTR_SPARSE_FILE | FILE_ATTR_REPARSE_POINT |
FILE_ATTR_COMPRESSED | FILE_ATTR_ENCRYPTED))) {
ntfs_log_quiet("%s", NONE);
}
@ -2008,7 +2008,7 @@ static int undelete_file(ntfs_volume *vol, long long inode)
* list_record(). Otherwise, when undeleting, a file will always be
* listed as 0% recoverable even if successfully undeleted. +mabs
*/
if (!le16_andz(file->mft->flags, MFT_RECORD_IN_USE)) {
if (file->mft->flags & MFT_RECORD_IN_USE) {
ntfs_log_error("Record is in use by the mft\n");
if (!opts.force) {
free(buffer);

View File

@ -62,8 +62,6 @@ Map the users defined on the Windows system present on /dev/sda1 :
.sp
.RE
.PP
A detailed example, with screen displays is available on
http://jp-andre.pagesperso-orange.fr/ntfsusermap.html
.SH EXIT CODES
.B ntfsusermap
exits with a value of 0 when no error was detected, and with a value
@ -72,7 +70,7 @@ of 1 when an error was detected.
Please see
.RS
.sp
http://www.tuxera.com/community/ntfs-3g-faq/
https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ/
.sp
.RE
for common questions and known issues.

View File

@ -126,7 +126,7 @@ is part of the
package and is available from:
.br
.nh
http://www.tuxera.com/community/
https://github.com/tuxera/ntfs-3g/wiki/
.hy
.SH SEE ALSO
.BR ntfs-3g (8),

View File

@ -779,7 +779,7 @@ static s64 wipe_attribute(ntfs_volume *vol, int byte, enum action act,
if (!offset)
return 0;
if (!le16_andz(na->data_flags, ATTR_IS_ENCRYPTED))
if (na->data_flags & ATTR_IS_ENCRYPTED)
offset = (((offset - 1) >> 10) + 1) << 10;
size = (vol->cluster_size - offset) % vol->cluster_size;
@ -839,7 +839,7 @@ static s64 wipe_attr_tail(ntfs_inode *ni, ntfschar *name, int namelen,
goto close_attr;
}
if (!le16_andz(na->data_flags, ATTR_COMPRESSION_MASK))
if (na->data_flags & ATTR_COMPRESSION_MASK)
wiped = wipe_compressed_attribute(vol, byte, act, na);
else
wiped = wipe_attribute(vol, byte, act, na);
@ -899,7 +899,7 @@ static s64 wipe_tails(ntfs_volume *vol, int byte, enum action act)
continue;
}
if (!le64_cmpz(ni->mrec->base_mft_record)) {
if (ni->mrec->base_mft_record) {
ntfs_log_verbose("Not base mft record. Skipping\n");
goto close_inode;
}
@ -914,7 +914,7 @@ static s64 wipe_tails(ntfs_volume *vol, int byte, enum action act)
NULL, 0, ctx)) {
a = ctx->attr;
if (!ctx->al_entry || sle64_cmpz(ctx->al_entry->lowest_vcn)) {
if (!ctx->al_entry || !ctx->al_entry->lowest_vcn) {
name = (ntfschar*)((u8*)a
+ le16_to_cpu(a->name_offset));
attr_wiped = wipe_attr_tail(ni, name,
@ -1271,7 +1271,7 @@ static s64 wipe_directory(ntfs_volume *vol, int byte, enum action act)
continue;
}
if (!le64_cmpz(ni->mrec->base_mft_record)) {
if (ni->mrec->base_mft_record) {
if (opts.verbose > 2)
ntfs_log_verbose("Not base mft record. Skipping\n");
else
@ -2174,7 +2174,7 @@ int main(int argc, char *argv[])
if (!vol)
goto free;
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY) && !opts.force)
if ((vol->flags & VOLUME_IS_DIRTY) && !opts.force)
goto umount;
if (opts.info) {

View File

@ -188,30 +188,30 @@ static BOOL valid_type(ATTR_TYPES type)
{
BOOL ok;
if (le32_eq(type, AT_STANDARD_INFORMATION) ||
le32_eq(type, AT_ATTRIBUTE_LIST) ||
le32_eq(type, AT_FILE_NAME) ||
le32_eq(type, AT_OBJECT_ID) ||
le32_eq(type, AT_SECURITY_DESCRIPTOR) ||
le32_eq(type, AT_VOLUME_NAME) ||
le32_eq(type, AT_VOLUME_INFORMATION) ||
le32_eq(type, AT_DATA) ||
le32_eq(type, AT_INDEX_ROOT) ||
le32_eq(type, AT_INDEX_ALLOCATION) ||
le32_eq(type, AT_BITMAP) ||
le32_eq(type, AT_REPARSE_POINT) ||
le32_eq(type, AT_EA_INFORMATION) ||
le32_eq(type, AT_EA) ||
le32_eq(type, AT_PROPERTY_SET) ||
le32_eq(type, AT_LOGGED_UTILITY_STREAM) ||
le32_eq(type, AT_FIRST_USER_DEFINED_ATTRIBUTE) ||
le32_eq(type, AT_END))
{
switch (type) {
case AT_STANDARD_INFORMATION :
case AT_ATTRIBUTE_LIST :
case AT_FILE_NAME :
case AT_OBJECT_ID :
case AT_SECURITY_DESCRIPTOR :
case AT_VOLUME_NAME :
case AT_VOLUME_INFORMATION :
case AT_DATA :
case AT_INDEX_ROOT :
case AT_INDEX_ALLOCATION :
case AT_BITMAP :
case AT_REPARSE_POINT :
case AT_EA_INFORMATION :
case AT_EA :
case AT_PROPERTY_SET :
case AT_LOGGED_UTILITY_STREAM :
case AT_FIRST_USER_DEFINED_ATTRIBUTE :
case AT_END :
ok = TRUE;
}
else {
break;
default :
ok = FALSE;
/* break; */
break;
}
return (ok);
}
@ -276,7 +276,7 @@ static int sanity_indx_list(const char *buffer, u32 k, u32 end)
err = 1;
}
}
done = !le16_andz(feedle16(buffer,k+12), INDEX_ENTRY_END) || !lth;
done = (feedle16(buffer,k+12) & INDEX_ENTRY_END) || !lth;
if (lth & 7) {
if (optv <= 1) /* Do not repeat the warning */
printf("** Invalid index record length %d\n",
@ -321,7 +321,7 @@ static int sanity_mft(const char *buffer)
attr = (const ATTR_RECORD*)&buffer[k];
prevtype = 0;
while ((k < mftrecsz)
&& !le32_eq(attr->type, AT_END)
&& (attr->type != AT_END)
&& valid_type(attr->type)) {
type = le32_to_cpu(attr->type);
if (type < prevtype) {
@ -345,7 +345,7 @@ static int sanity_mft(const char *buffer)
instances |= (u64)1 << instance;
}
if (optv > 1) {
if (le32_eq(attr->type, AT_FILE_NAME)
if ((attr->type == AT_FILE_NAME)
&& buffer[k + 88]) {
printf("attr %08lx offs 0x%x nres %d",
(long)type, (int)k,
@ -357,7 +357,7 @@ static int sanity_mft(const char *buffer)
(long)type, (int)k,
(int)attr->non_resident);
}
if (le32_eq(attr->type, AT_INDEX_ROOT)
if ((attr->type == AT_INDEX_ROOT)
&& sanity_indx_list(buffer,
k + le16_to_cpu(attr->value_offset) + 32,
k + le32_to_cpu(attr->length))) {
@ -367,10 +367,10 @@ static int sanity_mft(const char *buffer)
attr = (const ATTR_RECORD*)&buffer[k];
prevtype = type;
}
if ((optv > 1) && le32_eq(attr->type, AT_END))
if ((optv > 1) && (attr->type == AT_END))
printf("attr %08lx offs 0x%x\n",
(long)le32_to_cpu(attr->type), (int)k);
if (!le32_eq(attr->type, AT_END)
if ((attr->type != AT_END)
|| (le32_to_cpu(record->bytes_in_use) != (k + 8))
|| (le32_to_cpu(record->bytes_allocated) < (k + 8))) {
printf("** Bad MFT record length %ld"
@ -773,7 +773,7 @@ static void adjust_instance(const ATTR_RECORD *attr, MFT_RECORD *entry, int incr
if (increment > 0) {
/* Allocating a new instance ? */
if (le16_eq(attr->instance, entry->next_attr_instance)) {
if (attr->instance == entry->next_attr_instance) {
instance = (le16_to_cpu(entry->next_attr_instance)
+ 1) & 0xffff;
entry->next_attr_instance = cpu_to_le16(instance);
@ -783,7 +783,7 @@ static void adjust_instance(const ATTR_RECORD *attr, MFT_RECORD *entry, int incr
/* Freeing the latest instance ? */
instance = (le16_to_cpu(entry->next_attr_instance)
- 1) & 0xffff;
if (le16_eq(attr->instance, cpu_to_le16(instance)))
if (attr->instance == cpu_to_le16(instance))
entry->next_attr_instance = attr->instance;
}
}
@ -846,7 +846,7 @@ static BOOL index_match_undo(const char *first, const char *second, int length)
dump(second,length);
}
len = (first[80] & 255)*2 + 2;
match = le64_eq(feedle64(first, 16), feedle64(second, 16))
match = (feedle64(first, 16) == feedle64(second, 16))
&& !memcmp(first + 80, second + 80, len);
if (match && optv)
printf("However parent dir and name do match\n");
@ -869,7 +869,7 @@ static int change_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
int changed;
err = 1;
if (!le16_eq(action->record.undo_length, action->record.redo_length))
if (action->record.undo_length != action->record.redo_length)
printf("** Error size change in change_resident\n");
if (optv > 1) {
lcn = sle64_to_cpu(action->record.lcn_list[0]);
@ -923,7 +923,7 @@ static int change_resident_expect(ntfs_volume *vol, const struct ACTION_RECORD *
BOOL found;
err = 1;
if (!le16_eq(action->record.undo_length, action->record.redo_length))
if (action->record.undo_length != action->record.redo_length)
printf("** Error size change in change_resident\n");
if (optv > 1) {
lcn = sle64_to_cpu(action->record.lcn_list[0]);
@ -939,7 +939,7 @@ static int change_resident_expect(ntfs_volume *vol, const struct ACTION_RECORD *
printf("-> full record :\n");
dump((char*)attr, le32_to_cpu(attr->length));
}
if (le32_eq(attr->type, type)
if ((attr->type == type)
&& !(length & 7)
&& ((target + length) <= mftrecsz)) {
found = !memcmp(buffer + target, expected, length);
@ -1223,15 +1223,15 @@ static int insert_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
newused = le32_to_cpu(entry->bytes_in_use)
+ length;
entry->bytes_in_use = cpu_to_le32(newused);
if (le16_eq(action->record.redo_operation,
const_cpu_to_le16(CreateAttribute))) {
if (action->record.redo_operation
== const_cpu_to_le16(CreateAttribute)) {
/*
* For a real create, may have to adjust
* the next attribute instance
*/
adjust_instance(newattr, entry, 1);
}
if (le32_eq(newattr->type, AT_FILE_NAME)) {
if (newattr->type == AT_FILE_NAME) {
links = le16_to_cpu(entry->link_count) + 1;
entry->link_count = cpu_to_le16(links);
}
@ -1286,7 +1286,7 @@ static int remove_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
&& ((target + length) <= mftrecsz)) {
/* This has to be an idempotent action */
/* For AT_DATA the value is not always present */
if (le32_eq(attr->type, AT_DATA))
if (attr->type == AT_DATA)
found = !memcmp(buffer + target, data,
le16_to_cpu(attr->value_offset));
else
@ -1307,12 +1307,12 @@ static int remove_resident(ntfs_volume *vol, const struct ACTION_RECORD *action,
}
err = 0;
if (found) {
if (le32_eq(attr->type, AT_FILE_NAME)) {
if (attr->type == AT_FILE_NAME) {
links = le16_to_cpu(entry->link_count) - 1;
entry->link_count = cpu_to_le16(links);
}
if (le16_eq(action->record.redo_operation,
const_cpu_to_le16(CreateAttribute))) {
if (action->record.redo_operation
== const_cpu_to_le16(CreateAttribute)) {
adjust_instance(attr, entry, -1);
}
/* Remove the entry */
@ -1503,7 +1503,7 @@ static int update_index(ntfs_volume *vol, const struct ACTION_RECORD *action,
printf("-> existing index :\n");
dump(&buffer[target], length);
}
if (le32_eq(indx->magic, magic_INDX)
if ((indx->magic == magic_INDX)
&& !(length & 7)
&& ((target + length) <= xsize)) {
/* This has to be an idempotent action */
@ -1547,7 +1547,7 @@ static int delete_names(char *buffer)
do {
attr = (ATTR_RECORD*)&buffer[pos];
length = le32_to_cpu(attr->length);
if (le32_eq(attr->type, AT_FILE_NAME)) {
if (attr->type == AT_FILE_NAME) {
if (optv)
showname("Controversial deletion of ",
&buffer[pos+90], buffer[pos+88] & 255);
@ -1634,7 +1634,7 @@ static int insert_index_allocation(ntfs_volume *vol, char *buffer, u32 offs)
length = le32_to_cpu(attr->length);
addedlength = length - 8 /* index allocation */
+ length - 48; /* bitmap */
if (le32_eq(attr->type, AT_INDEX_ROOT)
if ((attr->type == AT_INDEX_ROOT)
&& ((pos + length) == offs)
&& ((used + addedlength) < mftrecsz)) {
/* Make space for the attribute */
@ -1722,9 +1722,9 @@ static BOOL check_full_mft(const struct ACTION_RECORD *action, BOOL redoing)
length = le16_to_cpu(action->record.undo_length);
}
/* The length in use must be fed */
ok = le16_cmpz(action->record.record_offset)
&& le16_cmpz(action->record.attribute_offset)
&& le32_eq(record->magic, magic_FILE)
ok = !action->record.record_offset
&& !action->record.attribute_offset
&& (record->magic == magic_FILE)
&& (length <= mftrecsz)
&& (length >= (offsetof(MFT_RECORD, bytes_in_use)
+ sizeof(record->bytes_in_use)));
@ -1732,14 +1732,14 @@ static BOOL check_full_mft(const struct ACTION_RECORD *action, BOOL redoing)
k = le16_to_cpu(record->attrs_offset);
attr = (const ATTR_RECORD*)((const char*)record + k);
while (((k + sizeof(attr->type)) <= length)
&& !le32_eq(attr->type, AT_END)
&& (attr->type != AT_END)
&& valid_type(attr->type)) {
k += le32_to_cpu(attr->length);
attr = (const ATTR_RECORD*)((const char*)record + k);
}
/* AT_END must be present */
ok = ((k + sizeof(attr->type)) <= length)
&& le32_eq(attr->type, AT_END);
&& (attr->type == AT_END);
}
return (ok);
}
@ -1765,9 +1765,9 @@ static BOOL check_full_index(const struct ACTION_RECORD *action, BOOL redoing)
length = le16_to_cpu(action->record.undo_length);
}
/* the index length must be fed, so must be the full index block */
return (le16_cmpz(action->record.record_offset)
&& le16_cmpz(action->record.attribute_offset)
&& le32_eq(indx->magic, magic_INDX)
return (!action->record.record_offset
&& !action->record.attribute_offset
&& (indx->magic == magic_INDX)
&& (length >= (offsetof(INDEX_BLOCK, index.index_length) + 4))
&& (length >= (le32_to_cpu(indx->index.index_length) + 24)));
}
@ -1890,7 +1890,7 @@ static int redo_add_index(ntfs_volume *vol, const struct ACTION_RECORD *action,
printf("-> existing record :\n");
dump(&buffer[target], length);
}
if (le32_eq(indx->magic, magic_INDX)
if ((indx->magic == magic_INDX)
&& !(length & 7)
&& ((target + length) <= xsize)) {
/* This has to be an idempotent action */
@ -1956,7 +1956,7 @@ static int redo_add_root_index(ntfs_volume *vol,
printf("existing index :\n");
dump(buffer + target,length);
}
if (le32_eq(attr->type, AT_INDEX_ROOT)
if ((attr->type == AT_INDEX_ROOT)
&& !(length & 7)
&& ((target + length) <= mftrecsz)) {
/* This has to be an idempotent action */
@ -2033,9 +2033,9 @@ static int redo_create_file(ntfs_volume *vol,
if ((target + length) <= mftrecsz) {
changed = memcmp(buffer + target, data, length);
err = 0;
if (changed || le16_andz(record->flags, MFT_RECORD_IN_USE)) {
if (changed || !(record->flags & MFT_RECORD_IN_USE)) {
memcpy(buffer + target, data, length);
record->flags = le16_or(record->flags, MFT_RECORD_IN_USE);
record->flags |= MFT_RECORD_IN_USE;
if (optv > 1) {
printf("-> new record :\n");
dump(buffer,mftrecsz);
@ -2070,7 +2070,7 @@ static int redo_create_attribute(ntfs_volume *vol,
target = le16_to_cpu(action->record.record_offset)
+ le16_to_cpu(action->record.attribute_offset);
// Could also be AT_DATA or AT_INDEX_ALLOCATION
if (le16_cmpz(action->record.undo_length))
if (!action->record.undo_length)
err = insert_resident(vol, action, buffer, data,
target, length);
return (err);
@ -2092,7 +2092,7 @@ static int redo_delete_attribute(ntfs_volume *vol,
length = le16_to_cpu(action->record.undo_length);
target = le16_to_cpu(action->record.record_offset)
+ le16_to_cpu(action->record.attribute_offset);
if (le16_cmpz(action->record.redo_length))
if (!action->record.redo_length)
err = remove_resident(vol, action, buffer, data,
target, length);
return (err);
@ -2131,11 +2131,11 @@ static int redo_delete_file(ntfs_volume *vol,
if ((target + length) <= mftrecsz) {
/* write a void mft entry (needed ?) */
changed = (length && memcmp(buffer + target, data, length))
|| !le16_andz(record->flags, MFT_RECORD_IN_USE);
|| (record->flags & MFT_RECORD_IN_USE);
err = 0;
if (changed) {
memcpy(buffer + target, data, length);
record->flags = le16_and(record->flags, le16_not(MFT_RECORD_IN_USE));
record->flags &= ~MFT_RECORD_IN_USE;
if (optv > 1) {
printf("-> new record :\n");
dump(buffer,mftrecsz);
@ -2184,7 +2184,7 @@ static int redo_delete_index(ntfs_volume *vol,
printf("-> existing record :\n");
dump(&buffer[target], length);
}
if (le32_eq(indx->magic, magic_INDX)
if ((indx->magic == magic_INDX)
&& !(length & 7)
&& ((target + length) <= xsize)) {
/* This has to be an idempotent action */
@ -2248,7 +2248,7 @@ static int redo_delete_root_index(ntfs_volume *vol,
printf("existing index :\n");
dump(buffer + target,length);
}
if (le32_eq(attr->type, AT_INDEX_ROOT)
if ((attr->type == AT_INDEX_ROOT)
&& !(length & 7)
&& ((target + length) <= mftrecsz)) {
/* This has to be an idempotent action */
@ -2297,8 +2297,8 @@ static int redo_force_bits(ntfs_volume *vol,
+ get_redo_offset(&action->record));
firstbit = le32_to_cpu(data->firstbit);
count = le32_to_cpu(data->count);
if (le16_eq(action->record.redo_operation,
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
if (action->record.redo_operation
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
wanted = 1;
else
wanted = 0;
@ -2342,7 +2342,7 @@ static int redo_open_attribute(ntfs_volume *vol __attribute__((unused)),
+ get_redo_offset(&action->record);
length = le16_to_cpu(action->record.redo_length);
extra = get_extra_offset(&action->record);
if (!le16_cmpz(action->record.undo_length)) {
if (action->record.undo_length) {
name = ((const char*)&action->record) + extra;
namelen = le32_to_cpu(action->record.client_data_length)
+ LOG_RECORD_HEAD_SZ - extra;
@ -2371,13 +2371,13 @@ static int redo_open_attribute(ntfs_volume *vol __attribute__((unused)),
/* Badly aligned */
memcpy(&inode, &attr_old->inode, 8);
err = (MREF(le64_to_cpu(inode)) != pa->inode)
|| !le32_eq(attr_old->type, pa->type);
|| (attr_old->type != pa->type);
break;
case sizeof(ATTR_NEW) :
attr_new = (const ATTR_NEW*)data;
err = (MREF(le64_to_cpu(attr_new->inode))
!= pa->inode)
|| !le32_eq(attr_new->type, pa->type);
|| (attr_new->type != pa->type);
break;
default : err = 1;
}
@ -2868,14 +2868,14 @@ static int redo_write_index(ntfs_volume *vol,
}
xsize = vol->indx_record_size;
indx = (INDEX_BLOCK*)buffer;
if (!le16_cmpz(action->record.record_offset)) {
if (action->record.record_offset) {
printf("** Non-null record_offset in redo_write_index()\n");
}
if (optv > 1) {
printf("-> existing index :\n");
dump(&buffer[target], length);
}
if (le32_eq(indx->magic, magic_INDX)
if ((indx->magic == magic_INDX)
&& !(length & 7)
&& ((target + length) <= xsize)) {
/* This has to be an idempotent action */
@ -2962,7 +2962,7 @@ static int undo_add_index(ntfs_volume *vol,
printf("-> existing record :\n");
dump(&buffer[target], length);
}
if (le32_eq(indx->magic, magic_INDX)
if ((indx->magic == magic_INDX)
&& !(length & 7)
&& ((target + length) <= xsize)) {
/* This has to be an idempotent action */
@ -3027,7 +3027,7 @@ static int undo_add_root_index(ntfs_volume *vol,
printf("existing index :\n");
dump(buffer + target,length);
}
if (le32_eq(attr->type, AT_INDEX_ROOT)
if ((attr->type == AT_INDEX_ROOT)
&& !(length & 7)
&& ((target + length) <= mftrecsz)) {
/* This has to be an idempotent action */
@ -3070,7 +3070,7 @@ static int undo_create_attribute(ntfs_volume *vol,
length = le16_to_cpu(action->record.redo_length);
target = le16_to_cpu(action->record.record_offset)
+ le16_to_cpu(action->record.attribute_offset);
if (le16_cmpz(action->record.undo_length))
if (!action->record.undo_length)
err = remove_resident(vol, action, buffer, data,
target, length);
return (err);
@ -3092,7 +3092,7 @@ static int undo_delete_attribute(ntfs_volume *vol,
length = le16_to_cpu(action->record.undo_length);
target = le16_to_cpu(action->record.record_offset)
+ le16_to_cpu(action->record.attribute_offset);
if (le16_cmpz(action->record.redo_length))
if (!action->record.redo_length)
err = insert_resident(vol, action, buffer, data,
target, length);
return (err);
@ -3132,7 +3132,7 @@ static int undo_delete_index(ntfs_volume *vol,
printf("-> existing record :\n");
dump(&buffer[target], length);
}
if (le32_eq(indx->magic, magic_INDX)
if ((indx->magic == magic_INDX)
&& !(length & 7)
&& ((target + length) <= xsize)
&& !sanity_indx(vol,buffer)) {
@ -3197,7 +3197,7 @@ static int undo_delete_root_index(ntfs_volume *vol,
+ le16_to_cpu(action->record.record_offset));
index = (INDEX_ROOT*)(((char*)attr)
+ le16_to_cpu(attr->value_offset));
if (!le32_eq(attr->type, AT_INDEX_ROOT)) {
if (attr->type != AT_INDEX_ROOT) {
printf("** Unexpected attr type 0x%lx\n",
(long)le32_to_cpu(attr->type));
printf("existing mft\n");
@ -3209,7 +3209,7 @@ static int undo_delete_root_index(ntfs_volume *vol,
printf("existing index :\n");
dump(buffer + target,length);
}
if (le32_eq(attr->type, AT_INDEX_ROOT)
if ((attr->type == AT_INDEX_ROOT)
&& !(length & 7)
&& ((target + length) <= mftrecsz)) {
/* This has to be an idempotent action */
@ -3272,9 +3272,9 @@ static int undo_create_file(ntfs_volume *vol,
if ((target + length) <= mftrecsz) {
changed = memcmp(buffer + target, data, length);
err = 0;
if (changed || !le16_andz(record->flags, MFT_RECORD_IN_USE)) {
if (changed || (record->flags & MFT_RECORD_IN_USE)) {
memcpy(buffer + target, data, length);
record->flags = le16_and(record->flags, le16_not(MFT_RECORD_IN_USE));
record->flags &= ~MFT_RECORD_IN_USE;
if (optv > 1) {
printf("-> new record :\n");
dump(buffer,mftrecsz);
@ -3322,7 +3322,7 @@ static int undo_delete_file(ntfs_volume *vol,
record = (MFT_RECORD*)buffer;
if ((target + length) <= mftrecsz) {
changed = memcmp(buffer + target, data, length)
|| le16_andz(record->flags, MFT_RECORD_IN_USE);
|| !(record->flags & MFT_RECORD_IN_USE);
err = 0;
if (changed) {
memcpy(buffer + target, data, length);
@ -3338,10 +3338,10 @@ static int undo_delete_file(ntfs_volume *vol,
* the record now appears to not be in use and there are
* links.
*/
if (!le16_cmpz(record->link_count)
&& le16_andz(record->flags, MFT_RECORD_IN_USE))
if (record->link_count
&& !(record->flags & MFT_RECORD_IN_USE))
err = delete_names(buffer);
record->flags = le16_or(record->flags, MFT_RECORD_IN_USE);
record->flags |= MFT_RECORD_IN_USE;
if (optv > 1) {
printf("-> new record :\n");
dump(buffer,mftrecsz);
@ -3378,8 +3378,8 @@ static int undo_force_bits(ntfs_volume *vol,
+ get_redo_offset(&action->record));
firstbit = le32_to_cpu(data->firstbit);
count = le32_to_cpu(data->count);
if (le16_eq(action->record.redo_operation,
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
if (action->record.redo_operation
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
wanted = 0;
else
wanted = 1;
@ -3423,7 +3423,7 @@ static int undo_open_attribute(ntfs_volume *vol __attribute__((unused)),
+ get_redo_offset(&action->record);
length = le16_to_cpu(action->record.redo_length);
extra = get_extra_offset(&action->record);
if (!le16_cmpz(action->record.undo_length)) {
if (action->record.undo_length) {
name = ((const char*)&action->record) + extra;
namelen = le32_to_cpu(action->record.client_data_length)
+ LOG_RECORD_HEAD_SZ - extra;
@ -3448,12 +3448,12 @@ static int undo_open_attribute(ntfs_volume *vol __attribute__((unused)),
/* Badly aligned */
memcpy(&inode, &attr_old->inode, 8);
err = (MREF(le64_to_cpu(inode)) != pa->inode)
|| !le32_eq(attr_old->type, pa->type);
|| (attr_old->type != pa->type);
break;
case sizeof(ATTR_NEW) :
attr_new = (const ATTR_NEW*)data;
err = (MREF(le64_to_cpu(attr_new->inode))!= pa->inode)
|| !le32_eq(attr_new->type, pa->type);
|| (attr_new->type != pa->type);
break;
default : err = 1;
}
@ -3493,14 +3493,14 @@ static int undo_sizes(ntfs_volume *vol,
+ le16_to_cpu(action->record.attribute_offset)
+ offsetof(ATTR_RECORD, allocated_size);
entry = (MFT_RECORD*)buffer;
if (le16_andz(entry->flags, MFT_RECORD_IS_DIRECTORY))
if (!(entry->flags & MFT_RECORD_IS_DIRECTORY))
err = change_resident(vol, action, buffer,
data, target, length);
else {
/* On a directory, may have to build an index allocation */
offs = le16_to_cpu(action->record.record_offset);
attr = (ATTR_RECORD*)(buffer + offs);
if (!le32_eq(attr->type, AT_INDEX_ALLOCATION)) {
if (attr->type != AT_INDEX_ALLOCATION) {
err = insert_index_allocation(vol, buffer, offs);
if (!err)
err = change_resident(vol, action, buffer,
@ -4022,13 +4022,12 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
* Unfortunately, only on some cases we can determine
* the action was defined by Win10 (or subsequent).
*/
if (!le16_andz(action->record.log_record_flags,
le16_or(LOG_RECORD_DELETING, LOG_RECORD_ADDING))) {
if (!le16_andz(action->record.attribute_flags, ACTS_ON_INDX))
if (action->record.log_record_flags
& (LOG_RECORD_DELETING | LOG_RECORD_ADDING)) {
if (action->record.attribute_flags & ACTS_ON_INDX)
kind = ON_INDX;
else
if (!le16_andz(action->record.attribute_flags,
ACTS_ON_MFT))
if (action->record.attribute_flags & ACTS_ON_MFT)
kind = ON_MFT;
else
kind = ON_RAW;
@ -4039,7 +4038,7 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
*/
pa = getattrentry(le16_to_cpu(
action->record.target_attribute),0);
if (!pa || le32_cmpz(pa->type)) {
if (!pa || !pa->type) {
/*
* Even when the attribute has not been recorded,
* we can sometimes tell the record does not apply
@ -4051,8 +4050,8 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
*/
data = (const char*)&action->record
+ get_redo_offset(&action->record);
if (!le16_cmpz(action->record.record_offset)
|| (le16_cmpz(action->record.attribute_offset)
if (action->record.record_offset
|| (!action->record.attribute_offset
&& (le16_to_cpu(action->record.redo_length)
>= 4)
&& memcmp(data,"FILE",4)
@ -4066,7 +4065,7 @@ static enum ACTION_KIND get_action_kind(const struct ACTION_RECORD *action)
kind = ON_NONE;
}
} else {
if (le32_eq(pa->type, AT_INDEX_ALLOCATION))
if (pa->type == AT_INDEX_ALLOCATION)
kind = ON_INDX;
else
kind = ON_RAW;
@ -4105,113 +4104,113 @@ static int distribute_redos(ntfs_volume *vol,
uop = le16_to_cpu(action->record.undo_operation);
switch (rop) {
case AddIndexEntryAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(DeleteIndexEntryAllocation)))
if (action->record.undo_operation
== const_cpu_to_le16(DeleteIndexEntryAllocation))
err = redo_add_index(vol, action, buffer);
break;
case AddIndexEntryRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(DeleteIndexEntryRoot)))
if (action->record.undo_operation
== const_cpu_to_le16(DeleteIndexEntryRoot))
err = redo_add_root_index(vol, action, buffer);
break;
case ClearBitsInNonResidentBitMap :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetBitsInNonResidentBitMap))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_force_bits(vol, action, buffer);
break;
case CompensationlogRecord :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = redo_compensate(vol, action, buffer);
break;
case CreateAttribute :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(DeleteAttribute))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(DeleteAttribute))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_create_attribute(vol, action, buffer);
break;
case DeallocateFileRecordSegment :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(InitializeFileRecordSegment))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(InitializeFileRecordSegment))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_delete_file(vol, action, buffer);
break;
case DeleteAttribute :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(CreateAttribute))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(CreateAttribute))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_delete_attribute(vol, action, buffer);
break;
case DeleteIndexEntryAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(AddIndexEntryAllocation))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(AddIndexEntryAllocation))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_delete_index(vol, action, buffer);
break;
case DeleteIndexEntryRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(AddIndexEntryRoot))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(AddIndexEntryRoot))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_delete_root_index(vol, action, buffer);
break;
case InitializeFileRecordSegment :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = redo_create_file(vol, action, buffer);
break;
case OpenNonResidentAttribute :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = redo_open_attribute(vol, action);
break;
case SetBitsInNonResidentBitMap :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(ClearBitsInNonResidentBitMap)))
if (action->record.undo_operation
== const_cpu_to_le16(ClearBitsInNonResidentBitMap))
err = redo_force_bits(vol, action, buffer);
break;
case SetIndexEntryVcnAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetIndexEntryVcnAllocation))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(SetIndexEntryVcnAllocation))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_update_vcn(vol, action, buffer);
break;
case SetIndexEntryVcnRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetIndexEntryVcnRoot)))
if (action->record.undo_operation
== const_cpu_to_le16(SetIndexEntryVcnRoot))
err = redo_update_root_vcn(vol, action, buffer);
break;
case SetNewAttributeSizes :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetNewAttributeSizes))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(SetNewAttributeSizes))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_sizes(vol, action, buffer);
break;
case UpdateFileNameAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateFileNameAllocation))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(UpdateFileNameAllocation))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_update_index(vol, action, buffer);
break;
case UpdateFileNameRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateFileNameRoot))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(UpdateFileNameRoot))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_update_root_index(vol, action, buffer);
break;
case UpdateMappingPairs :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateMappingPairs)))
if (action->record.undo_operation
== const_cpu_to_le16(UpdateMappingPairs))
err = redo_update_mapping(vol, action, buffer);
break;
case UpdateNonResidentValue :
@ -4228,27 +4227,27 @@ static int distribute_redos(ntfs_volume *vol,
}
break;
case UpdateResidentValue :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateResidentValue))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(UpdateResidentValue))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_update_resident(vol, action, buffer);
break;
case Win10Action37 :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = redo_action37(vol, action, buffer);
break;
case WriteEndofFileRecordSegment :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(WriteEndofFileRecordSegment)))
if (action->record.undo_operation
== const_cpu_to_le16(WriteEndofFileRecordSegment))
err = redo_write_end(vol, action, buffer);
break;
case WriteEndOfIndexBuffer :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(WriteEndOfIndexBuffer))
|| le16_eq(action->record.undo_operation,
const_cpu_to_le16(CompensationlogRecord)))
if ((action->record.undo_operation
== const_cpu_to_le16(WriteEndOfIndexBuffer))
|| (action->record.undo_operation
== const_cpu_to_le16(CompensationlogRecord)))
err = redo_write_index(vol, action, buffer);
break;
case AttributeNamesDump :
@ -4389,7 +4388,7 @@ printf("** %s (action %d) not acting on MFT\n",actionname(rop),(int)action->num)
buffer = read_protected(vol, &action->record,
mftrecsz, warn);
entry = (MFT_RECORD*)buffer;
if (entry && le32_eq(entry->magic, magic_FILE)) {
if (entry && (entry->magic == magic_FILE)) {
data_lsn = sle64_to_cpu(entry->lsn);
/*
* Beware of records not updated
@ -4431,7 +4430,7 @@ printf("** %s (action %d) not acting on INDX\n",actionname(rop),(int)action->num
buffer = read_protected(vol, &action->record,
xsize, warn);
indx = (INDEX_BLOCK*)buffer;
if (indx && le32_eq(indx->magic, magic_INDX)) {
if (indx && (indx->magic == magic_INDX)) {
data_lsn = sle64_to_cpu(indx->lsn);
/*
* Beware of records not updated
@ -4461,8 +4460,8 @@ printf("** %s (action %d) not acting on INDX\n",actionname(rop),(int)action->num
}
break;
case ON_RAW :
if (!le16_andz(action->record.attribute_flags,
le16_or(ACTS_ON_INDX, ACTS_ON_MFT))) {
if (action->record.attribute_flags
& (ACTS_ON_INDX | ACTS_ON_MFT)) {
printf("** Error : action %s on MFT"
" or INDX\n",
actionname(rop));
@ -4529,88 +4528,88 @@ static int distribute_undos(ntfs_volume *vol, const struct ACTION_RECORD *action
uop = le16_to_cpu(action->record.undo_operation);
switch (rop) {
case AddIndexEntryAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(DeleteIndexEntryAllocation)))
if (action->record.undo_operation
== const_cpu_to_le16(DeleteIndexEntryAllocation))
err = undo_add_index(vol, action, buffer);
break;
case AddIndexEntryRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(DeleteIndexEntryRoot)))
if (action->record.undo_operation
== const_cpu_to_le16(DeleteIndexEntryRoot))
err = undo_add_root_index(vol, action, buffer);
break;
case ClearBitsInNonResidentBitMap :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetBitsInNonResidentBitMap)))
if (action->record.undo_operation
== const_cpu_to_le16(SetBitsInNonResidentBitMap))
err = undo_force_bits(vol, action, buffer);
break;
case CreateAttribute :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(DeleteAttribute)))
if (action->record.undo_operation
== const_cpu_to_le16(DeleteAttribute))
err = undo_create_attribute(vol, action, buffer);
break;
case DeallocateFileRecordSegment :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(InitializeFileRecordSegment)))
if (action->record.undo_operation
== const_cpu_to_le16(InitializeFileRecordSegment))
err = undo_delete_file(vol, action, buffer);
break;
case DeleteAttribute :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(CreateAttribute)))
if (action->record.undo_operation
== const_cpu_to_le16(CreateAttribute))
err = undo_delete_attribute(vol, action, buffer);
break;
case DeleteIndexEntryAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(AddIndexEntryAllocation)))
if (action->record.undo_operation
== const_cpu_to_le16(AddIndexEntryAllocation))
err = undo_delete_index(vol, action, buffer);
break;
case DeleteIndexEntryRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(AddIndexEntryRoot)))
if (action->record.undo_operation
== const_cpu_to_le16(AddIndexEntryRoot))
err = undo_delete_root_index(vol, action, buffer);
break;
case InitializeFileRecordSegment :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = undo_create_file(vol, action, buffer);
break;
case OpenNonResidentAttribute :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = undo_open_attribute(vol, action);
break;
case SetBitsInNonResidentBitMap :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(ClearBitsInNonResidentBitMap)))
if (action->record.undo_operation
== const_cpu_to_le16(ClearBitsInNonResidentBitMap))
err = undo_force_bits(vol, action, buffer);
break;
case SetIndexEntryVcnAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetIndexEntryVcnAllocation)))
if (action->record.undo_operation
== const_cpu_to_le16(SetIndexEntryVcnAllocation))
err = undo_update_vcn(vol, action, buffer);
break;
case SetIndexEntryVcnRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetIndexEntryVcnRoot)))
if (action->record.undo_operation
== const_cpu_to_le16(SetIndexEntryVcnRoot))
err = undo_update_root_vcn(vol, action, buffer);
break;
case SetNewAttributeSizes :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(SetNewAttributeSizes)))
if (action->record.undo_operation
== const_cpu_to_le16(SetNewAttributeSizes))
err = undo_sizes(vol, action, buffer);
break;
case UpdateFileNameAllocation :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateFileNameAllocation)))
if (action->record.undo_operation
== const_cpu_to_le16(UpdateFileNameAllocation))
err = undo_update_index(vol, action, buffer);
break;
case UpdateFileNameRoot :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateFileNameRoot)))
if (action->record.undo_operation
== const_cpu_to_le16(UpdateFileNameRoot))
err = undo_update_root_index(vol, action, buffer);
break;
case UpdateMappingPairs :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateMappingPairs)))
if (action->record.undo_operation
== const_cpu_to_le16(UpdateMappingPairs))
err = undo_update_mapping(vol, action, buffer);
break;
case UpdateNonResidentValue :
@ -4627,23 +4626,23 @@ static int distribute_undos(ntfs_volume *vol, const struct ACTION_RECORD *action
}
break;
case UpdateResidentValue :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(UpdateResidentValue)))
if (action->record.undo_operation
== const_cpu_to_le16(UpdateResidentValue))
err = undo_update_resident(vol, action, buffer);
break;
case Win10Action37 :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(Noop)))
if (action->record.undo_operation
== const_cpu_to_le16(Noop))
err = undo_action37(vol, action, buffer);
break;
case WriteEndofFileRecordSegment :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(WriteEndofFileRecordSegment)))
if (action->record.undo_operation
== const_cpu_to_le16(WriteEndofFileRecordSegment))
err = undo_write_end(vol, action, buffer);
break;
case WriteEndOfIndexBuffer :
if (le16_eq(action->record.undo_operation,
const_cpu_to_le16(WriteEndOfIndexBuffer)))
if (action->record.undo_operation
== const_cpu_to_le16(WriteEndOfIndexBuffer))
err = undo_write_index(vol, action, buffer);
break;
case AttributeNamesDump :
@ -4768,7 +4767,7 @@ printf("** %s (action %d) not acting on MFT\n",actionname(rop),(int)action->num)
buffer = read_protected(vol, &action->record, mftrecsz, TRUE);
entry = (MFT_RECORD*)buffer;
if (entry) {
if (le32_eq(entry->magic, magic_FILE)) {
if (entry->magic == magic_FILE) {
executed = !older_record(entry,
&action->record);
if (!executed
@ -4808,7 +4807,7 @@ printf("** %s (action %d) not acting on INDX\n",actionname(rop),(int)action->num
buffer = read_protected(vol, &action->record, xsize, TRUE);
indx = (INDEX_BLOCK*)buffer;
if (indx) {
if (le32_eq(indx->magic, magic_INDX)) {
if (indx->magic == magic_INDX) {
executed = !older_record(indx,
&action->record);
if (!executed
@ -4851,8 +4850,8 @@ printf("index lsn 0x%llx is %s than action %d lsn 0x%llx\n",
}
break;
case ON_RAW :
if (!le16_andz(action->record.attribute_flags,
le16_or(ACTS_ON_INDX, ACTS_ON_MFT))) {
if (action->record.attribute_flags
& (ACTS_ON_INDX | ACTS_ON_MFT)) {
printf("** Error : action %s on MFT or INDX\n",
actionname(rop));
err = 1;

View File

@ -37,7 +37,7 @@ void init_system_file_sd(int sys_file_no, u8 **sd_val, int *sd_val_len)
sd = (SECURITY_DESCRIPTOR_RELATIVE*)&sd_array;
sd->revision = 1;
sd->alignment = 0;
sd->control = le16_or(SE_SELF_RELATIVE, SE_DACL_PRESENT);
sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
*sd_val_len = 0x64;
sd->owner = const_cpu_to_le32(0x48);
sd->group = const_cpu_to_le32(0x54);
@ -64,14 +64,14 @@ void init_system_file_sd(int sys_file_no, u8 **sd_val, int *sd_val_len)
switch (sys_file_no) {
case FILE_AttrDef:
case FILE_Boot:
aa_ace->mask = le32_or(SYNCHRONIZE, le32_or(STANDARD_RIGHTS_READ,
le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_READ_EA, FILE_READ_DATA))));
aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_READ |
FILE_READ_ATTRIBUTES | FILE_READ_EA | FILE_READ_DATA;
break;
default:
aa_ace->mask = le32_or(SYNCHRONIZE, le32_or(STANDARD_RIGHTS_WRITE,
le32_or(FILE_WRITE_ATTRIBUTES, le32_or(FILE_READ_ATTRIBUTES,
le32_or(FILE_WRITE_EA, le32_or(FILE_READ_EA, le32_or(FILE_APPEND_DATA,
le32_or(FILE_WRITE_DATA, FILE_READ_DATA))))))));
aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_WRITE |
FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES |
FILE_WRITE_EA | FILE_READ_EA | FILE_APPEND_DATA |
FILE_WRITE_DATA | FILE_READ_DATA;
break;
}
aa_ace->sid.revision = 1;
@ -100,16 +100,16 @@ void init_system_file_sd(int sys_file_no, u8 **sd_val, int *sd_val_len)
switch (sys_file_no) {
case FILE_AttrDef:
case FILE_Boot:
aa_ace->mask = le32_or(SYNCHRONIZE, le32_or(STANDARD_RIGHTS_READ,
le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_READ_EA,
FILE_READ_DATA))));
aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_READ |
FILE_READ_ATTRIBUTES | FILE_READ_EA |
FILE_READ_DATA;
break;
default:
aa_ace->mask = le32_or(SYNCHRONIZE, le32_or(STANDARD_RIGHTS_READ,
le32_or(FILE_WRITE_ATTRIBUTES,
le32_or(FILE_READ_ATTRIBUTES, le32_or(FILE_WRITE_EA,
le32_or(FILE_READ_EA, le32_or(FILE_APPEND_DATA,
le32_or(FILE_WRITE_DATA, FILE_READ_DATA))))))));
aa_ace->mask = SYNCHRONIZE | STANDARD_RIGHTS_READ |
FILE_WRITE_ATTRIBUTES |
FILE_READ_ATTRIBUTES | FILE_WRITE_EA |
FILE_READ_EA | FILE_APPEND_DATA |
FILE_WRITE_DATA | FILE_READ_DATA;
break;
}
aa_ace->sid.revision = 1;
@ -184,7 +184,7 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
sd = (SECURITY_DESCRIPTOR_RELATIVE*)sd_array;
sd->revision = SECURITY_DESCRIPTOR_REVISION;
sd->alignment = 0;
sd->control = le16_or(SE_SELF_RELATIVE, SE_DACL_PRESENT);
sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
sd->owner = const_cpu_to_le32(0x1014);
sd->group = const_cpu_to_le32(0x1020);
sd->sacl = const_cpu_to_le32(0);
@ -203,11 +203,11 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
ace->type = ACCESS_ALLOWED_ACE_TYPE;
ace->flags = 0;
ace->size = const_cpu_to_le16(0x18);
ace->mask = le32_or(STANDARD_RIGHTS_ALL, le32_or(FILE_WRITE_ATTRIBUTES,
le32_or(FILE_LIST_DIRECTORY, le32_or(FILE_WRITE_DATA,
le32_or(FILE_ADD_SUBDIRECTORY, le32_or(FILE_READ_EA, le32_or(FILE_WRITE_EA,
le32_or(FILE_TRAVERSE, le32_or(FILE_DELETE_CHILD,
FILE_READ_ATTRIBUTES)))))))));
ace->mask = STANDARD_RIGHTS_ALL | FILE_WRITE_ATTRIBUTES |
FILE_LIST_DIRECTORY | FILE_WRITE_DATA |
FILE_ADD_SUBDIRECTORY | FILE_READ_EA | FILE_WRITE_EA |
FILE_TRAVERSE | FILE_DELETE_CHILD |
FILE_READ_ATTRIBUTES;
ace->sid.revision = SID_REVISION;
ace->sid.sub_authority_count = 0x02;
/* SECURITY_NT_SID_AUTHORITY (S-1-5) */
@ -248,11 +248,11 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
ace->type = ACCESS_ALLOWED_ACE_TYPE;
ace->flags = 0;
ace->size = const_cpu_to_le16(0x14);
ace->mask = le32_or(STANDARD_RIGHTS_ALL, le32_or(FILE_WRITE_ATTRIBUTES,
le32_or(FILE_LIST_DIRECTORY, le32_or(FILE_WRITE_DATA,
le32_or(FILE_ADD_SUBDIRECTORY, le32_or(FILE_READ_EA, le32_or(FILE_WRITE_EA,
le32_or(FILE_TRAVERSE, le32_or(FILE_DELETE_CHILD,
FILE_READ_ATTRIBUTES)))))))));
ace->mask = STANDARD_RIGHTS_ALL | FILE_WRITE_ATTRIBUTES |
FILE_LIST_DIRECTORY | FILE_WRITE_DATA |
FILE_ADD_SUBDIRECTORY | FILE_READ_EA | FILE_WRITE_EA |
FILE_TRAVERSE | FILE_DELETE_CHILD |
FILE_READ_ATTRIBUTES;
ace->sid.revision = SID_REVISION;
ace->sid.sub_authority_count = 0x01;
/* SECURITY_NT_SID_AUTHORITY (S-1-5) */
@ -289,11 +289,11 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
ace->type = ACCESS_ALLOWED_ACE_TYPE;
ace->flags = 0;
ace->size = const_cpu_to_le16(0x14);
ace->mask = le32_or(SYNCHRONIZE, le32_or(READ_CONTROL, le32_or(DELETE,
le32_or(FILE_WRITE_ATTRIBUTES, le32_or(FILE_READ_ATTRIBUTES,
le32_or(FILE_TRAVERSE, le32_or(FILE_WRITE_EA, le32_or(FILE_READ_EA,
le32_or(FILE_ADD_SUBDIRECTORY, le32_or(FILE_ADD_FILE,
FILE_LIST_DIRECTORY))))))))));
ace->mask = SYNCHRONIZE | READ_CONTROL | DELETE |
FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES |
FILE_TRAVERSE | FILE_WRITE_EA | FILE_READ_EA |
FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE |
FILE_LIST_DIRECTORY;
ace->sid.revision = SID_REVISION;
ace->sid.sub_authority_count = 0x01;
/* SECURITY_NT_SID_AUTHORITY (S-1-5) */
@ -312,7 +312,7 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
ace->flags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE |
INHERIT_ONLY_ACE;
ace->size = const_cpu_to_le16(0x14);
ace->mask = le32_or(GENERIC_READ, le32_or(GENERIC_WRITE, le32_or(GENERIC_EXECUTE, DELETE)));
ace->mask = GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | DELETE;
ace->sid.revision = SID_REVISION;
ace->sid.sub_authority_count = 0x01;
/* SECURITY_NT_SID_AUTHORITY (S-1-5) */
@ -330,8 +330,8 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
ace->type = ACCESS_ALLOWED_ACE_TYPE;
ace->flags = 0;
ace->size = const_cpu_to_le16(0x18);
ace->mask = le32_or(SYNCHRONIZE, le32_or(READ_CONTROL, le32_or(FILE_READ_ATTRIBUTES,
le32_or(FILE_TRAVERSE, le32_or(FILE_READ_EA, FILE_LIST_DIRECTORY)))));
ace->mask = SYNCHRONIZE | READ_CONTROL | FILE_READ_ATTRIBUTES |
FILE_TRAVERSE | FILE_READ_EA | FILE_LIST_DIRECTORY;
ace->sid.revision = SID_REVISION;
ace->sid.sub_authority_count = 0x02;
/* SECURITY_NT_SID_AUTHORITY (S-1-5) */
@ -352,7 +352,7 @@ void init_root_sd(u8 **sd_val, int *sd_val_len)
ace->flags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE |
INHERIT_ONLY_ACE;
ace->size = const_cpu_to_le16(0x18);
ace->mask = le32_or(GENERIC_READ, GENERIC_EXECUTE);
ace->mask = GENERIC_READ | GENERIC_EXECUTE;
ace->sid.revision = SID_REVISION;
ace->sid.sub_authority_count = 0x02;
/* SECURITY_NT_SID_AUTHORITY (S-1-5) */
@ -424,7 +424,7 @@ void init_secure_sds(char *sd_val)
sizeof(SECURITY_DESCRIPTOR_HEADER));
sd->revision = 0x01;
sd->alignment = 0x00;
sd->control = le16_or(SE_SELF_RELATIVE, SE_DACL_PRESENT);
sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
sd->owner = const_cpu_to_le32(0x48);
sd->group = const_cpu_to_le32(0x58);
sd->sacl = const_cpu_to_le32(0x00);
@ -520,7 +520,7 @@ void init_secure_sds(char *sd_val)
sizeof(SECURITY_DESCRIPTOR_HEADER));
sd->revision = 0x01;
sd->alignment = 0x00;
sd->control = le16_or(SE_SELF_RELATIVE, SE_DACL_PRESENT);
sd->control = SE_SELF_RELATIVE | SE_DACL_PRESENT;
sd->owner = const_cpu_to_le32(0x48);
sd->group = const_cpu_to_le32(0x58);
sd->sacl = const_cpu_to_le32(0x00);

View File

@ -303,7 +303,7 @@ ntfs_volume * utils_mount_volume(const char *device, unsigned long flags)
* libntfs-3g does not record whether the volume log file was dirty
* before mount, so we can only warn if the VOLUME_IS_DIRTY flag is set
* in VOLUME_INFORMATION. */
if (!le16_andz(vol->flags, VOLUME_IS_DIRTY)) {
if (vol->flags & VOLUME_IS_DIRTY) {
if (!(flags & NTFS_MNT_RECOVER)) {
ntfs_log_error("%s", dirty_volume_msg);
ntfs_umount(vol, FALSE);
@ -875,7 +875,7 @@ int utils_is_metadata(ntfs_inode *inode)
return 1;
file = inode->mrec;
if (file && !le64_cmpz(file->base_mft_record)) {
if (file && (file->base_mft_record != 0)) {
num = MREF_LE(file->base_mft_record);
if (__metadata(vol, num) == 1)
return 1;
@ -1041,7 +1041,7 @@ int mft_next_record(struct mft_search_ctx *ctx)
mrec = (MFT_RECORD*)NULL;
r = ntfs_file_record_read(ctx->vol,
(MFT_REF) ctx->mft_num, &mrec, NULL);
if (r || !mrec || le64_cmpz(mrec->base_mft_record))
if (r || !mrec || !mrec->base_mft_record)
ntfs_log_error(
"Error reading inode %lld.\n",
(long long)ctx->mft_num);

View File

@ -166,7 +166,7 @@
? 1 : ntfs_allowed_access(scx, ni, type))
#endif
#define set_archive(ni) (ni)->flags = le32_or((ni)->flags, FILE_ATTR_ARCHIVE)
#define set_archive(ni) (ni)->flags |= FILE_ATTR_ARCHIVE
#define INODE(ino) ((ino) == 1 ? (MFT_REF)FILE_root : (MFT_REF)(ino))
/*
@ -262,7 +262,7 @@ static const char *usage_msg =
"\n"
"Copyright (C) 2005-2007 Yura Pakhuchiy\n"
"Copyright (C) 2006-2009 Szabolcs Szakacsits\n"
"Copyright (C) 2007-2021 Jean-Pierre Andre\n"
"Copyright (C) 2007-2022 Jean-Pierre Andre\n"
"Copyright (C) 2009-2020 Erik Larsson\n"
"\n"
"Usage: %s [-o option[,...]] <device|image_file> <mount_point>\n"
@ -300,13 +300,13 @@ static const char *setuid_msg =
"external FUSE library. Either remove the setuid/setgid bit from the binary\n"
"or rebuild NTFS-3G with integrated FUSE support and make it setuid root.\n"
"Please see more information at\n"
"http://tuxera.com/community/ntfs-3g-faq/#unprivileged\n";
"https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n";
static const char *unpriv_fuseblk_msg =
"Unprivileged user can not mount NTFS block devices using the external FUSE\n"
"library. Either mount the volume as root, or rebuild NTFS-3G with integrated\n"
"FUSE support and make it setuid root. Please see more information at\n"
"http://tuxera.com/community/ntfs-3g-faq/#unprivileged\n";
"https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n";
#endif
@ -686,28 +686,28 @@ static int wsl_getstat(ntfs_inode *ni, const REPARSE_POINT *reparse,
res = ntfs_reparse_check_wsl(ni, reparse);
if (!res) {
/* switch (reparse->reparse_tag) { */
if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_AF_UNIX)) {
switch (reparse->reparse_tag) {
case IO_REPARSE_TAG_AF_UNIX :
stbuf->st_mode = S_IFSOCK;
}
else if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_FIFO)) {
break;
case IO_REPARSE_TAG_LX_FIFO :
stbuf->st_mode = S_IFIFO;
}
else if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_CHR)) {
break;
case IO_REPARSE_TAG_LX_CHR :
stbuf->st_mode = S_IFCHR;
res = ntfs_ea_check_wsldev(ni, &rdev);
stbuf->st_rdev = rdev;
}
else if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_BLK)) {
break;
case IO_REPARSE_TAG_LX_BLK :
stbuf->st_mode = S_IFBLK;
res = ntfs_ea_check_wsldev(ni, &rdev);
stbuf->st_rdev = rdev;
}
else {
break;
default :
stbuf->st_size = ntfs_bad_reparse_lth;
stbuf->st_mode = S_IFLNK;
break;
}
/* } */
}
/*
* If the reparse point is not a valid wsl special file
@ -755,11 +755,11 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
withusermapping = (scx->mapping[MAPUSERS] != (struct MAPPING*)NULL);
stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count);
if (ctx->posix_nlink
&& le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT))
&& !(ni->flags & FILE_ATTR_REPARSE_POINT))
stbuf->st_nlink = ntfs_dir_link_cnt(ni);
if (!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
|| !le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if ((ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
|| (ni->flags & FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -831,7 +831,7 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
* also include 2 bytes for padding info
*/
if (ctx->efs_raw
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)
&& (ni->flags & FILE_ATTR_ENCRYPTED)
&& ni->data_size)
stbuf->st_size = ((ni->data_size + 511) & ~511) + 2;
#endif /* HAVE_SETXATTR */
@ -840,14 +840,14 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
* See more on the ntfs-3g-devel list.
*/
stbuf->st_blocks = (ni->allocated_size + 511) >> 9;
if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM)) {
if (ni->flags & FILE_ATTR_SYSTEM) {
na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0);
if (!na) {
stbuf->st_ino = ni->mft_no;
goto nodata;
}
/* Check whether it's Interix FIFO or socket. */
if (le32_andz(ni->flags, FILE_ATTR_HIDDEN)) {
if (!(ni->flags & FILE_ATTR_HIDDEN)) {
/* FIFO. */
if (na->data_size == 0)
stbuf->st_mode = S_IFIFO;
@ -879,7 +879,7 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
ntfs_attr_close(na);
goto exit;
}
if (le64_eq(intx_file->magic, INTX_BLOCK_DEVICE) &&
if (intx_file->magic == INTX_BLOCK_DEVICE &&
na->data_size == (s64)offsetof(
INTX_FILE, device_end)) {
stbuf->st_mode = S_IFBLK;
@ -888,7 +888,7 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
le64_to_cpu(
intx_file->minor));
}
if (le64_eq(intx_file->magic, INTX_CHARACTER_DEVICE) &&
if (intx_file->magic == INTX_CHARACTER_DEVICE &&
na->data_size == (s64)offsetof(
INTX_FILE, device_end)) {
stbuf->st_mode = S_IFCHR;
@ -897,7 +897,7 @@ static int ntfs_fuse_getstat(struct SECURITY_CONTEXT *scx,
le64_to_cpu(
intx_file->minor));
}
if (le64_eq(intx_file->magic, INTX_SYMBOLIC_LINK)) {
if (intx_file->magic == INTX_SYMBOLIC_LINK) {
char *target = NULL;
int len;
@ -1131,7 +1131,7 @@ static void ntfs_fuse_readlink(fuse_req_t req, fuse_ino_t ino)
/*
* Reparse point : analyze as a junction point
*/
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
REPARSE_POINT *reparse;
le32 tag;
int lth;
@ -1171,7 +1171,7 @@ static void ntfs_fuse_readlink(fuse_req_t req, fuse_ino_t ino)
goto exit;
}
/* Sanity checks. */
if (le32_andz(ni->flags, FILE_ATTR_SYSTEM)) {
if (!(ni->flags & FILE_ATTR_SYSTEM)) {
res = -EINVAL;
goto exit;
}
@ -1200,7 +1200,7 @@ static void ntfs_fuse_readlink(fuse_req_t req, fuse_ino_t ino)
goto exit;
}
/* Sanity check. */
if (!le64_eq(intx_file->magic, INTX_SYMBOLIC_LINK)) {
if (intx_file->magic != INTX_SYMBOLIC_LINK) {
res = -EINVAL;
goto exit;
}
@ -1277,7 +1277,7 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx,
#ifndef DISABLE_PLUGINS
/* get emulated type from plugin if available */
ni = ntfs_inode_open(ctx->vol, mref);
if (ni && !le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni && (ni->flags & FILE_ATTR_REPARSE_POINT)) {
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
int res;
@ -1395,7 +1395,7 @@ static void ntfs_fuse_opendir(fuse_req_t req, fuse_ino_t ino,
if (!ntfs_allowed_access(&security,ni,accesstype))
res = -EACCES;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1463,7 +1463,7 @@ static void ntfs_fuse_releasedir(fuse_req_t req,
ni = ntfs_inode_open(ctx->vol, INODE(ino));
if (ni) {
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
memcpy(&ufi, fi, sizeof(ufi));
ufi.fh = fill->fh;
res = CALL_REPARSE_PLUGIN(ni, release,
@ -1524,8 +1524,8 @@ static void ntfs_fuse_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
if (!ni)
err = -errno;
else {
if (!le32_andz(ni->flags,
FILE_ATTR_REPARSE_POINT)) {
if (ni->flags
& FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1613,7 +1613,7 @@ static void ntfs_fuse_open(fuse_req_t req, fuse_ino_t ino,
ni = ntfs_inode_open(ctx->vol, INODE(ino));
if (ni) {
if (le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (!(ni->flags & FILE_ATTR_REPARSE_POINT)) {
na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0);
if (!na) {
res = -errno;
@ -1635,7 +1635,7 @@ static void ntfs_fuse_open(fuse_req_t req, fuse_ino_t ino,
res = -EACCES;
}
#endif
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1653,13 +1653,13 @@ static void ntfs_fuse_open(fuse_req_t req, fuse_ino_t ino,
if ((res >= 0)
&& (fi->flags & (O_WRONLY | O_RDWR))) {
/* mark a future need to compress the last chunk */
if (!le16_andz(na->data_flags, ATTR_COMPRESSION_MASK))
if (na->data_flags & ATTR_COMPRESSION_MASK)
state |= CLOSE_COMPRESSED;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (ctx->efs_raw
&& le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& !(na->data_flags & ATTR_IS_ENCRYPTED)
&& (ni->flags & FILE_ATTR_ENCRYPTED))
state |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
/* mark a future need to update the mtime */
@ -1724,7 +1724,7 @@ static void ntfs_fuse_read(fuse_req_t req, fuse_ino_t ino, size_t size,
res = -errno;
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1750,7 +1750,7 @@ static void ntfs_fuse_read(fuse_req_t req, fuse_ino_t ino, size_t size,
/* limit reads at next 512 byte boundary for encrypted attributes */
if (ctx->efs_raw
&& max_read
&& !le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& (na->data_flags & ATTR_IS_ENCRYPTED)
&& NAttrNonResident(na)) {
max_read = ((na->data_size+511) & ~511) + 2;
}
@ -1805,7 +1805,7 @@ static void ntfs_fuse_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
res = -errno;
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2002,7 +2002,7 @@ static int ntfs_fuse_trunc(struct SECURITY_CONTEXT *scx, fuse_ino_t ino,
errno = EPERM;
goto exit;
}
if (le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (!(ni->flags & FILE_ATTR_REPARSE_POINT)) {
na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0);
if (!na)
goto exit;
@ -2019,7 +2019,7 @@ static int ntfs_fuse_trunc(struct SECURITY_CONTEXT *scx, fuse_ino_t ino,
goto exit;
}
#endif
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2039,7 +2039,7 @@ static int ntfs_fuse_trunc(struct SECURITY_CONTEXT *scx, fuse_ino_t ino,
* zero, which is optimized as creating a hole when possible.
*/
oldsize = na->data_size;
if (!le16_andz(na->data_flags, ATTR_COMPRESSION_MASK)
if ((na->data_flags & ATTR_COMPRESSION_MASK)
&& (size > na->initialized_size)) {
char zero = 0;
if (ntfs_attr_pwrite(na, size - 1, 1, &zero) <= 0)
@ -2413,7 +2413,7 @@ static int ntfs_fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name,
perm & ~security.umask, S_ISDIR(type));
#endif
/* Create object specified in @type. */
if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2465,13 +2465,13 @@ static int ntfs_fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name,
*/
if (ctx->security.mapping[MAPUSERS]) {
#if POSIXACLS
if (le32_cmpz(securid)
if (!securid
&& ntfs_set_inherited_posix(&security, ni,
security.uid, gid,
dir_ni, perm) < 0)
set_fuse_error(&res);
#else
if (le32_cmpz(securid)
if (!securid
&& ntfs_set_owner_mode(&security, ni,
security.uid, gid,
perm & ~security.umask) < 0)
@ -2480,14 +2480,14 @@ static int ntfs_fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name,
}
set_archive(ni);
/* mark a need to compress the end of file */
if (fi && !le32_andz(ni->flags, FILE_ATTR_COMPRESSED)) {
if (fi && (ni->flags & FILE_ATTR_COMPRESSED)) {
state |= CLOSE_COMPRESSED;
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (fi
&& ctx->efs_raw
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& (ni->flags & FILE_ATTR_ENCRYPTED))
state |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
if (fi && ctx->dmtime)
@ -2597,7 +2597,7 @@ static int ntfs_fuse_newlink(fuse_req_t req __attribute__((unused)),
}
/* Do not accept linking to a directory (except for renaming) */
if (e && !le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)) {
if (e && (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
errno = EPERM;
res = -errno;
goto exit;
@ -2627,7 +2627,7 @@ static int ntfs_fuse_newlink(fuse_req_t req __attribute__((unused)),
ntfs_fuse_fill_security_context(req, &security);
#endif
{
if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2741,10 +2741,10 @@ static int ntfs_fuse_rm(fuse_req_t req, fuse_ino_t parent, const char *name,
#if defined(__sun) && defined (__SVR4)
/* on Solaris : deny unlinking directories */
isdir = !le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY);
isdir = ni->mrec->flags & MFT_RECORD_IS_DIRECTORY;
#ifndef DISABLE_PLUGINS
/* get emulated type from plugin if available */
if (!le32_andz((ni->flags, FILE_ATTR_REPARSE_POINT) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
struct stat st;
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2854,7 +2854,7 @@ static int ntfs_fuse_rm(fuse_req_t req, fuse_ino_t parent, const char *name,
goto exit;
}
}
if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -3091,7 +3091,7 @@ static void ntfs_fuse_release(fuse_req_t req, fuse_ino_t ino,
res = -errno;
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -3265,7 +3265,7 @@ static void ntfs_fuse_bmap(fuse_req_t req, fuse_ino_t ino, size_t blocksize,
goto close_inode;
}
if (!le16_andz(na->data_flags, le16_or(ATTR_COMPRESSION_MASK, ATTR_IS_ENCRYPTED))
if ((na->data_flags & (ATTR_COMPRESSION_MASK | ATTR_IS_ENCRYPTED))
|| !NAttrNonResident(na)) {
ret = -EINVAL;
goto close_attr;
@ -3671,7 +3671,7 @@ static void ntfs_fuse_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
rsize = na->data_size;
if (ctx->efs_raw
&& rsize
&& !le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& (na->data_flags & ATTR_IS_ENCRYPTED)
&& NAttrNonResident(na))
rsize = ((na->data_size + 511) & ~511) + 2;
rsize -= position;
@ -3908,7 +3908,7 @@ static void ntfs_fuse_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
res = -errno;
goto exit;
}
if (le32_andz(ni->flags, FILE_ATTR_ARCHIVE)) {
if (!(ni->flags & FILE_ATTR_ARCHIVE)) {
set_archive(ni);
NInoFileNameSetDirty(ni);
}
@ -3943,14 +3943,14 @@ static void ntfs_fuse_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
res = -errno;
else {
if (ctx->efs_raw
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
&& (ni->flags & FILE_ATTR_ENCRYPTED)) {
if (ntfs_efs_fixup_attribute(NULL,na))
res = -errno;
}
}
if (!res) {
ntfs_fuse_update_times(ni, NTFS_UPDATE_CTIME);
if (le32_andz(ni->flags, FILE_ATTR_ARCHIVE)) {
if (!(ni->flags & FILE_ATTR_ARCHIVE)) {
set_archive(ni);
NInoFileNameSetDirty(ni);
}
@ -4149,7 +4149,7 @@ static void ntfs_fuse_removexattr(fuse_req_t req, fuse_ino_t ino, const char *na
}
if (!res) {
ntfs_fuse_update_times(ni, NTFS_UPDATE_CTIME);
if (le32_andz(ni->flags, FILE_ATTR_ARCHIVE)) {
if (!(ni->flags & FILE_ATTR_ARCHIVE)) {
set_archive(ni);
NInoFileNameSetDirty(ni);
}
@ -4398,7 +4398,7 @@ static const char *fuse26_kmod_msg =
" message to disappear then you should upgrade to at least kernel\n"
" version 2.6.20, or request help from your distribution to fix\n"
" the kernel problem. The below web page has more information:\n"
" http://tuxera.com/community/ntfs-3g-faq/#fuse26\n"
" https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n"
"\n";
static void mknod_dev_fuse(const char *dev)

View File

@ -4,7 +4,7 @@
.\" Copyright (c) 2009-2014 Jean-Pierre Andre
.\" This file may be copied under the terms of the GNU Public License.
.\"
.TH NTFS-3G 8 "Mar 2014" "ntfs-3g @VERSION@"
.TH NTFS-3G 8 "Aug 2021" "ntfs-3g @VERSION@"
.SH NAME
ntfs-3g \- Third Generation Read/Write NTFS Driver
.SH SYNOPSIS
@ -35,7 +35,7 @@ It comes in two variants \fBntfs-3g\fR and \fBlowntfs-3g\fR with
a few differences mentioned below in relevant options descriptions.
.PP
The \fIvolume\fR to be mounted can be either a block device or
an image file.
an image file, either by using the mount command or starting the drive.
.SS Windows hibernation and fast restarting
On computers which can be dual-booted into Windows or Linux, Windows has
to be fully shut down before booting into Linux, otherwise the NTFS file
@ -70,7 +70,7 @@ and
.B dmask
options.
.PP
Doing so, Windows users have full access to the files created by
Doing so, all Windows users have full access to the files created by
.B ntfs-3g.
.PP
But, by setting the \fBpermissions\fR option, you can benefit from the full
@ -96,9 +96,9 @@ data stream and can have many named data streams. The size of a file is the
size of its unnamed data stream. By default, \fBntfs-3g\fR will only read
the unnamed data stream.
.PP
By using the options "streams_interface=windows", with the ntfs-3g driver
By using the option \fBstreams_interface=windows\fP, with the ntfs-3g driver
(not possible with lowntfs-3g), you will be able to read any named data
streams, simply by specifying the stream's name after a colon.
streams, simply by specifying the stream name after a colon.
For example:
.RS
.sp
@ -107,45 +107,10 @@ cat some.mp3:artist
.RE
Named data streams act like normal files, so you can read from them, write to
them and even delete them (using rm). You can list all the named data streams
a file has by getting the "ntfs.streams.list" extended attribute.
a file has by getting the \fBntfs.streams.list\fP extended attribute.
.SH OPTIONS
Below is a summary of the options that \fBntfs-3g\fR accepts.
.TP
\fBuid=\fP\fIvalue\fP and \fBgid=\fP\fIvalue\fP
Set the owner and the group of files and directories. The values are numerical.
The defaults are the uid and gid of the current process.
.TP
.BI umask= value
Set the bitmask of the file and directory permissions that are not
present. The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.BI fmask= value
Set the bitmask of the file permissions that are not present.
The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.BI dmask= value
Set the bitmask of the directory permissions that are not
present. The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.BI usermapping= file-name
Use file \fIfile-name\fP as the user mapping file instead of the default
\fB.NTFS-3G/UserMapping\fP. If \fIfile-name\fP defines a full path, the
file must be located on a partition previously mounted. If it defines a
relative path, it is interpreted relative to the root of NTFS partition
being mounted.
.P
.RS
When a user mapping file is defined, the options \fBuid=\fP, \fBgid=\fP,
\fBumask=\fP, \fBfmask=\fP, \fBdmask=\fP and \fBsilent\fP are ignored.
.RE
.TP
.B permissions
Set standard permissions on created files and use standard access control.
This option is set by default when a user mapping file is present.
.TP
.B acl
Enable setting Posix ACLs on created files and use them for access control.
This option is only available on specific builds. It is set by default
@ -153,46 +118,11 @@ when a user mapping file is present and the
.B permissions
mount option is not set.
.TP
.B inherit
When creating a new file, set its initial protections
according to inheritance rules defined in parent directory. These rules
deviate from Posix specifications, but yield a better Windows
compatibility. The \fBpermissions\fR option or a valid user mapping file
is required for this option to be effective.
.TP
.B ro
Mount filesystem read\-only. Useful if Windows is hibernated or the
NTFS journal file is unclean.
.TP
.BI locale= value
This option can be useful when wanting a language specific locale environment.
It is however discouraged as it leads to files with untranslatable chars
to not be visible.
.TP
.B force
This option is obsolete. It has been superseded by the \fBrecover\fR and
\fBnorecover\fR options.
.TP
.B recover
Recover and try to mount a partition which was not unmounted properly by
Windows. The Windows logfile is cleared, which may cause inconsistencies.
Currently this is the default option.
.TP
.B norecover
Do not try to mount a partition which was not unmounted properly by Windows.
.TP
.B ignore_case \fP(only with lowntfs-3g)
Ignore character case when accessing a file (\fBFOO\fR, \fBFoo\fR, \fBfoo\fR,
etc. designate the same file). All files are displayed with lower case in
directory listings.
.TP
.B remove_hiberfile
When the NTFS volume is hibernated, a read-write mount is denied and
a read-only mount is forced. One needs either to resume Windows and
shutdown it properly, or use this option which will remove the Windows
hibernation file. Please note, this means that the saved Windows
session will be completely lost. Use this option under your own
responsibility.
.B allow_other
This option overrides the security measure restricting file access
to the user mounting the filesystem. This option is only
allowed to root, but this restriction can be overridden by
the \fBuser_allow_other\fP option in the /etc/fuse.conf file.
.TP
.B atime, noatime, relatime
The
@ -201,7 +131,7 @@ option updates inode access time for each access.
The
.B noatime
option disables inode access time updates which can speed up
option disables inode access time updates, which can speed up
file operations and prevent sleeping (notebook) disks spinning
up too often thus saving energy and disk lifetime.
@ -217,6 +147,23 @@ this option doesn't break applications that need to know
if a file has been read since the last time it was modified.
This is the default behaviour.
.TP
.B big_writes
This option prevents fuse from splitting write buffers into 4K chunks,
enabling big write buffers to be transferred from the application in a
single step (up to some system limit, generally 128K bytes).
.TP
.B compression
This option enables creating new transparently compressed files in
directories marked for compression. A directory is marked for compression by
setting the bit 11 (value 0x00000800) in its Windows attribute. In such a
directory, new files are created compressed and new subdirectories are
themselves marked for compression. The option and the flag have no effect
on existing files. Currently this is the default option.
.TP
.B debug
Makes ntfs-3g (or lowntfs-3g) to print a lot of debug output from libntfs-3g
and FUSE.
.TP
.B delay_mtime[= value]
Only update the file modification time and the file change time of a file
when it is closed or when the indicated delay since the previous update has
@ -225,22 +172,26 @@ This is mainly useful for big files which are kept open for a long
time and written to without changing their size, such as databases or file
system images mounted as loop.
.TP
.B show_sys_files
Show the metafiles in directory listings. Otherwise the default behaviour is
to hide the metafiles, which are special files used to store the NTFS
structure. Please note that even when this option is specified, "$MFT" may
not be visible due to a glibc bug. Furthermore, irrespectively of
show_sys_files, all files are accessible by name, for example you can always
do
"ls \-l '$UpCase'".
.BI dmask= value
Set the bitmask of the directory permissions that are not
present. The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.B hide_hid_files
Hide the hidden files and directories in directory listings, the hidden files
and directories being the ones whose NTFS attribute have the hidden flag set.
The hidden files will not be selected when using wildcards in commands,
but all files and directories remain accessible by full name, for example you
can always display the Windows trash bin directory by :
"ls \-ld '$RECYCLE.BIN'".
.B efs_raw
This option should only be used in backup or restore situation.
It changes the apparent size of files and the behavior of read and
write operation so that encrypted files can be saved and restored
without being decrypted. The \fBuser.ntfs.efsinfo\fP extended attribute
has also to be saved and restored for the file to be decrypted.
.TP
.BI fmask= value
Set the bitmask of the file permissions that are not present.
The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.B force
This option is obsolete. It has been superseded by the \fBrecover\fR and
\fBnorecover\fR options.
.TP
.B hide_dot_files
Set the hidden flag in the NTFS attribute for created files and directories
@ -250,13 +201,141 @@ they do not appear in Windows directory displays either.
When a file is renamed or linked with a new name, the hidden flag is
adjusted to the latest name.
.TP
.B hide_hid_files
Hide the hidden files and directories in directory listings, the hidden files
and directories being the ones whose NTFS attribute have the hidden flag set.
The hidden files will not be selected when using wildcards in commands,
but all files and directories remain accessible by full name, for example you
can always display the Windows trash bin directory by :
"ls \-ld '$RECYCLE.BIN'".
.TP
.B ignore_case \fP(only with lowntfs-3g)
Ignore character case when accessing a file (\fBFOO\fR, \fBFoo\fR, \fBfoo\fR,
etc. designate the same file). All files are displayed with lower case in
directory listings.
.TP
.B inherit
When creating a new file, set its initial protections
according to inheritance rules defined in parent directory. These rules
deviate from Posix specifications, but yield a better Windows
compatibility. The \fBpermissions\fR (or **acl**) option or a valid user
mapping file is required for this option to be effective.
.TP
.BI locale= value
This option can be useful when wanting a language specific locale environment.
It is however discouraged as it leads to files with untranslatable characters
to not be visible.
.TP
.BI max_read= value
With this option the maximum size of read operations can be set.
The default is infinite. Note that the size of read requests is
limited anyway by the system (usually to 128kbyte).
.TP
.B no_def_opts
By default ntfs-3g acts as if \fBsilent\fP (ignore permission errors when
permissions are not enabled),
\fBallow_other\fP (allow any user to access files) and \fBnonempty\fP
(allow mounting on non-empty directories) were set, and \fBno_def_opts\fP
cancels these default options.
.TP
.B no_detach
Makes ntfs-3g to not detach from terminal and print some debug output.
.TP
.B nocompression
This option disables creating new transparently compressed files in directories
marked for compression. Existing compressed files can still be read and
updated.
.TP
.B norecover
Do not try to mount a partition which was not unmounted properly by Windows.
.TP
.B permissions
Set standard permissions on created files and use standard access control.
This option is set by default when a user mapping file is present.
.TP
.B posix_nlink
Compute the count of hard links of a file or directory according to
the Posix specifications. When this option is not set, a count of 1
the POSIX specifications. When this option is not set, a count of 1
is set for directories, and the short name of files is accounted for.
Using the option entails some penalty as the count is not stored and
has to be computed.
.TP
.B recover
Recover and try to mount a partition which was not unmounted properly by
Windows. The Windows logfile is cleared, which may cause inconsistencies.
Currently this is the default option.
.TP
.B remove_hiberfile
When the NTFS volume is hibernated, a read-write mount is denied and
a read-only mount is forced. One needs either to resume Windows and
shutdown it properly, or use this option which will remove the Windows
hibernation file. Please note, this means that the saved Windows
session will be completely lost. Use this option under your own
responsibility.
.TP
.B ro
Mount the filesystem read\-only. Useful if Windows is hibernated or the
NTFS journal file is unclean.
.TP
.B show_sys_files
Show the metafiles in directory listings. Otherwise the default behaviour is
to hide the metafiles, which are special files used to store the NTFS
structure. Please note that even when this option is specified, "$MFT" may
not be visible due to a glibc bug. Furthermore, irrespectively of
\fBshow_sys_files\fP, all files are accessible by name, for example you can
always do
"ls \-l '$UpCase'".
.TP
.B silent
Do nothing, without returning any error, on chmod and chown operations
and on permission checking errors,
when the \fBpermissions\fR option is not set and no user mapping file
is defined. This option is on by default, and when set off (through option
\fBno_def_opts\fR) ownership and permissions parameters have to be set.
.TP
.BI special_files= mode
This option selects a mode for representing a special file to be created
(symbolic link, socket, fifo, character or block device). The \fImode\fP can
be \fBinterix\fR or \fBwsl\fR, and existing files in either mode are
recognized irrespective of the selected mode. Interix is the traditional
mode, used by default, and wsl is interoperable with Windows WSL, but
it is not compatible with Windows versions earlier than Windows 10.
Neither mode are interoperable with Windows.
.TP
.BI streams_interface= mode
This option controls how the user can access Alternate Data Streams (ADS) or in
other words, named data streams. The \fImode\fP can be set to one of \fBnone\fR,
\fBwindows\fR or \fBxattr\fR. If the option is set to \fBnone\fR, the user
will have no access to the named data streams. If it is set to \fBwindows\fR
(not possible with lowntfs-3g), then the user can access them just like in
Windows (eg. cat file:stream). If it's set to \fBxattr\fR, then the named
data streams are mapped to extended attributes and a user can manipulate them
using \fB{get,set}fattr\fR utilities. The default is \fBxattr\fR.
.TP
\fBuid=\fP\fIvalue\fP and \fBgid=\fP\fIvalue\fP
Set the owner and the group of files and directories. The values are numerical.
The defaults are the uid and gid of the current process.
.TP
.BI umask= value
Set the bitmask of the file and directory permissions that are not
present. The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.BI usermapping= file-name
Use file \fIfile-name\fP as the user mapping file instead of the default
\fB.NTFS-3G/UserMapping\fP. If \fIfile-name\fP defines a full path, the
file must be located on a partition previously mounted. If it defines a
relative path, it is interpreted relative to the root of NTFS partition
being mounted.
.P
.RS
When a user mapping file is defined, the options \fBuid=\fP, \fBgid=\fP,
\fBumask=\fP, \fBfmask=\fP, \fBdmask=\fP and \fBsilent\fP are ignored.
.RE
.TP
.B user_xattr
Same as \fBstreams_interface=\fP\fIxattr\fP.
.TP
.B windows_names
This option prevents files, directories and extended attributes to be
created with a name not allowed by windows, because
@ -277,92 +356,15 @@ with no suffix or followed by a dot.
.sp
Existing such files can still be read (and renamed).
.RE
.TP
.B allow_other
This option overrides the security measure restricting file access
to the user mounting the filesystem. This option is only
allowed to root, but this restriction can be overridden by
the 'user_allow_other' option in the /etc/fuse.conf file.
.TP
.BI max_read= value
With this option the maximum size of read operations can be set.
The default is infinite. Note that the size of read requests is
limited anyway to 32 pages (which is 128kbyte on i386).
.TP
.B silent
Do nothing, without returning any error, on chmod and chown operations
and on permission checking errors,
when the \fBpermissions\fR option is not set and no user mapping file
is defined. This option is on by default, and when set off (through option
\fBno_def_opts\fR) ownership and permissions parameters have to be set.
.TP
.B no_def_opts
By default ntfs-3g acts as if "silent" (ignore permission errors when
permissions are not enabled),
"allow_other" (allow any user to access files) and "nonempty"
(allow mounting on non-empty directories) were set, and "no_def_opts"
cancels these default options.
.TP
.BI streams_interface= value
This option controls how the user can access Alternate Data Streams (ADS) or
in other words, named data streams. It can be set to, one of \fBnone\fR,
\fBwindows\fR or \fBxattr\fR. If the option is set to \fBnone\fR, the user
will have no access to the named data streams. If it is set to \fBwindows\fR
(not possible with lowntfs-3g), then the user can access them just like in
Windows (eg. cat file:stream). If it's set to \fBxattr\fR, then the named
data streams are mapped to xattrs and user can manipulate them using
\fB{get,set}fattr\fR utilities. The default is \fBxattr\fR.
.TP
.B user_xattr
Same as \fBstreams_interface=\fP\fIxattr\fP.
.TP
.BI special_files= value
This option selects a mode for representing a special file to be created
(symbolic link, socket, fifo, character or block device). The mode can
be \fBinterix\fR or \fBwsl\fR, and existing files in either mode are
recognized irrespective of the selected mode. Interix is the traditional
mode, used by default, and wsl is interoperable with Windows WSL, but
it is not compatible with Windows versions earlier than Windows 10.
.TP
.B efs_raw
This option should only be used in backup or restore situation.
It changes the apparent size of files and the behavior of read and
write operation so that encrypted files can be saved and restored
without being decrypted. The \fBuser.ntfs.efsinfo\fP extended attribute
has also to be saved and restored for the file to be decrypted.
.TP
.B compression
This option enables creating new transparently compressed files in
directories marked for compression. A directory is marked for compression by
setting the bit 11 (value 0x00000800) in its Windows attribute. In such a
directory, new files are created compressed and new subdirectories are
themselves marked for compression. The option and the flag have no effect
on existing files. Currently this is the default option.
.TP
.B nocompression
This option disables creating new transparently compressed files in directories
marked for compression. Existing compressed files can still be read and
updated.
.TP
.B big_writes
This option prevents fuse from splitting write buffers into 4K chunks,
enabling big write buffers to be transferred from the application in a
single step (up to some system limit, generally 128K bytes).
.TP
.B debug
Makes ntfs-3g to print a lot of debug output from libntfs-3g and FUSE.
.TP
.B no_detach
Makes ntfs-3g to not detach from terminal and print some debug output.
.SH USER MAPPING
NTFS uses specific ids to record the ownership of files instead of
the \fBuid\fP and \fBgid\fP used by Linux. As a consequence a mapping
between the ids has to be defined for ownerships to be recorded into
NTFS and recognized.
the \fBuid\fP (user id) and \fBgid\fP (group id) used by Linux. As a
consequence a mapping between the ids has to be defined for ownerships
to be recorded into NTFS files and recognized.
.P
By default, this mapping is fetched from the file \fB.NTFS-3G/UserMapping\fP
located in the NTFS partition. The option \fBusermapping=\fP may be used
to define another location. When the option permissions is set and
to define another location. When the option **permissions** is set and
no mapping file is found, a default mapping is used.
.P
Each line in the user mapping file defines a mapping. It is organized
@ -379,15 +381,15 @@ both cases, files created on Linux will appear to Windows as owned by a
foreign user, and files created on Windows will appear to Linux as owned by
root. Just copy the example below and replace the 9 and 10-digit numbers by
any number not greater than 4294967295. The resulting behavior is the same as
the one with the option permission set with no ownership option and no user
mapping file available.
the one with the option \fBpermission\fP set with no ownership option and no
user mapping file available.
.RS
.sp
.B ::S-1-5-21-3141592653-589793238-462643383-10000
.sp
.RE
If a strong interoperation with Windows is needed, the mapping has to be
defined for each user and group known in both system, and the \fBSID\fPs used
defined for each user and group known to both system, and the \fBSID\fPs used
by Windows has to be collected. This will lead to a user mapping file like :
.RS
.sp
@ -454,15 +456,18 @@ manual page.
Please see
.RS
.sp
http://www.tuxera.com/support/
https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ
.sp
.RE
for common questions and known issues.
If you would find a new one in the latest release of
the software then please send an email describing it
in detail. You can contact the
development team on the ntfs\-3g\-devel@lists.sf.net
address.
the software then please post an ntfs-3g issue describing it in detail
so that the development team can be aware of the issue and take care of it:
.RS
.sp
https://github.com/tuxera/ntfs-3g/issues
.sp
.RE
.SH AUTHORS
.B ntfs-3g
was based on and a major improvement to ntfsmount and libntfs which were
@ -472,7 +477,8 @@ Linux-NTFS team developer Szabolcs Szakacsits (szaka@tuxera.com).
.SH THANKS
Several people made heroic efforts, often over five or more
years which resulted the ntfs-3g driver. Most importantly they are
Anton Altaparmakov, Jean-Pierre André, Richard Russon, Szabolcs Szakacsits,
Anton Altaparmakov, Jean-Pierre André, Erik Larsson, Richard Russon,
Szabolcs Szakacsits,
Yura Pakhuchiy, Yuval Fledel, and the author of the groundbreaking FUSE
filesystem development framework, Miklos Szeredi.
.SH SEE ALSO

View File

@ -136,7 +136,7 @@
? 1 : ntfs_allowed_access(scx, ni, type))
#endif
#define set_archive(ni) (ni)->flags = le32_or((ni)->flags, FILE_ATTR_ARCHIVE)
#define set_archive(ni) (ni)->flags |= FILE_ATTR_ARCHIVE
/*
* Call a function from a reparse plugin (variable arguments)
@ -197,7 +197,7 @@ static const char *usage_msg =
"\n"
"Copyright (C) 2005-2007 Yura Pakhuchiy\n"
"Copyright (C) 2006-2009 Szabolcs Szakacsits\n"
"Copyright (C) 2007-2021 Jean-Pierre Andre\n"
"Copyright (C) 2007-2022 Jean-Pierre Andre\n"
"Copyright (C) 2009-2020 Erik Larsson\n"
"\n"
"Usage: %s [-o option[,...]] <device|image_file> <mount_point>\n"
@ -235,13 +235,13 @@ static const char *setuid_msg =
"external FUSE library. Either remove the setuid/setgid bit from the binary\n"
"or rebuild NTFS-3G with integrated FUSE support and make it setuid root.\n"
"Please see more information at\n"
"http://tuxera.com/community/ntfs-3g-faq/#unprivileged\n";
"https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n";
static const char *unpriv_fuseblk_msg =
"Unprivileged user can not mount NTFS block devices using the external FUSE\n"
"library. Either mount the volume as root, or rebuild NTFS-3G with integrated\n"
"FUSE support and make it setuid root. Please see more information at\n"
"http://tuxera.com/community/ntfs-3g-faq/#unprivileged\n";
"https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n";
#endif
@ -744,28 +744,28 @@ static int wsl_getattr(ntfs_inode *ni, const REPARSE_POINT *reparse,
res = ntfs_reparse_check_wsl(ni, reparse);
if (!res) {
/* switch (reparse->reparse_tag) { */
if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_AF_UNIX)) {
switch (reparse->reparse_tag) {
case IO_REPARSE_TAG_AF_UNIX :
stbuf->st_mode = S_IFSOCK;
}
else if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_FIFO)) {
break;
case IO_REPARSE_TAG_LX_FIFO :
stbuf->st_mode = S_IFIFO;
}
else if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_CHR)) {
break;
case IO_REPARSE_TAG_LX_CHR :
stbuf->st_mode = S_IFCHR;
res = ntfs_ea_check_wsldev(ni, &rdev);
stbuf->st_rdev = rdev;
}
else if (le32_eq(reparse->reparse_tag, IO_REPARSE_TAG_LX_BLK)) {
break;
case IO_REPARSE_TAG_LX_BLK :
stbuf->st_mode = S_IFBLK;
res = ntfs_ea_check_wsldev(ni, &rdev);
stbuf->st_rdev = rdev;
}
else {
break;
default :
stbuf->st_size = ntfs_bad_reparse_lth;
stbuf->st_mode = S_IFLNK;
break;
}
/* } */
}
/*
* If the reparse point is not a valid wsl special file
@ -837,13 +837,13 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
#endif
stbuf->st_nlink = le16_to_cpu(ni->mrec->link_count);
if (ctx->posix_nlink
&& le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT))
&& !(ni->flags & FILE_ATTR_REPARSE_POINT))
stbuf->st_nlink = ntfs_dir_link_cnt(ni);
if ((!le16_andz(ni->mrec->flags, MFT_RECORD_IS_DIRECTORY)
|| !le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT))
if (((ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)
|| (ni->flags & FILE_ATTR_REPARSE_POINT))
&& !stream_name_len) {
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -914,7 +914,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
* also include 2 bytes for padding info
*/
if (ctx->efs_raw
&& (!le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& (ni->flags & FILE_ATTR_ENCRYPTED)
&& ni->data_size)
stbuf->st_size = ((ni->data_size + 511) & ~511) + 2;
#endif /* HAVE_SETXATTR */
@ -923,7 +923,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
* See more on the ntfs-3g-devel list.
*/
stbuf->st_blocks = (ni->allocated_size + 511) >> 9;
if (!le32_andz(ni->flags, FILE_ATTR_SYSTEM) || stream_name_len) {
if (ni->flags & FILE_ATTR_SYSTEM || stream_name_len) {
na = ntfs_attr_open(ni, AT_DATA, stream_name,
stream_name_len);
if (!na) {
@ -938,7 +938,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
stbuf->st_blocks = na->allocated_size >> 9;
}
/* Check whether it's Interix FIFO or socket. */
if (le32_andz(ni->flags, FILE_ATTR_HIDDEN) &&
if (!(ni->flags & FILE_ATTR_HIDDEN) &&
!stream_name_len) {
/* FIFO. */
if (na->data_size == 0)
@ -951,7 +951,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
/* encrypted named stream */
/* round size up to next 512 byte boundary */
if (ctx->efs_raw && stream_name_len &&
!le16_andz(na->data_flags, ATTR_IS_ENCRYPTED) &&
(na->data_flags & ATTR_IS_ENCRYPTED) &&
NAttrNonResident(na))
stbuf->st_size = ((na->data_size+511) & ~511)+2;
#endif /* HAVE_SETXATTR */
@ -980,7 +980,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
ntfs_attr_close(na);
goto exit;
}
if (le64_eq(intx_file->magic, INTX_BLOCK_DEVICE) &&
if (intx_file->magic == INTX_BLOCK_DEVICE &&
na->data_size == offsetof(
INTX_FILE, device_end)) {
stbuf->st_mode = S_IFBLK;
@ -989,7 +989,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
le64_to_cpu(
intx_file->minor));
}
if (le64_eq(intx_file->magic, INTX_CHARACTER_DEVICE) &&
if (intx_file->magic == INTX_CHARACTER_DEVICE &&
na->data_size == offsetof(
INTX_FILE, device_end)) {
stbuf->st_mode = S_IFCHR;
@ -998,7 +998,7 @@ static int ntfs_fuse_getattr(const char *org_path, struct stat *stbuf)
le64_to_cpu(
intx_file->minor));
}
if (le64_eq(intx_file->magic, INTX_SYMBOLIC_LINK)) {
if (intx_file->magic == INTX_SYMBOLIC_LINK) {
char *target = NULL;
int len;
@ -1157,7 +1157,7 @@ static int ntfs_fuse_readlink(const char *org_path, char *buf, size_t buf_size)
/*
* Reparse point : analyze as a junction point
*/
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
char *gotlink;
const plugin_operations_t *ops;
@ -1201,7 +1201,7 @@ static int ntfs_fuse_readlink(const char *org_path, char *buf, size_t buf_size)
goto exit;
}
/* Sanity checks. */
if (le32_andz(ni->flags, FILE_ATTR_SYSTEM)) {
if (!(ni->flags & FILE_ATTR_SYSTEM)) {
res = -EINVAL;
goto exit;
}
@ -1230,7 +1230,7 @@ static int ntfs_fuse_readlink(const char *org_path, char *buf, size_t buf_size)
goto exit;
}
/* Sanity check. */
if (!le64_eq(intx_file->magic, INTX_SYMBOLIC_LINK)) {
if (intx_file->magic != INTX_SYMBOLIC_LINK) {
res = -EINVAL;
goto exit;
}
@ -1308,7 +1308,7 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx,
#ifndef DISABLE_PLUGINS
/* get emulated type from plugin if available */
ni = ntfs_inode_open(ctx->vol, mref);
if (ni && !le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni && (ni->flags & FILE_ATTR_REPARSE_POINT)) {
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
int res;
@ -1439,7 +1439,7 @@ static int ntfs_fuse_readdir(const char *path, void *buf,
if (!ni)
return -errno;
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1483,7 +1483,7 @@ static int ntfs_fuse_open(const char *org_path,
return stream_name_len;
ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
if (ni) {
if (le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (!(ni->flags & FILE_ATTR_REPARSE_POINT)) {
na = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_len);
if (!na) {
res = -errno;
@ -1510,7 +1510,7 @@ static int ntfs_fuse_open(const char *org_path,
res = -EACCES;
}
#endif
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1525,13 +1525,13 @@ static int ntfs_fuse_open(const char *org_path,
if ((res >= 0)
&& (fi->flags & (O_WRONLY | O_RDWR))) {
/* mark a future need to compress the last chunk */
if (!le16_andz(na->data_flags, ATTR_COMPRESSION_MASK))
if (na->data_flags & ATTR_COMPRESSION_MASK)
fi->fh |= CLOSE_COMPRESSED;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (ctx->efs_raw
&& le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& !(na->data_flags & ATTR_IS_ENCRYPTED)
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
/* mark a future need to update the mtime */
@ -1575,7 +1575,7 @@ static int ntfs_fuse_read(const char *org_path, char *buf, size_t size,
res = -errno;
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1603,7 +1603,7 @@ static int ntfs_fuse_read(const char *org_path, char *buf, size_t size,
/* limit reads at next 512 byte boundary for encrypted attributes */
if (ctx->efs_raw
&& max_read
&& !le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& (na->data_flags & ATTR_IS_ENCRYPTED)
&& NAttrNonResident(na)) {
max_read = ((na->data_size+511) & ~511) + 2;
}
@ -1663,7 +1663,7 @@ static int ntfs_fuse_write(const char *org_path, const char *buf, size_t size,
res = -errno;
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1749,7 +1749,7 @@ static int ntfs_fuse_release(const char *org_path,
res = -errno;
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1831,7 +1831,7 @@ static int ntfs_fuse_trunc(const char *org_path, off_t size,
goto exit;
}
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -1872,7 +1872,7 @@ static int ntfs_fuse_trunc(const char *org_path, off_t size,
* zero, which is optimized as creating a hole when possible.
*/
oldsize = na->data_size;
if (!le16_andz(na->data_flags, ATTR_COMPRESSION_MASK)
if ((na->data_flags & ATTR_COMPRESSION_MASK)
&& (size > na->initialized_size)) {
char zero = 0;
if (ntfs_attr_pwrite(na, size - 1, 1, &zero) <= 0)
@ -2145,7 +2145,7 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
perm & ~security.umask, S_ISDIR(type));
#endif
/* Create object specified in @type. */
if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2194,13 +2194,13 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
*/
if (ctx->security.mapping[MAPUSERS]) {
#if POSIXACLS
if (le32_cmpz(securid)
if (!securid
&& ntfs_set_inherited_posix(&security, ni,
security.uid, gid,
dir_ni, perm) < 0)
set_fuse_error(&res);
#else
if (le32_cmpz(securid)
if (!securid
&& ntfs_set_owner_mode(&security, ni,
security.uid, gid,
perm & ~security.umask) < 0)
@ -2209,14 +2209,14 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev,
}
set_archive(ni);
/* mark a need to compress the end of file */
if (fi && !le32_andz(ni->flags, FILE_ATTR_COMPRESSED)) {
if (fi && (ni->flags & FILE_ATTR_COMPRESSED)) {
fi->fh |= CLOSE_COMPRESSED;
}
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (fi
&& ctx->efs_raw
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
/* mark a need to update the mtime */
@ -2283,12 +2283,12 @@ static int ntfs_fuse_create_stream(const char *path,
&& fi
&& (fi->flags & (O_WRONLY | O_RDWR))) {
/* mark a future need to compress the last block */
if (!le32_andz(ni->flags, FILE_ATTR_COMPRESSED))
if (ni->flags & FILE_ATTR_COMPRESSED)
fi->fh |= CLOSE_COMPRESSED;
#ifdef HAVE_SETXATTR /* extended attributes interface required */
/* mark a future need to fixup encrypted inode */
if (ctx->efs_raw
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED))
&& (ni->flags & FILE_ATTR_ENCRYPTED))
fi->fh |= CLOSE_ENCRYPTED;
#endif /* HAVE_SETXATTR */
if (ctx->dmtime)
@ -2408,7 +2408,7 @@ static int ntfs_fuse_link(const char *old_path, const char *new_path)
else
#endif
{
if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2497,7 +2497,7 @@ static int ntfs_fuse_rm(const char *org_path)
|| ntfs_allowed_dir_access(&security, org_path, dir_ni, ni,
S_IEXEC + S_IWRITE + S_ISVTX)) {
#endif
if (!le32_andz(dir_ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (dir_ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
const plugin_operations_t *ops;
REPARSE_POINT *reparse;
@ -2969,7 +2969,7 @@ static int ntfs_fuse_bmap(const char *path, size_t blocksize, uint64_t *idx)
goto close_inode;
}
if (!le16_andz(na->data_flags, le16_or(ATTR_COMPRESSION_MASK, ATTR_IS_ENCRYPTED))
if ((na->data_flags & (ATTR_COMPRESSION_MASK | ATTR_IS_ENCRYPTED))
|| !NAttrNonResident(na)) {
ret = -EINVAL;
goto close_attr;
@ -3408,7 +3408,7 @@ static int ntfs_fuse_getxattr(const char *path, const char *name,
rsize = na->data_size;
if (ctx->efs_raw
&& rsize
&& !le16_andz(na->data_flags, ATTR_IS_ENCRYPTED)
&& (na->data_flags & ATTR_IS_ENCRYPTED)
&& NAttrNonResident(na))
rsize = ((na->data_size + 511) & ~511) + 2;
rsize -= position;
@ -3622,7 +3622,7 @@ static int ntfs_fuse_setxattr(const char *path, const char *name,
res = -errno;
goto exit;
}
if (le32_andz(ni->flags, FILE_ATTR_ARCHIVE)) {
if (!(ni->flags & FILE_ATTR_ARCHIVE)) {
set_archive(ni);
NInoFileNameSetDirty(ni);
}
@ -3657,14 +3657,14 @@ static int ntfs_fuse_setxattr(const char *path, const char *name,
res = -errno;
else {
if (ctx->efs_raw
&& !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
&& (ni->flags & FILE_ATTR_ENCRYPTED)) {
if (ntfs_efs_fixup_attribute(NULL,na))
res = -errno;
}
}
if (!res) {
ntfs_fuse_update_times(ni, NTFS_UPDATE_CTIME);
if (le32_andz(ni->flags, FILE_ATTR_ARCHIVE)) {
if (!(ni->flags & FILE_ATTR_ARCHIVE)) {
set_archive(ni);
NInoFileNameSetDirty(ni);
}
@ -3855,7 +3855,7 @@ static int ntfs_fuse_removexattr(const char *path, const char *name)
}
if (!res) {
ntfs_fuse_update_times(ni, NTFS_UPDATE_CTIME);
if (le32_andz(ni->flags, FILE_ATTR_ARCHIVE)) {
if (!(ni->flags & FILE_ATTR_ARCHIVE)) {
set_archive(ni);
NInoFileNameSetDirty(ni);
}
@ -4106,7 +4106,7 @@ static const char *fuse26_kmod_msg =
" message to disappear then you should upgrade to at least kernel\n"
" version 2.6.20, or request help from your distribution to fix\n"
" the kernel problem. The below web page has more information:\n"
" http://tuxera.com/community/ntfs-3g-faq/#fuse26\n"
" https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ\n"
"\n";
static void mknod_dev_fuse(const char *dev)

View File

@ -63,14 +63,18 @@ Unclassified FUSE error.
Please see
.RS
.sp
http://tuxera.com/community/ntfs-3g-faq/
https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ
.sp
.RE
for common questions and known issues.
If you think you have found an undocumented problem in the latest release of
the software then please send an email describing it in detail.
You can contact the development team on the ntfs\-3g\-devel@lists.sf.net
address.
the software then please post an ntfs-3g issue describing it in detail
so that the development team can be aware of the issue and take care of it:
.RS
.sp
https://github.com/tuxera/ntfs-3g/issues
.sp
.RE
.SH AUTHORS
.B ntfs-3g.probe
was written by Szabolcs Szakacsits.

View File

@ -128,6 +128,10 @@ const struct DEFOPTION optionlist[] = {
{ "efs_raw", OPT_EFS_RAW, FLGOPT_BOGUS },
{ "posix_nlink", OPT_POSIX_NLINK, FLGOPT_BOGUS },
{ "special_files", OPT_SPECIAL_FILES, FLGOPT_STRING },
{ "--help", OPT_HELP, FLGOPT_BOGUS },
{ "-h", OPT_HELP, FLGOPT_BOGUS },
{ "--version", OPT_VERSION, FLGOPT_BOGUS },
{ "-V", OPT_VERSION, FLGOPT_BOGUS },
{ (const char*)NULL, 0, 0 } /* end marker */
} ;
@ -521,6 +525,8 @@ char *parse_mount_options(ntfs_fuse_context_t *ctx,
* mounted or not.
* (falling through to default)
*/
case OPT_HELP : /* Could lead to unclean condition */
case OPT_VERSION : /* Could lead to unclean condition */
default :
ntfs_log_error("'%s' is an unsupported option.\n",
poptl->name);
@ -772,7 +778,7 @@ int ntfs_fuse_listxattr_common(ntfs_inode *ni, ntfs_attr_search_ctx *actx,
}
#else /* XATTR_MAPPINGS */
/* List efs info xattr for encrypted files */
if (ni->vol->efs_raw && !le32_andz(ni->flags, FILE_ATTR_ENCRYPTED)) {
if (ni->vol->efs_raw && (ni->flags & FILE_ATTR_ENCRYPTED)) {
ret += sizeof(nf_ns_alt_xattr_efsinfo);
if ((size_t)ret <= size) {
memcpy(to, nf_ns_alt_xattr_efsinfo,
@ -832,8 +838,8 @@ const struct plugin_operations *select_reparse_plugin(ntfs_fuse_context_t *ctx,
reparse = ntfs_get_reparse_point(ni);
if (reparse) {
tag = reparse->reparse_tag;
seltag = le32_and(tag, IO_REPARSE_PLUGIN_SELECT);
for (plugin=ctx->plugins; plugin && !le32_eq(plugin->tag, seltag);
seltag = tag & IO_REPARSE_PLUGIN_SELECT;
for (plugin=ctx->plugins; plugin && (plugin->tag != seltag);
plugin = plugin->next) { }
if (plugin) {
ops = plugin->ops;
@ -914,12 +920,12 @@ BOOL user_xattrs_allowed(ntfs_fuse_context_t *ctx __attribute__((unused)),
BOOL res;
/* Quick return for common cases and root */
if (le32_andz(ni->flags, le32_or(FILE_ATTR_SYSTEM, FILE_ATTR_REPARSE_POINT))
if (!(ni->flags & (FILE_ATTR_SYSTEM | FILE_ATTR_REPARSE_POINT))
|| (ni->mft_no == FILE_root))
res = TRUE;
else {
/* Reparse point depends on kind, see plugin */
if (!le32_andz(ni->flags, FILE_ATTR_REPARSE_POINT)) {
if (ni->flags & FILE_ATTR_REPARSE_POINT) {
#ifndef DISABLE_PLUGINS
struct stat stbuf;
REPARSE_POINT *reparse;

View File

@ -94,6 +94,8 @@ enum {
OPT_EFS_RAW,
OPT_POSIX_NLINK,
OPT_SPECIAL_FILES,
OPT_HELP,
OPT_VERSION,
} ;
/* Option flags */