On Tue, 15 Nov 2005, Yura Pakhuchiy wrote:
> On Tue, 2005-11-15 at 15:37 +0200, Yura Pakhuchiy wrote:
> > On Tue, 2005-11-15 at 10:41 +0000, Anton Altaparmakov wrote:
> > > This is a bug... You can't do atime updates on read-only volumes. You
> > > need to check if the volume is read-only and only if not perform the
> > > update. This breaks the entirety of libntfs/ntfsprogs that use
> > > read-only mounts for sure.
> >
> > A lot of utils use read-only mounts if --no-action option passed to
> > them, they call ntfs_attr_pwrite and it is OK, but why updating atime is
> > evil in this case?
>
> I read ntfs_attr_pread source and found answer myself. I always had
> thought that read-only check performed on some more low-level such as
> ntfs_pwrite, not in ntfs_{attr,rl}_pwrite.
Yes. The reason it is not in ntfs_pwrite() is that ntfs_pwrite() is a
device operation not a volume operation. The NVolReadOnly() check is a
volume operation also.
Note, ntfs_pwrite() actually does do a read-only check. But a different
kind of read-only check. It checks whether the device is read-only and
returns an error if so:
if (NDevReadOnly(dev)) {
errno = EROFS;
return -1;
}
In contrast to this, the volume layer silently returns success when
NVolReadOnly() is true. This allows us to do the "--noaction" easily
whilst still actually doing as much as possible of the operations so that
--noaction is closer to reality.
And the NDevReadOnly() guarantees that if we have bugs in volume layer
(very complex and large amount of code so quite possible) and those
bugs result in some writes slipping through, those writes will never
corrupt the real on-disk volume as we will catch them and return EROFS
which will cause the utility to abort and hopefully we will get a
bugreport about it and be able to fix the leak...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
|