mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2024-11-23 10:04:00 +08:00
Checked whether the device to mount was forced read-only
Force the read-only mount mode when the device was set so through a command "blockdev --setro".
This commit is contained in:
parent
1f8b751341
commit
ad79372024
@ -53,6 +53,9 @@
|
||||
#ifdef HAVE_LINUX_FD_H
|
||||
#include <linux/fd.h>
|
||||
#endif
|
||||
#ifdef HAVE_LINUX_FS_H
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "mst.h"
|
||||
@ -142,6 +145,21 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags)
|
||||
err = errno;
|
||||
goto err_out;
|
||||
}
|
||||
#ifdef HAVE_LINUX_FS_H
|
||||
/* Check whether the device was forced read-only */
|
||||
if (NDevBlock(dev) && ((flags & O_RDWR) == O_RDWR)) {
|
||||
int r;
|
||||
int state;
|
||||
|
||||
r = ioctl(DEV_FD(dev), BLKROGET, &state);
|
||||
if (!r && state) {
|
||||
err = EROFS;
|
||||
if (close(DEV_FD(dev)))
|
||||
err = errno;
|
||||
goto err_out;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((flags & O_RDWR) != O_RDWR)
|
||||
NDevSetReadOnly(dev);
|
||||
|
Loading…
Reference in New Issue
Block a user