mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
fs: Remove NTFS classic
The replacement, NTFS3, was merged over two years ago. It is now time to remove the original from the tree as it is the last user of several APIs, and it is not worth changing. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://lore.kernel.org/r/20240115072025.2071931-1-willy@infradead.org Acked-by: Namjae Jeon <linkinjeon@kernel.org> Acked-by: Dave Chinner <david@fromorbit.com> Cc: Anton Altaparmakov <anton@tuxera.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
6613476e22
commit
7ffa8f3d30
5
CREDITS
5
CREDITS
@@ -63,6 +63,11 @@ D: dosfs, LILO, some fd features, ATM, various other hacks here and there
|
||||
S: Buenos Aires
|
||||
S: Argentina
|
||||
|
||||
NTFS FILESYSTEM
|
||||
N: Anton Altaparmakov
|
||||
E: anton@tuxera.com
|
||||
D: NTFS filesystem
|
||||
|
||||
N: Tim Alpaerts
|
||||
E: tim_alpaerts@toyota-motor-europe.com
|
||||
D: 802.2 class II logical link control layer,
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
.. SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
================================
|
||||
The Linux NTFS filesystem driver
|
||||
================================
|
||||
|
||||
|
||||
.. Table of contents
|
||||
|
||||
- Overview
|
||||
- Web site
|
||||
- Features
|
||||
- Supported mount options
|
||||
- Known bugs and (mis-)features
|
||||
- Using NTFS volume and stripe sets
|
||||
- The Device-Mapper driver
|
||||
- The Software RAID / MD driver
|
||||
- Limitations when using the MD driver
|
||||
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
Linux-NTFS comes with a number of user-space programs known as ntfsprogs.
|
||||
These include mkntfs, a full-featured ntfs filesystem format utility,
|
||||
ntfsundelete used for recovering files that were unintentionally deleted
|
||||
from an NTFS volume and ntfsresize which is used to resize an NTFS partition.
|
||||
See the web site for more information.
|
||||
|
||||
To mount an NTFS 1.2/3.x (Windows NT4/2000/XP/2003) volume, use the file
|
||||
system type 'ntfs'. The driver currently supports read-only mode (with no
|
||||
fault-tolerance, encryption or journalling) and very limited, but safe, write
|
||||
support.
|
||||
|
||||
For fault tolerance and raid support (i.e. volume and stripe sets), you can
|
||||
use the kernel's Software RAID / MD driver. See section "Using Software RAID
|
||||
with NTFS" for details.
|
||||
|
||||
|
||||
Web site
|
||||
========
|
||||
|
||||
There is plenty of additional information on the linux-ntfs web site
|
||||
at http://www.linux-ntfs.org/
|
||||
|
||||
The web site has a lot of additional information, such as a comprehensive
|
||||
FAQ, documentation on the NTFS on-disk format, information on the Linux-NTFS
|
||||
userspace utilities, etc.
|
||||
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
- This is a complete rewrite of the NTFS driver that used to be in the 2.4 and
|
||||
earlier kernels. This new driver implements NTFS read support and is
|
||||
functionally equivalent to the old ntfs driver and it also implements limited
|
||||
write support. The biggest limitation at present is that files/directories
|
||||
cannot be created or deleted. See below for the list of write features that
|
||||
are so far supported. Another limitation is that writing to compressed files
|
||||
is not implemented at all. Also, neither read nor write access to encrypted
|
||||
files is so far implemented.
|
||||
- The new driver has full support for sparse files on NTFS 3.x volumes which
|
||||
the old driver isn't happy with.
|
||||
- The new driver supports execution of binaries due to mmap() now being
|
||||
supported.
|
||||
- The new driver supports loopback mounting of files on NTFS which is used by
|
||||
some Linux distributions to enable the user to run Linux from an NTFS
|
||||
partition by creating a large file while in Windows and then loopback
|
||||
mounting the file while in Linux and creating a Linux filesystem on it that
|
||||
is used to install Linux on it.
|
||||
- A comparison of the two drivers using::
|
||||
|
||||
time find . -type f -exec md5sum "{}" \;
|
||||
|
||||
run three times in sequence with each driver (after a reboot) on a 1.4GiB
|
||||
NTFS partition, showed the new driver to be 20% faster in total time elapsed
|
||||
(from 9:43 minutes on average down to 7:53). The time spent in user space
|
||||
was unchanged but the time spent in the kernel was decreased by a factor of
|
||||
2.5 (from 85 CPU seconds down to 33).
|
||||
- The driver does not support short file names in general. For backwards
|
||||
compatibility, we implement access to files using their short file names if
|
||||
they exist. The driver will not create short file names however, and a
|
||||
rename will discard any existing short file name.
|
||||
- The new driver supports exporting of mounted NTFS volumes via NFS.
|
||||
- The new driver supports async io (aio).
|
||||
- The new driver supports fsync(2), fdatasync(2), and msync(2).
|
||||
- The new driver supports readv(2) and writev(2).
|
||||
- The new driver supports access time updates (including mtime and ctime).
|
||||
- The new driver supports truncate(2) and open(2) with O_TRUNC. But at present
|
||||
only very limited support for highly fragmented files, i.e. ones which have
|
||||
their data attribute split across multiple extents, is included. Another
|
||||
limitation is that at present truncate(2) will never create sparse files,
|
||||
since to mark a file sparse we need to modify the directory entry for the
|
||||
file and we do not implement directory modifications yet.
|
||||
- The new driver supports write(2) which can both overwrite existing data and
|
||||
extend the file size so that you can write beyond the existing data. Also,
|
||||
writing into sparse regions is supported and the holes are filled in with
|
||||
clusters. But at present only limited support for highly fragmented files,
|
||||
i.e. ones which have their data attribute split across multiple extents, is
|
||||
included. Another limitation is that write(2) will never create sparse
|
||||
files, since to mark a file sparse we need to modify the directory entry for
|
||||
the file and we do not implement directory modifications yet.
|
||||
|
||||
Supported mount options
|
||||
=======================
|
||||
|
||||
In addition to the generic mount options described by the manual page for the
|
||||
mount command (man 8 mount, also see man 5 fstab), the NTFS driver supports the
|
||||
following mount options:
|
||||
|
||||
======================= =======================================================
|
||||
iocharset=name Deprecated option. Still supported but please use
|
||||
nls=name in the future. See description for nls=name.
|
||||
|
||||
nls=name Character set to use when returning file names.
|
||||
Unlike VFAT, NTFS suppresses names that contain
|
||||
unconvertible characters. Note that most character
|
||||
sets contain insufficient characters to represent all
|
||||
possible Unicode characters that can exist on NTFS.
|
||||
To be sure you are not missing any files, you are
|
||||
advised to use nls=utf8 which is capable of
|
||||
representing all Unicode characters.
|
||||
|
||||
utf8=<bool> Option no longer supported. Currently mapped to
|
||||
nls=utf8 but please use nls=utf8 in the future and
|
||||
make sure utf8 is compiled either as module or into
|
||||
the kernel. See description for nls=name.
|
||||
|
||||
uid=
|
||||
gid=
|
||||
umask= Provide default owner, group, and access mode mask.
|
||||
These options work as documented in mount(8). By
|
||||
default, the files/directories are owned by root and
|
||||
he/she has read and write permissions, as well as
|
||||
browse permission for directories. No one else has any
|
||||
access permissions. I.e. the mode on all files is by
|
||||
default rw------- and for directories rwx------, a
|
||||
consequence of the default fmask=0177 and dmask=0077.
|
||||
Using a umask of zero will grant all permissions to
|
||||
everyone, i.e. all files and directories will have mode
|
||||
rwxrwxrwx.
|
||||
|
||||
fmask=
|
||||
dmask= Instead of specifying umask which applies both to
|
||||
files and directories, fmask applies only to files and
|
||||
dmask only to directories.
|
||||
|
||||
sloppy=<BOOL> If sloppy is specified, ignore unknown mount options.
|
||||
Otherwise the default behaviour is to abort mount if
|
||||
any unknown options are found.
|
||||
|
||||
show_sys_files=<BOOL> If show_sys_files is specified, show the system files
|
||||
in directory listings. Otherwise the default behaviour
|
||||
is to hide the system files.
|
||||
Note that even when show_sys_files is specified, "$MFT"
|
||||
will not be visible due to bugs/mis-features in glibc.
|
||||
Further, note that irrespective of show_sys_files, all
|
||||
files are accessible by name, i.e. you can always do
|
||||
"ls -l \$UpCase" for example to specifically show the
|
||||
system file containing the Unicode upcase table.
|
||||
|
||||
case_sensitive=<BOOL> If case_sensitive is specified, treat all file names as
|
||||
case sensitive and create file names in the POSIX
|
||||
namespace. Otherwise the default behaviour is to treat
|
||||
file names as case insensitive and to create file names
|
||||
in the WIN32/LONG name space. Note, the Linux NTFS
|
||||
driver will never create short file names and will
|
||||
remove them on rename/delete of the corresponding long
|
||||
file name.
|
||||
Note that files remain accessible via their short file
|
||||
name, if it exists. If case_sensitive, you will need
|
||||
to provide the correct case of the short file name.
|
||||
|
||||
disable_sparse=<BOOL> If disable_sparse is specified, creation of sparse
|
||||
regions, i.e. holes, inside files is disabled for the
|
||||
volume (for the duration of this mount only). By
|
||||
default, creation of sparse regions is enabled, which
|
||||
is consistent with the behaviour of traditional Unix
|
||||
filesystems.
|
||||
|
||||
errors=opt What to do when critical filesystem errors are found.
|
||||
Following values can be used for "opt":
|
||||
|
||||
======== =========================================
|
||||
continue DEFAULT, try to clean-up as much as
|
||||
possible, e.g. marking a corrupt inode as
|
||||
bad so it is no longer accessed, and then
|
||||
continue.
|
||||
recover At present only supported is recovery of
|
||||
the boot sector from the backup copy.
|
||||
If read-only mount, the recovery is done
|
||||
in memory only and not written to disk.
|
||||
======== =========================================
|
||||
|
||||
Note that the options are additive, i.e. specifying::
|
||||
|
||||
errors=continue,errors=recover
|
||||
|
||||
means the driver will attempt to recover and if that
|
||||
fails it will clean-up as much as possible and
|
||||
continue.
|
||||
|
||||
mft_zone_multiplier= Set the MFT zone multiplier for the volume (this
|
||||
setting is not persistent across mounts and can be
|
||||
changed from mount to mount but cannot be changed on
|
||||
remount). Values of 1 to 4 are allowed, 1 being the
|
||||
default. The MFT zone multiplier determines how much
|
||||
space is reserved for the MFT on the volume. If all
|
||||
other space is used up, then the MFT zone will be
|
||||
shrunk dynamically, so this has no impact on the
|
||||
amount of free space. However, it can have an impact
|
||||
on performance by affecting fragmentation of the MFT.
|
||||
In general use the default. If you have a lot of small
|
||||
files then use a higher value. The values have the
|
||||
following meaning:
|
||||
|
||||
===== =================================
|
||||
Value MFT zone size (% of volume size)
|
||||
===== =================================
|
||||
1 12.5%
|
||||
2 25%
|
||||
3 37.5%
|
||||
4 50%
|
||||
===== =================================
|
||||
|
||||
Note this option is irrelevant for read-only mounts.
|
||||
======================= =======================================================
|
||||
|
||||
|
||||
Known bugs and (mis-)features
|
||||
=============================
|
||||
|
||||
- The link count on each directory inode entry is set to 1, due to Linux not
|
||||
supporting directory hard links. This may well confuse some user space
|
||||
applications, since the directory names will have the same inode numbers.
|
||||
This also speeds up ntfs_read_inode() immensely. And we haven't found any
|
||||
problems with this approach so far. If you find a problem with this, please
|
||||
let us know.
|
||||
|
||||
|
||||
Please send bug reports/comments/feedback/abuse to the Linux-NTFS development
|
||||
list at sourceforge: linux-ntfs-dev@lists.sourceforge.net
|
||||
|
||||
|
||||
Using NTFS volume and stripe sets
|
||||
=================================
|
||||
|
||||
For support of volume and stripe sets, you can either use the kernel's
|
||||
Device-Mapper driver or the kernel's Software RAID / MD driver. The former is
|
||||
the recommended one to use for linear raid. But the latter is required for
|
||||
raid level 5. For striping and mirroring, either driver should work fine.
|
||||
|
||||
|
||||
The Device-Mapper driver
|
||||
------------------------
|
||||
|
||||
You will need to create a table of the components of the volume/stripe set and
|
||||
how they fit together and load this into the kernel using the dmsetup utility
|
||||
(see man 8 dmsetup).
|
||||
|
||||
Linear volume sets, i.e. linear raid, has been tested and works fine. Even
|
||||
though untested, there is no reason why stripe sets, i.e. raid level 0, and
|
||||
mirrors, i.e. raid level 1 should not work, too. Stripes with parity, i.e.
|
||||
raid level 5, unfortunately cannot work yet because the current version of the
|
||||
Device-Mapper driver does not support raid level 5. You may be able to use the
|
||||
Software RAID / MD driver for raid level 5, see the next section for details.
|
||||
|
||||
To create the table describing your volume you will need to know each of its
|
||||
components and their sizes in sectors, i.e. multiples of 512-byte blocks.
|
||||
|
||||
For NT4 fault tolerant volumes you can obtain the sizes using fdisk. So for
|
||||
example if one of your partitions is /dev/hda2 you would do::
|
||||
|
||||
$ fdisk -ul /dev/hda
|
||||
|
||||
Disk /dev/hda: 81.9 GB, 81964302336 bytes
|
||||
255 heads, 63 sectors/track, 9964 cylinders, total 160086528 sectors
|
||||
Units = sectors of 1 * 512 = 512 bytes
|
||||
|
||||
Device Boot Start End Blocks Id System
|
||||
/dev/hda1 * 63 4209029 2104483+ 83 Linux
|
||||
/dev/hda2 4209030 37768814 16779892+ 86 NTFS
|
||||
/dev/hda3 37768815 46170809 4200997+ 83 Linux
|
||||
|
||||
And you would know that /dev/hda2 has a size of 37768814 - 4209030 + 1 =
|
||||
33559785 sectors.
|
||||
|
||||
For Win2k and later dynamic disks, you can for example use the ldminfo utility
|
||||
which is part of the Linux LDM tools (the latest version at the time of
|
||||
writing is linux-ldm-0.0.8.tar.bz2). You can download it from:
|
||||
|
||||
http://www.linux-ntfs.org/
|
||||
|
||||
Simply extract the downloaded archive (tar xvjf linux-ldm-0.0.8.tar.bz2), go
|
||||
into it (cd linux-ldm-0.0.8) and change to the test directory (cd test). You
|
||||
will find the precompiled (i386) ldminfo utility there. NOTE: You will not be
|
||||
able to compile this yourself easily so use the binary version!
|
||||
|
||||
Then you would use ldminfo in dump mode to obtain the necessary information::
|
||||
|
||||
$ ./ldminfo --dump /dev/hda
|
||||
|
||||
This would dump the LDM database found on /dev/hda which describes all of your
|
||||
dynamic disks and all the volumes on them. At the bottom you will see the
|
||||
VOLUME DEFINITIONS section which is all you really need. You may need to look
|
||||
further above to determine which of the disks in the volume definitions is
|
||||
which device in Linux. Hint: Run ldminfo on each of your dynamic disks and
|
||||
look at the Disk Id close to the top of the output for each (the PRIVATE HEADER
|
||||
section). You can then find these Disk Ids in the VBLK DATABASE section in the
|
||||
<Disk> components where you will get the LDM Name for the disk that is found in
|
||||
the VOLUME DEFINITIONS section.
|
||||
|
||||
Note you will also need to enable the LDM driver in the Linux kernel. If your
|
||||
distribution did not enable it, you will need to recompile the kernel with it
|
||||
enabled. This will create the LDM partitions on each device at boot time. You
|
||||
would then use those devices (for /dev/hda they would be /dev/hda1, 2, 3, etc)
|
||||
in the Device-Mapper table.
|
||||
|
||||
You can also bypass using the LDM driver by using the main device (e.g.
|
||||
/dev/hda) and then using the offsets of the LDM partitions into this device as
|
||||
the "Start sector of device" when creating the table. Once again ldminfo would
|
||||
give you the correct information to do this.
|
||||
|
||||
Assuming you know all your devices and their sizes things are easy.
|
||||
|
||||
For a linear raid the table would look like this (note all values are in
|
||||
512-byte sectors)::
|
||||
|
||||
# Offset into Size of this Raid type Device Start sector
|
||||
# volume device of device
|
||||
0 1028161 linear /dev/hda1 0
|
||||
1028161 3903762 linear /dev/hdb2 0
|
||||
4931923 2103211 linear /dev/hdc1 0
|
||||
|
||||
For a striped volume, i.e. raid level 0, you will need to know the chunk size
|
||||
you used when creating the volume. Windows uses 64kiB as the default, so it
|
||||
will probably be this unless you changes the defaults when creating the array.
|
||||
|
||||
For a raid level 0 the table would look like this (note all values are in
|
||||
512-byte sectors)::
|
||||
|
||||
# Offset Size Raid Number Chunk 1st Start 2nd Start
|
||||
# into of the type of size Device in Device in
|
||||
# volume volume stripes device device
|
||||
0 2056320 striped 2 128 /dev/hda1 0 /dev/hdb1 0
|
||||
|
||||
If there are more than two devices, just add each of them to the end of the
|
||||
line.
|
||||
|
||||
Finally, for a mirrored volume, i.e. raid level 1, the table would look like
|
||||
this (note all values are in 512-byte sectors)::
|
||||
|
||||
# Ofs Size Raid Log Number Region Should Number Source Start Target Start
|
||||
# in of the type type of log size sync? of Device in Device in
|
||||
# vol volume params mirrors Device Device
|
||||
0 2056320 mirror core 2 16 nosync 2 /dev/hda1 0 /dev/hdb1 0
|
||||
|
||||
If you are mirroring to multiple devices you can specify further targets at the
|
||||
end of the line.
|
||||
|
||||
Note the "Should sync?" parameter "nosync" means that the two mirrors are
|
||||
already in sync which will be the case on a clean shutdown of Windows. If the
|
||||
mirrors are not clean, you can specify the "sync" option instead of "nosync"
|
||||
and the Device-Mapper driver will then copy the entirety of the "Source Device"
|
||||
to the "Target Device" or if you specified multiple target devices to all of
|
||||
them.
|
||||
|
||||
Once you have your table, save it in a file somewhere (e.g. /etc/ntfsvolume1),
|
||||
and hand it over to dmsetup to work with, like so::
|
||||
|
||||
$ dmsetup create myvolume1 /etc/ntfsvolume1
|
||||
|
||||
You can obviously replace "myvolume1" with whatever name you like.
|
||||
|
||||
If it all worked, you will now have the device /dev/device-mapper/myvolume1
|
||||
which you can then just use as an argument to the mount command as usual to
|
||||
mount the ntfs volume. For example::
|
||||
|
||||
$ mount -t ntfs -o ro /dev/device-mapper/myvolume1 /mnt/myvol1
|
||||
|
||||
(You need to create the directory /mnt/myvol1 first and of course you can use
|
||||
anything you like instead of /mnt/myvol1 as long as it is an existing
|
||||
directory.)
|
||||
|
||||
It is advisable to do the mount read-only to see if the volume has been setup
|
||||
correctly to avoid the possibility of causing damage to the data on the ntfs
|
||||
volume.
|
||||
|
||||
|
||||
The Software RAID / MD driver
|
||||
-----------------------------
|
||||
|
||||
An alternative to using the Device-Mapper driver is to use the kernel's
|
||||
Software RAID / MD driver. For which you need to set up your /etc/raidtab
|
||||
appropriately (see man 5 raidtab).
|
||||
|
||||
Linear volume sets, i.e. linear raid, as well as stripe sets, i.e. raid level
|
||||
0, have been tested and work fine (though see section "Limitations when using
|
||||
the MD driver with NTFS volumes" especially if you want to use linear raid).
|
||||
Even though untested, there is no reason why mirrors, i.e. raid level 1, and
|
||||
stripes with parity, i.e. raid level 5, should not work, too.
|
||||
|
||||
You have to use the "persistent-superblock 0" option for each raid-disk in the
|
||||
NTFS volume/stripe you are configuring in /etc/raidtab as the persistent
|
||||
superblock used by the MD driver would damage the NTFS volume.
|
||||
|
||||
Windows by default uses a stripe chunk size of 64k, so you probably want the
|
||||
"chunk-size 64k" option for each raid-disk, too.
|
||||
|
||||
For example, if you have a stripe set consisting of two partitions /dev/hda5
|
||||
and /dev/hdb1 your /etc/raidtab would look like this::
|
||||
|
||||
raiddev /dev/md0
|
||||
raid-level 0
|
||||
nr-raid-disks 2
|
||||
nr-spare-disks 0
|
||||
persistent-superblock 0
|
||||
chunk-size 64k
|
||||
device /dev/hda5
|
||||
raid-disk 0
|
||||
device /dev/hdb1
|
||||
raid-disk 1
|
||||
|
||||
For linear raid, just change the raid-level above to "raid-level linear", for
|
||||
mirrors, change it to "raid-level 1", and for stripe sets with parity, change
|
||||
it to "raid-level 5".
|
||||
|
||||
Note for stripe sets with parity you will also need to tell the MD driver
|
||||
which parity algorithm to use by specifying the option "parity-algorithm
|
||||
which", where you need to replace "which" with the name of the algorithm to
|
||||
use (see man 5 raidtab for available algorithms) and you will have to try the
|
||||
different available algorithms until you find one that works. Make sure you
|
||||
are working read-only when playing with this as you may damage your data
|
||||
otherwise. If you find which algorithm works please let us know (email the
|
||||
linux-ntfs developers list linux-ntfs-dev@lists.sourceforge.net or drop in on
|
||||
IRC in channel #ntfs on the irc.freenode.net network) so we can update this
|
||||
documentation.
|
||||
|
||||
Once the raidtab is setup, run for example raid0run -a to start all devices or
|
||||
raid0run /dev/md0 to start a particular md device, in this case /dev/md0.
|
||||
|
||||
Then just use the mount command as usual to mount the ntfs volume using for
|
||||
example::
|
||||
|
||||
mount -t ntfs -o ro /dev/md0 /mnt/myntfsvolume
|
||||
|
||||
It is advisable to do the mount read-only to see if the md volume has been
|
||||
setup correctly to avoid the possibility of causing damage to the data on the
|
||||
ntfs volume.
|
||||
|
||||
|
||||
Limitations when using the Software RAID / MD driver
|
||||
-----------------------------------------------------
|
||||
|
||||
Using the md driver will not work properly if any of your NTFS partitions have
|
||||
an odd number of sectors. This is especially important for linear raid as all
|
||||
data after the first partition with an odd number of sectors will be offset by
|
||||
one or more sectors so if you mount such a partition with write support you
|
||||
will cause massive damage to the data on the volume which will only become
|
||||
apparent when you try to use the volume again under Windows.
|
||||
|
||||
So when using linear raid, make sure that all your partitions have an even
|
||||
number of sectors BEFORE attempting to use it. You have been warned!
|
||||
|
||||
Even better is to simply use the Device-Mapper for linear raid and then you do
|
||||
not have this problem with odd numbers of sectors.
|
||||
10
MAINTAINERS
10
MAINTAINERS
@@ -15566,16 +15566,6 @@ W: https://github.com/davejiang/linux/wiki
|
||||
T: git https://github.com/davejiang/linux.git
|
||||
F: drivers/ntb/hw/intel/
|
||||
|
||||
NTFS FILESYSTEM
|
||||
M: Anton Altaparmakov <anton@tuxera.com>
|
||||
R: Namjae Jeon <linkinjeon@kernel.org>
|
||||
L: linux-ntfs-dev@lists.sourceforge.net
|
||||
S: Supported
|
||||
W: http://www.tuxera.com/
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/aia21/ntfs.git
|
||||
F: Documentation/filesystems/ntfs.rst
|
||||
F: fs/ntfs/
|
||||
|
||||
NTFS3 FILESYSTEM
|
||||
M: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
|
||||
L: ntfs3@lists.linux.dev
|
||||
|
||||
@@ -162,7 +162,6 @@ menu "DOS/FAT/EXFAT/NT Filesystems"
|
||||
|
||||
source "fs/fat/Kconfig"
|
||||
source "fs/exfat/Kconfig"
|
||||
source "fs/ntfs/Kconfig"
|
||||
source "fs/ntfs3/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -91,7 +91,6 @@ obj-y += unicode/
|
||||
obj-$(CONFIG_SYSV_FS) += sysv/
|
||||
obj-$(CONFIG_SMBFS) += smb/
|
||||
obj-$(CONFIG_HPFS_FS) += hpfs/
|
||||
obj-$(CONFIG_NTFS_FS) += ntfs/
|
||||
obj-$(CONFIG_NTFS3_FS) += ntfs3/
|
||||
obj-$(CONFIG_UFS_FS) += ufs/
|
||||
obj-$(CONFIG_EFS_FS) += efs/
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
config NTFS_FS
|
||||
tristate "NTFS file system support"
|
||||
select BUFFER_HEAD
|
||||
select NLS
|
||||
help
|
||||
NTFS is the file system of Microsoft Windows NT, 2000, XP and 2003.
|
||||
|
||||
Saying Y or M here enables read support. There is partial, but
|
||||
safe, write support available. For write support you must also
|
||||
say Y to "NTFS write support" below.
|
||||
|
||||
There are also a number of user-space tools available, called
|
||||
ntfsprogs. These include ntfsundelete and ntfsresize, that work
|
||||
without NTFS support enabled in the kernel.
|
||||
|
||||
This is a rewrite from scratch of Linux NTFS support and replaced
|
||||
the old NTFS code starting with Linux 2.5.11. A backport to
|
||||
the Linux 2.4 kernel series is separately available as a patch
|
||||
from the project web site.
|
||||
|
||||
For more information see <file:Documentation/filesystems/ntfs.rst>
|
||||
and <http://www.linux-ntfs.org/>.
|
||||
|
||||
To compile this file system support as a module, choose M here: the
|
||||
module will be called ntfs.
|
||||
|
||||
If you are not using Windows NT, 2000, XP or 2003 in addition to
|
||||
Linux on your computer it is safe to say N.
|
||||
|
||||
config NTFS_DEBUG
|
||||
bool "NTFS debugging support"
|
||||
depends on NTFS_FS
|
||||
help
|
||||
If you are experiencing any problems with the NTFS file system, say
|
||||
Y here. This will result in additional consistency checks to be
|
||||
performed by the driver as well as additional debugging messages to
|
||||
be written to the system log. Note that debugging messages are
|
||||
disabled by default. To enable them, supply the option debug_msgs=1
|
||||
at the kernel command line when booting the kernel or as an option
|
||||
to insmod when loading the ntfs module. Once the driver is active,
|
||||
you can enable debugging messages by doing (as root):
|
||||
echo 1 > /proc/sys/fs/ntfs-debug
|
||||
Replacing the "1" with "0" would disable debug messages.
|
||||
|
||||
If you leave debugging messages disabled, this results in little
|
||||
overhead, but enabling debug messages results in very significant
|
||||
slowdown of the system.
|
||||
|
||||
When reporting bugs, please try to have available a full dump of
|
||||
debugging messages while the misbehaviour was occurring.
|
||||
|
||||
config NTFS_RW
|
||||
bool "NTFS write support"
|
||||
depends on NTFS_FS
|
||||
depends on PAGE_SIZE_LESS_THAN_64KB
|
||||
help
|
||||
This enables the partial, but safe, write support in the NTFS driver.
|
||||
|
||||
The only supported operation is overwriting existing files, without
|
||||
changing the file length. No file or directory creation, deletion or
|
||||
renaming is possible. Note only non-resident files can be written to
|
||||
so you may find that some very small files (<500 bytes or so) cannot
|
||||
be written to.
|
||||
|
||||
While we cannot guarantee that it will not damage any data, we have
|
||||
so far not received a single report where the driver would have
|
||||
damaged someones data so we assume it is perfectly safe to use.
|
||||
|
||||
Note: While write support is safe in this version (a rewrite from
|
||||
scratch of the NTFS support), it should be noted that the old NTFS
|
||||
write support, included in Linux 2.5.10 and before (since 1997),
|
||||
is not safe.
|
||||
|
||||
This is currently useful with TopologiLinux. TopologiLinux is run
|
||||
on top of any DOS/Microsoft Windows system without partitioning your
|
||||
hard disk. Unlike other Linux distributions TopologiLinux does not
|
||||
need its own partition. For more information see
|
||||
<http://topologi-linux.sourceforge.net/>
|
||||
|
||||
It is perfectly safe to say N here.
|
||||
@@ -1,15 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Rules for making the NTFS driver.
|
||||
|
||||
obj-$(CONFIG_NTFS_FS) += ntfs.o
|
||||
|
||||
ntfs-y := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
|
||||
index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \
|
||||
unistr.o upcase.o
|
||||
|
||||
ntfs-$(CONFIG_NTFS_RW) += bitmap.o lcnalloc.o logfile.o quota.o usnjrnl.o
|
||||
|
||||
ccflags-y := -DNTFS_VERSION=\"2.1.32\"
|
||||
ccflags-$(CONFIG_NTFS_DEBUG) += -DDEBUG
|
||||
ccflags-$(CONFIG_NTFS_RW) += -DNTFS_RW
|
||||
|
||||
1744
fs/ntfs/aops.c
1744
fs/ntfs/aops.c
File diff suppressed because it is too large
Load Diff
@@ -1,88 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* aops.h - Defines for NTFS kernel address space operations and page cache
|
||||
* handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NTFS_AOPS_H
|
||||
#define _LINUX_NTFS_AOPS_H
|
||||
|
||||
#include <linux/mm.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "inode.h"
|
||||
|
||||
/**
|
||||
* ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
|
||||
* @page: the page to release
|
||||
*
|
||||
* Unpin, unmap and release a page that was obtained from ntfs_map_page().
|
||||
*/
|
||||
static inline void ntfs_unmap_page(struct page *page)
|
||||
{
|
||||
kunmap(page);
|
||||
put_page(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_map_page - map a page into accessible memory, reading it if necessary
|
||||
* @mapping: address space for which to obtain the page
|
||||
* @index: index into the page cache for @mapping of the page to map
|
||||
*
|
||||
* Read a page from the page cache of the address space @mapping at position
|
||||
* @index, where @index is in units of PAGE_SIZE, and not in bytes.
|
||||
*
|
||||
* If the page is not in memory it is loaded from disk first using the
|
||||
* read_folio method defined in the address space operations of @mapping
|
||||
* and the page is added to the page cache of @mapping in the process.
|
||||
*
|
||||
* If the page belongs to an mst protected attribute and it is marked as such
|
||||
* in its ntfs inode (NInoMstProtected()) the mst fixups are applied but no
|
||||
* error checking is performed. This means the caller has to verify whether
|
||||
* the ntfs record(s) contained in the page are valid or not using one of the
|
||||
* ntfs_is_XXXX_record{,p}() macros, where XXXX is the record type you are
|
||||
* expecting to see. (For details of the macros, see fs/ntfs/layout.h.)
|
||||
*
|
||||
* If the page is in high memory it is mapped into memory directly addressible
|
||||
* by the kernel.
|
||||
*
|
||||
* Finally the page count is incremented, thus pinning the page into place.
|
||||
*
|
||||
* The above means that page_address(page) can be used on all pages obtained
|
||||
* with ntfs_map_page() to get the kernel virtual address of the page.
|
||||
*
|
||||
* When finished with the page, the caller has to call ntfs_unmap_page() to
|
||||
* unpin, unmap and release the page.
|
||||
*
|
||||
* Note this does not grant exclusive access. If such is desired, the caller
|
||||
* must provide it independently of the ntfs_{un}map_page() calls by using
|
||||
* a {rw_}semaphore or other means of serialization. A spin lock cannot be
|
||||
* used as ntfs_map_page() can block.
|
||||
*
|
||||
* The unlocked and uptodate page is returned on success or an encoded error
|
||||
* on failure. Caller has to test for error using the IS_ERR() macro on the
|
||||
* return value. If that evaluates to 'true', the negative error code can be
|
||||
* obtained using PTR_ERR() on the return value of ntfs_map_page().
|
||||
*/
|
||||
static inline struct page *ntfs_map_page(struct address_space *mapping,
|
||||
unsigned long index)
|
||||
{
|
||||
struct page *page = read_mapping_page(mapping, index, NULL);
|
||||
|
||||
if (!IS_ERR(page))
|
||||
kmap(page);
|
||||
return page;
|
||||
}
|
||||
|
||||
#ifdef NTFS_RW
|
||||
|
||||
extern void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs);
|
||||
|
||||
#endif /* NTFS_RW */
|
||||
|
||||
#endif /* _LINUX_NTFS_AOPS_H */
|
||||
2624
fs/ntfs/attrib.c
2624
fs/ntfs/attrib.c
File diff suppressed because it is too large
Load Diff
102
fs/ntfs/attrib.h
102
fs/ntfs/attrib.h
@@ -1,102 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* attrib.h - Defines for attribute handling in NTFS Linux kernel driver.
|
||||
* Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NTFS_ATTRIB_H
|
||||
#define _LINUX_NTFS_ATTRIB_H
|
||||
|
||||
#include "endian.h"
|
||||
#include "types.h"
|
||||
#include "layout.h"
|
||||
#include "inode.h"
|
||||
#include "runlist.h"
|
||||
#include "volume.h"
|
||||
|
||||
/**
|
||||
* ntfs_attr_search_ctx - used in attribute search functions
|
||||
* @mrec: buffer containing mft record to search
|
||||
* @attr: attribute record in @mrec where to begin/continue search
|
||||
* @is_first: if true ntfs_attr_lookup() begins search with @attr, else after
|
||||
*
|
||||
* Structure must be initialized to zero before the first call to one of the
|
||||
* attribute search functions. Initialize @mrec to point to the mft record to
|
||||
* search, and @attr to point to the first attribute within @mrec (not necessary
|
||||
* if calling the _first() functions), and set @is_first to 'true' (not necessary
|
||||
* if calling the _first() functions).
|
||||
*
|
||||
* If @is_first is 'true', the search begins with @attr. If @is_first is 'false',
|
||||
* the search begins after @attr. This is so that, after the first call to one
|
||||
* of the search attribute functions, we can call the function again, without
|
||||
* any modification of the search context, to automagically get the next
|
||||
* matching attribute.
|
||||
*/
|
||||
typedef struct {
|
||||
MFT_RECORD *mrec;
|
||||
ATTR_RECORD *attr;
|
||||
bool is_first;
|
||||
ntfs_inode *ntfs_ino;
|
||||
ATTR_LIST_ENTRY *al_entry;
|
||||
ntfs_inode *base_ntfs_ino;
|
||||
MFT_RECORD *base_mrec;
|
||||
ATTR_RECORD *base_attr;
|
||||
} ntfs_attr_search_ctx;
|
||||
|
||||
extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn,
|
||||
ntfs_attr_search_ctx *ctx);
|
||||
extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn);
|
||||
|
||||
extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn,
|
||||
const bool write_locked);
|
||||
|
||||
extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni,
|
||||
const VCN vcn, ntfs_attr_search_ctx *ctx);
|
||||
|
||||
int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
|
||||
const u32 name_len, const IGNORE_CASE_BOOL ic,
|
||||
const VCN lowest_vcn, const u8 *val, const u32 val_len,
|
||||
ntfs_attr_search_ctx *ctx);
|
||||
|
||||
extern int load_attribute_list(ntfs_volume *vol, runlist *rl, u8 *al_start,
|
||||
const s64 size, const s64 initialized_size);
|
||||
|
||||
static inline s64 ntfs_attr_size(const ATTR_RECORD *a)
|
||||
{
|
||||
if (!a->non_resident)
|
||||
return (s64)le32_to_cpu(a->data.resident.value_length);
|
||||
return sle64_to_cpu(a->data.non_resident.data_size);
|
||||
}
|
||||
|
||||
extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx);
|
||||
extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
|
||||
MFT_RECORD *mrec);
|
||||
extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
|
||||
|
||||
#ifdef NTFS_RW
|
||||
|
||||
extern int ntfs_attr_size_bounds_check(const ntfs_volume *vol,
|
||||
const ATTR_TYPE type, const s64 size);
|
||||
extern int ntfs_attr_can_be_non_resident(const ntfs_volume *vol,
|
||||
const ATTR_TYPE type);
|
||||
extern int ntfs_attr_can_be_resident(const ntfs_volume *vol,
|
||||
const ATTR_TYPE type);
|
||||
|
||||
extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
|
||||
extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
|
||||
const u32 new_size);
|
||||
|
||||
extern int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size);
|
||||
|
||||
extern s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size,
|
||||
const s64 new_data_size, const s64 data_start);
|
||||
|
||||
extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt,
|
||||
const u8 val);
|
||||
|
||||
#endif /* NTFS_RW */
|
||||
|
||||
#endif /* _LINUX_NTFS_ATTRIB_H */
|
||||
179
fs/ntfs/bitmap.c
179
fs/ntfs/bitmap.c
@@ -1,179 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* bitmap.c - NTFS kernel bitmap handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2004-2005 Anton Altaparmakov
|
||||
*/
|
||||
|
||||
#ifdef NTFS_RW
|
||||
|
||||
#include <linux/pagemap.h>
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "debug.h"
|
||||
#include "aops.h"
|
||||
#include "ntfs.h"
|
||||
|
||||
/**
|
||||
* __ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
|
||||
* @vi: vfs inode describing the bitmap
|
||||
* @start_bit: first bit to set
|
||||
* @count: number of bits to set
|
||||
* @value: value to set the bits to (i.e. 0 or 1)
|
||||
* @is_rollback: if 'true' this is a rollback operation
|
||||
*
|
||||
* Set @count bits starting at bit @start_bit in the bitmap described by the
|
||||
* vfs inode @vi to @value, where @value is either 0 or 1.
|
||||
*
|
||||
* @is_rollback should always be 'false', it is for internal use to rollback
|
||||
* errors. You probably want to use ntfs_bitmap_set_bits_in_run() instead.
|
||||
*
|
||||
* Return 0 on success and -errno on error.
|
||||
*/
|
||||
int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
|
||||
const s64 count, const u8 value, const bool is_rollback)
|
||||
{
|
||||
s64 cnt = count;
|
||||
pgoff_t index, end_index;
|
||||
struct address_space *mapping;
|
||||
struct page *page;
|
||||
u8 *kaddr;
|
||||
int pos, len;
|
||||
u8 bit;
|
||||
|
||||
BUG_ON(!vi);
|
||||
ntfs_debug("Entering for i_ino 0x%lx, start_bit 0x%llx, count 0x%llx, "
|
||||
"value %u.%s", vi->i_ino, (unsigned long long)start_bit,
|
||||
(unsigned long long)cnt, (unsigned int)value,
|
||||
is_rollback ? " (rollback)" : "");
|
||||
BUG_ON(start_bit < 0);
|
||||
BUG_ON(cnt < 0);
|
||||
BUG_ON(value > 1);
|
||||
/*
|
||||
* Calculate the indices for the pages containing the first and last
|
||||
* bits, i.e. @start_bit and @start_bit + @cnt - 1, respectively.
|
||||
*/
|
||||
index = start_bit >> (3 + PAGE_SHIFT);
|
||||
end_index = (start_bit + cnt - 1) >> (3 + PAGE_SHIFT);
|
||||
|
||||
/* Get the page containing the first bit (@start_bit). */
|
||||
mapping = vi->i_mapping;
|
||||
page = ntfs_map_page(mapping, index);
|
||||
if (IS_ERR(page)) {
|
||||
if (!is_rollback)
|
||||
ntfs_error(vi->i_sb, "Failed to map first page (error "
|
||||
"%li), aborting.", PTR_ERR(page));
|
||||
return PTR_ERR(page);
|
||||
}
|
||||
kaddr = page_address(page);
|
||||
|
||||
/* Set @pos to the position of the byte containing @start_bit. */
|
||||
pos = (start_bit >> 3) & ~PAGE_MASK;
|
||||
|
||||
/* Calculate the position of @start_bit in the first byte. */
|
||||
bit = start_bit & 7;
|
||||
|
||||
/* If the first byte is partial, modify the appropriate bits in it. */
|
||||
if (bit) {
|
||||
u8 *byte = kaddr + pos;
|
||||
while ((bit & 7) && cnt) {
|
||||
cnt--;
|
||||
if (value)
|
||||
*byte |= 1 << bit++;
|
||||
else
|
||||
*byte &= ~(1 << bit++);
|
||||
}
|
||||
/* If we are done, unmap the page and return success. */
|
||||
if (!cnt)
|
||||
goto done;
|
||||
|
||||
/* Update @pos to the new position. */
|
||||
pos++;
|
||||
}
|
||||
/*
|
||||
* Depending on @value, modify all remaining whole bytes in the page up
|
||||
* to @cnt.
|
||||
*/
|
||||
len = min_t(s64, cnt >> 3, PAGE_SIZE - pos);
|
||||
memset(kaddr + pos, value ? 0xff : 0, len);
|
||||
cnt -= len << 3;
|
||||
|
||||
/* Update @len to point to the first not-done byte in the page. */
|
||||
if (cnt < 8)
|
||||
len += pos;
|
||||
|
||||
/* If we are not in the last page, deal with all subsequent pages. */
|
||||
while (index < end_index) {
|
||||
BUG_ON(cnt <= 0);
|
||||
|
||||
/* Update @index and get the next page. */
|
||||
flush_dcache_page(page);
|
||||
set_page_dirty(page);
|
||||
ntfs_unmap_page(page);
|
||||
page = ntfs_map_page(mapping, ++index);
|
||||
if (IS_ERR(page))
|
||||
goto rollback;
|
||||
kaddr = page_address(page);
|
||||
/*
|
||||
* Depending on @value, modify all remaining whole bytes in the
|
||||
* page up to @cnt.
|
||||
*/
|
||||
len = min_t(s64, cnt >> 3, PAGE_SIZE);
|
||||
memset(kaddr, value ? 0xff : 0, len);
|
||||
cnt -= len << 3;
|
||||
}
|
||||
/*
|
||||
* The currently mapped page is the last one. If the last byte is
|
||||
* partial, modify the appropriate bits in it. Note, @len is the
|
||||
* position of the last byte inside the page.
|
||||
*/
|
||||
if (cnt) {
|
||||
u8 *byte;
|
||||
|
||||
BUG_ON(cnt > 7);
|
||||
|
||||
bit = cnt;
|
||||
byte = kaddr + len;
|
||||
while (bit--) {
|
||||
if (value)
|
||||
*byte |= 1 << bit;
|
||||
else
|
||||
*byte &= ~(1 << bit);
|
||||
}
|
||||
}
|
||||
done:
|
||||
/* We are done. Unmap the page and return success. */
|
||||
flush_dcache_page(page);
|
||||
set_page_dirty(page);
|
||||
ntfs_unmap_page(page);
|
||||
ntfs_debug("Done.");
|
||||
return 0;
|
||||
rollback:
|
||||
/*
|
||||
* Current state:
|
||||
* - no pages are mapped
|
||||
* - @count - @cnt is the number of bits that have been modified
|
||||
*/
|
||||
if (is_rollback)
|
||||
return PTR_ERR(page);
|
||||
if (count != cnt)
|
||||
pos = __ntfs_bitmap_set_bits_in_run(vi, start_bit, count - cnt,
|
||||
value ? 0 : 1, true);
|
||||
else
|
||||
pos = 0;
|
||||
if (!pos) {
|
||||
/* Rollback was successful. */
|
||||
ntfs_error(vi->i_sb, "Failed to map subsequent page (error "
|
||||
"%li), aborting.", PTR_ERR(page));
|
||||
} else {
|
||||
/* Rollback failed. */
|
||||
ntfs_error(vi->i_sb, "Failed to map subsequent page (error "
|
||||
"%li) and rollback failed (error %i). "
|
||||
"Aborting and leaving inconsistent metadata. "
|
||||
"Unmount and run chkdsk.", PTR_ERR(page), pos);
|
||||
NVolSetErrors(NTFS_SB(vi->i_sb));
|
||||
}
|
||||
return PTR_ERR(page);
|
||||
}
|
||||
|
||||
#endif /* NTFS_RW */
|
||||
104
fs/ntfs/bitmap.h
104
fs/ntfs/bitmap.h
@@ -1,104 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* bitmap.h - Defines for NTFS kernel bitmap handling. Part of the Linux-NTFS
|
||||
* project.
|
||||
*
|
||||
* Copyright (c) 2004 Anton Altaparmakov
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NTFS_BITMAP_H
|
||||
#define _LINUX_NTFS_BITMAP_H
|
||||
|
||||
#ifdef NTFS_RW
|
||||
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
extern int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 start_bit,
|
||||
const s64 count, const u8 value, const bool is_rollback);
|
||||
|
||||
/**
|
||||
* ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
|
||||
* @vi: vfs inode describing the bitmap
|
||||
* @start_bit: first bit to set
|
||||
* @count: number of bits to set
|
||||
* @value: value to set the bits to (i.e. 0 or 1)
|
||||
*
|
||||
* Set @count bits starting at bit @start_bit in the bitmap described by the
|
||||
* vfs inode @vi to @value, where @value is either 0 or 1.
|
||||
*
|
||||
* Return 0 on success and -errno on error.
|
||||
*/
|
||||
static inline int ntfs_bitmap_set_bits_in_run(struct inode *vi,
|
||||
const s64 start_bit, const s64 count, const u8 value)
|
||||
{
|
||||
return __ntfs_bitmap_set_bits_in_run(vi, start_bit, count, value,
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_bitmap_set_run - set a run of bits in a bitmap
|
||||
* @vi: vfs inode describing the bitmap
|
||||
* @start_bit: first bit to set
|
||||
* @count: number of bits to set
|
||||
*
|
||||
* Set @count bits starting at bit @start_bit in the bitmap described by the
|
||||
* vfs inode @vi.
|
||||
*
|
||||
* Return 0 on success and -errno on error.
|
||||
*/
|
||||
static inline int ntfs_bitmap_set_run(struct inode *vi, const s64 start_bit,
|
||||
const s64 count)
|
||||
{
|
||||
return ntfs_bitmap_set_bits_in_run(vi, start_bit, count, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_bitmap_clear_run - clear a run of bits in a bitmap
|
||||
* @vi: vfs inode describing the bitmap
|
||||
* @start_bit: first bit to clear
|
||||
* @count: number of bits to clear
|
||||
*
|
||||
* Clear @count bits starting at bit @start_bit in the bitmap described by the
|
||||
* vfs inode @vi.
|
||||
*
|
||||
* Return 0 on success and -errno on error.
|
||||
*/
|
||||
static inline int ntfs_bitmap_clear_run(struct inode *vi, const s64 start_bit,
|
||||
const s64 count)
|
||||
{
|
||||
return ntfs_bitmap_set_bits_in_run(vi, start_bit, count, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_bitmap_set_bit - set a bit in a bitmap
|
||||
* @vi: vfs inode describing the bitmap
|
||||
* @bit: bit to set
|
||||
*
|
||||
* Set bit @bit in the bitmap described by the vfs inode @vi.
|
||||
*
|
||||
* Return 0 on success and -errno on error.
|
||||
*/
|
||||
static inline int ntfs_bitmap_set_bit(struct inode *vi, const s64 bit)
|
||||
{
|
||||
return ntfs_bitmap_set_run(vi, bit, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntfs_bitmap_clear_bit - clear a bit in a bitmap
|
||||
* @vi: vfs inode describing the bitmap
|
||||
* @bit: bit to clear
|
||||
*
|
||||
* Clear bit @bit in the bitmap described by the vfs inode @vi.
|
||||
*
|
||||
* Return 0 on success and -errno on error.
|
||||
*/
|
||||
static inline int ntfs_bitmap_clear_bit(struct inode *vi, const s64 bit)
|
||||
{
|
||||
return ntfs_bitmap_clear_run(vi, bit, 1);
|
||||
}
|
||||
|
||||
#endif /* NTFS_RW */
|
||||
|
||||
#endif /* defined _LINUX_NTFS_BITMAP_H */
|
||||
@@ -1,110 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* collate.c - NTFS kernel collation handling. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2004 Anton Altaparmakov
|
||||
*/
|
||||
|
||||
#include "collate.h"
|
||||
#include "debug.h"
|
||||
#include "ntfs.h"
|
||||
|
||||
static int ntfs_collate_binary(ntfs_volume *vol,
|
||||
const void *data1, const int data1_len,
|
||||
const void *data2, const int data2_len)
|
||||
{
|
||||
int rc;
|
||||
|
||||
ntfs_debug("Entering.");
|
||||
rc = memcmp(data1, data2, min(data1_len, data2_len));
|
||||
if (!rc && (data1_len != data2_len)) {
|
||||
if (data1_len < data2_len)
|
||||
rc = -1;
|
||||
else
|
||||
rc = 1;
|
||||
}
|
||||
ntfs_debug("Done, returning %i", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int ntfs_collate_ntofs_ulong(ntfs_volume *vol,
|
||||
const void *data1, const int data1_len,
|
||||
const void *data2, const int data2_len)
|
||||
{
|
||||
int rc;
|
||||
u32 d1, d2;
|
||||
|
||||
ntfs_debug("Entering.");
|
||||
// FIXME: We don't really want to bug here.
|
||||
BUG_ON(data1_len != data2_len);
|
||||
BUG_ON(data1_len != 4);
|
||||
d1 = le32_to_cpup(data1);
|
||||
d2 = le32_to_cpup(data2);
|
||||
if (d1 < d2)
|
||||
rc = -1;
|
||||
else {
|
||||
if (d1 == d2)
|
||||
rc = 0;
|
||||
else
|
||||
rc = 1;
|
||||
}
|
||||
ntfs_debug("Done, returning %i", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
typedef int (*ntfs_collate_func_t)(ntfs_volume *, const void *, const int,
|
||||
const void *, const int);
|
||||
|
||||
static ntfs_collate_func_t ntfs_do_collate0x0[3] = {
|
||||
ntfs_collate_binary,
|
||||
NULL/*ntfs_collate_file_name*/,
|
||||
NULL/*ntfs_collate_unicode_string*/,
|
||||
};
|
||||
|
||||
static ntfs_collate_func_t ntfs_do_collate0x1[4] = {
|
||||
ntfs_collate_ntofs_ulong,
|
||||
NULL/*ntfs_collate_ntofs_sid*/,
|
||||
NULL/*ntfs_collate_ntofs_security_hash*/,
|
||||
NULL/*ntfs_collate_ntofs_ulongs*/,
|
||||
};
|
||||
|
||||
/**
|
||||
* ntfs_collate - collate two data items using a specified collation rule
|
||||
* @vol: ntfs volume to which the data items belong
|
||||
* @cr: collation rule to use when comparing the items
|
||||
* @data1: first data item to collate
|
||||
* @data1_len: length in bytes of @data1
|
||||
* @data2: second data item to collate
|
||||
* @data2_len: length in bytes of @data2
|
||||
*
|
||||
* Collate the two data items @data1 and @data2 using the collation rule @cr
|
||||
* and return -1, 0, ir 1 if @data1 is found, respectively, to collate before,
|
||||
* to match, or to collate after @data2.
|
||||
*
|
||||
* For speed we use the collation rule @cr as an index into two tables of
|
||||
* function pointers to call the appropriate collation function.
|
||||
*/
|
||||
int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
|
||||
const void *data1, const int data1_len,
|
||||
const void *data2, const int data2_len) {
|
||||
int i;
|
||||
|
||||
ntfs_debug("Entering.");
|
||||
/*
|
||||
* FIXME: At the moment we only support COLLATION_BINARY and
|
||||
* COLLATION_NTOFS_ULONG, so we BUG() for everything else for now.
|
||||
*/
|
||||
BUG_ON(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG);
|
||||
i = le32_to_cpu(cr);
|
||||
BUG_ON(i < 0);
|
||||
if (i <= 0x02)
|
||||
return ntfs_do_collate0x0[i](vol, data1, data1_len,
|
||||
data2, data2_len);
|
||||
BUG_ON(i < 0x10);
|
||||
i -= 0x10;
|
||||
if (likely(i <= 3))
|
||||
return ntfs_do_collate0x1[i](vol, data1, data1_len,
|
||||
data2, data2_len);
|
||||
BUG();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* collate.h - Defines for NTFS kernel collation handling. Part of the
|
||||
* Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2004 Anton Altaparmakov
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NTFS_COLLATE_H
|
||||
#define _LINUX_NTFS_COLLATE_H
|
||||
|
||||
#include "types.h"
|
||||
#include "volume.h"
|
||||
|
||||
static inline bool ntfs_is_collation_rule_supported(COLLATION_RULE cr) {
|
||||
int i;
|
||||
|
||||
/*
|
||||
* FIXME: At the moment we only support COLLATION_BINARY and
|
||||
* COLLATION_NTOFS_ULONG, so we return false for everything else for
|
||||
* now.
|
||||
*/
|
||||
if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG))
|
||||
return false;
|
||||
i = le32_to_cpu(cr);
|
||||
if (likely(((i >= 0) && (i <= 0x02)) ||
|
||||
((i >= 0x10) && (i <= 0x13))))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
|
||||
const void *data1, const int data1_len,
|
||||
const void *data2, const int data2_len);
|
||||
|
||||
#endif /* _LINUX_NTFS_COLLATE_H */
|
||||
File diff suppressed because it is too large
Load Diff
159
fs/ntfs/debug.c
159
fs/ntfs/debug.c
@@ -1,159 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
* debug.c - NTFS kernel debug support. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
*/
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* __ntfs_warning - output a warning to the syslog
|
||||
* @function: name of function outputting the warning
|
||||
* @sb: super block of mounted ntfs filesystem
|
||||
* @fmt: warning string containing format specifications
|
||||
* @...: a variable number of arguments specified in @fmt
|
||||
*
|
||||
* Outputs a warning to the syslog for the mounted ntfs filesystem described
|
||||
* by @sb.
|
||||
*
|
||||
* @fmt and the corresponding @... is printf style format string containing
|
||||
* the warning string and the corresponding format arguments, respectively.
|
||||
*
|
||||
* @function is the name of the function from which __ntfs_warning is being
|
||||
* called.
|
||||
*
|
||||
* Note, you should be using debug.h::ntfs_warning(@sb, @fmt, @...) instead
|
||||
* as this provides the @function parameter automatically.
|
||||
*/
|
||||
void __ntfs_warning(const char *function, const struct super_block *sb,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
int flen = 0;
|
||||
|
||||
#ifndef DEBUG
|
||||
if (!printk_ratelimit())
|
||||
return;
|
||||
#endif
|
||||
if (function)
|
||||
flen = strlen(function);
|
||||
va_start(args, fmt);
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
if (sb)
|
||||
pr_warn("(device %s): %s(): %pV\n",
|
||||
sb->s_id, flen ? function : "", &vaf);
|
||||
else
|
||||
pr_warn("%s(): %pV\n", flen ? function : "", &vaf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* __ntfs_error - output an error to the syslog
|
||||
* @function: name of function outputting the error
|
||||
* @sb: super block of mounted ntfs filesystem
|
||||
* @fmt: error string containing format specifications
|
||||
* @...: a variable number of arguments specified in @fmt
|
||||
*
|
||||
* Outputs an error to the syslog for the mounted ntfs filesystem described
|
||||
* by @sb.
|
||||
*
|
||||
* @fmt and the corresponding @... is printf style format string containing
|
||||
* the error string and the corresponding format arguments, respectively.
|
||||
*
|
||||
* @function is the name of the function from which __ntfs_error is being
|
||||
* called.
|
||||
*
|
||||
* Note, you should be using debug.h::ntfs_error(@sb, @fmt, @...) instead
|
||||
* as this provides the @function parameter automatically.
|
||||
*/
|
||||
void __ntfs_error(const char *function, const struct super_block *sb,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
int flen = 0;
|
||||
|
||||
#ifndef DEBUG
|
||||
if (!printk_ratelimit())
|
||||
return;
|
||||
#endif
|
||||
if (function)
|
||||
flen = strlen(function);
|
||||
va_start(args, fmt);
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
if (sb)
|
||||
pr_err("(device %s): %s(): %pV\n",
|
||||
sb->s_id, flen ? function : "", &vaf);
|
||||
else
|
||||
pr_err("%s(): %pV\n", flen ? function : "", &vaf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/* If 1, output debug messages, and if 0, don't. */
|
||||
int debug_msgs = 0;
|
||||
|
||||
void __ntfs_debug(const char *file, int line, const char *function,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
struct va_format vaf;
|
||||
va_list args;
|
||||
int flen = 0;
|
||||
|
||||
if (!debug_msgs)
|
||||
return;
|
||||
if (function)
|
||||
flen = strlen(function);
|
||||
va_start(args, fmt);
|
||||
vaf.fmt = fmt;
|
||||
vaf.va = &args;
|
||||
pr_debug("(%s, %d): %s(): %pV", file, line, flen ? function : "", &vaf);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/* Dump a runlist. Caller has to provide synchronisation for @rl. */
|
||||
void ntfs_debug_dump_runlist(const runlist_element *rl)
|
||||
{
|
||||
int i;
|
||||
const char *lcn_str[5] = { "LCN_HOLE ", "LCN_RL_NOT_MAPPED",
|
||||
"LCN_ENOENT ", "LCN_unknown " };
|
||||
|
||||
if (!debug_msgs)
|
||||
return;
|
||||
pr_debug("Dumping runlist (values in hex):\n");
|
||||
if (!rl) {
|
||||
pr_debug("Run list not present.\n");
|
||||
return;
|
||||
}
|
||||
pr_debug("VCN LCN Run length\n");
|
||||
for (i = 0; ; i++) {
|
||||
LCN lcn = (rl + i)->lcn;
|
||||
|
||||
if (lcn < (LCN)0) {
|
||||
int index = -lcn - 1;
|
||||
|
||||
if (index > -LCN_ENOENT - 1)
|
||||
index = 3;
|
||||
pr_debug("%-16Lx %s %-16Lx%s\n",
|
||||
(long long)(rl + i)->vcn, lcn_str[index],
|
||||
(long long)(rl + i)->length,
|
||||
(rl + i)->length ? "" :
|
||||
" (runlist end)");
|
||||
} else
|
||||
pr_debug("%-16Lx %-16Lx %-16Lx%s\n",
|
||||
(long long)(rl + i)->vcn,
|
||||
(long long)(rl + i)->lcn,
|
||||
(long long)(rl + i)->length,
|
||||
(rl + i)->length ? "" :
|
||||
" (runlist end)");
|
||||
if (!(rl + i)->length)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* debug.h - NTFS kernel debug support. Part of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NTFS_DEBUG_H
|
||||
#define _LINUX_NTFS_DEBUG_H
|
||||
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "runlist.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
extern int debug_msgs;
|
||||
|
||||
extern __printf(4, 5)
|
||||
void __ntfs_debug(const char *file, int line, const char *function,
|
||||
const char *format, ...);
|
||||
/**
|
||||
* ntfs_debug - write a debug level message to syslog
|
||||
* @f: a printf format string containing the message
|
||||
* @...: the variables to substitute into @f
|
||||
*
|
||||
* ntfs_debug() writes a DEBUG level message to the syslog but only if the
|
||||
* driver was compiled with -DDEBUG. Otherwise, the call turns into a NOP.
|
||||
*/
|
||||
#define ntfs_debug(f, a...) \
|
||||
__ntfs_debug(__FILE__, __LINE__, __func__, f, ##a)
|
||||
|
||||
extern void ntfs_debug_dump_runlist(const runlist_element *rl);
|
||||
|
||||
#else /* !DEBUG */
|
||||
|
||||
#define ntfs_debug(fmt, ...) \
|
||||
do { \
|
||||
if (0) \
|
||||
no_printk(fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define ntfs_debug_dump_runlist(rl) do {} while (0)
|
||||
|
||||
#endif /* !DEBUG */
|
||||
|
||||
extern __printf(3, 4)
|
||||
void __ntfs_warning(const char *function, const struct super_block *sb,
|
||||
const char *fmt, ...);
|
||||
#define ntfs_warning(sb, f, a...) __ntfs_warning(__func__, sb, f, ##a)
|
||||
|
||||
extern __printf(3, 4)
|
||||
void __ntfs_error(const char *function, const struct super_block *sb,
|
||||
const char *fmt, ...);
|
||||
#define ntfs_error(sb, f, a...) __ntfs_error(__func__, sb, f, ##a)
|
||||
|
||||
#endif /* _LINUX_NTFS_DEBUG_H */
|
||||
1540
fs/ntfs/dir.c
1540
fs/ntfs/dir.c
File diff suppressed because it is too large
Load Diff
@@ -1,34 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/*
|
||||
* dir.h - Defines for directory handling in NTFS Linux kernel driver. Part of
|
||||
* the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2002-2004 Anton Altaparmakov
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NTFS_DIR_H
|
||||
#define _LINUX_NTFS_DIR_H
|
||||
|
||||
#include "layout.h"
|
||||
#include "inode.h"
|
||||
#include "types.h"
|
||||
|
||||
/*
|
||||
* ntfs_name is used to return the file name to the caller of
|
||||
* ntfs_lookup_inode_by_name() in order for the caller (namei.c::ntfs_lookup())
|
||||
* to be able to deal with dcache aliasing issues.
|
||||
*/
|
||||
typedef struct {
|
||||
MFT_REF mref;
|
||||
FILE_NAME_TYPE_FLAGS type;
|
||||
u8 len;
|
||||
ntfschar name[0];
|
||||
} __attribute__ ((__packed__)) ntfs_name;
|
||||
|
||||
/* The little endian Unicode string $I30 as a global constant. */
|
||||
extern ntfschar I30[5];
|
||||
|
||||
extern MFT_REF ntfs_lookup_inode_by_name(ntfs_inode *dir_ni,
|
||||
const ntfschar *uname, const int uname_len, ntfs_name **res);
|
||||
|
||||
#endif /* _LINUX_NTFS_FS_DIR_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user