aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/super.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-07-17 03:45:34 -0400
committerDavid Howells <dhowells@redhat.com>2017-07-17 03:45:34 -0400
commitbc98a42c1f7d0f886c0c1b75a92a004976a46d9f (patch)
tree42a30f4f8d1aa3723f5356f2a5697b23317e2e19 /fs/ntfs/super.c
parent94e92e7ac90d06e1e839e112d3ae80b2457dbdd7 (diff)
VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb)
Firstly by applying the following with coccinelle's spatch: @@ expression SB; @@ -SB->s_flags & MS_RDONLY +sb_rdonly(SB) to effect the conversion to sb_rdonly(sb), then by applying: @@ expression A, SB; @@ ( -(!sb_rdonly(SB)) && A +!sb_rdonly(SB) && A | -A != (sb_rdonly(SB)) +A != sb_rdonly(SB) | -A == (sb_rdonly(SB)) +A == sb_rdonly(SB) | -!(sb_rdonly(SB)) +!sb_rdonly(SB) | -A && (sb_rdonly(SB)) +A && sb_rdonly(SB) | -A || (sb_rdonly(SB)) +A || sb_rdonly(SB) | -(sb_rdonly(SB)) != A +sb_rdonly(SB) != A | -(sb_rdonly(SB)) == A +sb_rdonly(SB) == A | -(sb_rdonly(SB)) && A +sb_rdonly(SB) && A | -(sb_rdonly(SB)) || A +sb_rdonly(SB) || A ) @@ expression A, B, SB; @@ ( -(sb_rdonly(SB)) ? 1 : 0 +sb_rdonly(SB) | -(sb_rdonly(SB)) ? A : B +sb_rdonly(SB) ? A : B ) to remove left over excess bracketage and finally by applying: @@ expression A, SB; @@ ( -(A & MS_RDONLY) != sb_rdonly(SB) +(bool)(A & MS_RDONLY) != sb_rdonly(SB) | -(A & MS_RDONLY) == sb_rdonly(SB) +(bool)(A & MS_RDONLY) == sb_rdonly(SB) ) to make comparisons against the result of sb_rdonly() (which is a bool) work correctly. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/ntfs/super.c')
-rw-r--r--fs/ntfs/super.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index ecb49870a680..3f70f041dbe9 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -487,7 +487,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
487 * When remounting read-only, mark the volume clean if no volume errors 487 * When remounting read-only, mark the volume clean if no volume errors
488 * have occurred. 488 * have occurred.
489 */ 489 */
490 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { 490 if (sb_rdonly(sb) && !(*flags & MS_RDONLY)) {
491 static const char *es = ". Cannot remount read-write."; 491 static const char *es = ". Cannot remount read-write.";
492 492
493 /* Remounting read-write. */ 493 /* Remounting read-write. */
@@ -548,7 +548,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
548 NVolSetErrors(vol); 548 NVolSetErrors(vol);
549 return -EROFS; 549 return -EROFS;
550 } 550 }
551 } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { 551 } else if (!sb_rdonly(sb) && (*flags & MS_RDONLY)) {
552 /* Remounting read-only. */ 552 /* Remounting read-only. */
553 if (!NVolErrors(vol)) { 553 if (!NVolErrors(vol)) {
554 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) 554 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY))
@@ -732,7 +732,7 @@ hotfix_primary_boot_sector:
732 * on a large sector device contains the whole boot loader or 732 * on a large sector device contains the whole boot loader or
733 * just the first 512 bytes). 733 * just the first 512 bytes).
734 */ 734 */
735 if (!(sb->s_flags & MS_RDONLY)) { 735 if (!sb_rdonly(sb)) {
736 ntfs_warning(sb, "Hot-fix: Recovering invalid primary " 736 ntfs_warning(sb, "Hot-fix: Recovering invalid primary "
737 "boot sector from backup copy."); 737 "boot sector from backup copy.");
738 memcpy(bh_primary->b_data, bh_backup->b_data, 738 memcpy(bh_primary->b_data, bh_backup->b_data,
@@ -1789,7 +1789,7 @@ static bool load_system_files(ntfs_volume *vol)
1789 static const char *es3 = ". Run ntfsfix and/or chkdsk."; 1789 static const char *es3 = ". Run ntfsfix and/or chkdsk.";
1790 1790
1791 /* If a read-write mount, convert it to a read-only mount. */ 1791 /* If a read-write mount, convert it to a read-only mount. */
1792 if (!(sb->s_flags & MS_RDONLY)) { 1792 if (!sb_rdonly(sb)) {
1793 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | 1793 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
1794 ON_ERRORS_CONTINUE))) { 1794 ON_ERRORS_CONTINUE))) {
1795 ntfs_error(sb, "%s and neither on_errors=" 1795 ntfs_error(sb, "%s and neither on_errors="
@@ -1928,7 +1928,7 @@ get_ctx_vol_failed:
1928 (unsigned)le16_to_cpu(vol->vol_flags)); 1928 (unsigned)le16_to_cpu(vol->vol_flags));
1929 } 1929 }
1930 /* If a read-write mount, convert it to a read-only mount. */ 1930 /* If a read-write mount, convert it to a read-only mount. */
1931 if (!(sb->s_flags & MS_RDONLY)) { 1931 if (!sb_rdonly(sb)) {
1932 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | 1932 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
1933 ON_ERRORS_CONTINUE))) { 1933 ON_ERRORS_CONTINUE))) {
1934 ntfs_error(sb, "%s and neither on_errors=" 1934 ntfs_error(sb, "%s and neither on_errors="
@@ -1961,7 +1961,7 @@ get_ctx_vol_failed:
1961 1961
1962 es1 = !vol->logfile_ino ? es1a : es1b; 1962 es1 = !vol->logfile_ino ? es1a : es1b;
1963 /* If a read-write mount, convert it to a read-only mount. */ 1963 /* If a read-write mount, convert it to a read-only mount. */
1964 if (!(sb->s_flags & MS_RDONLY)) { 1964 if (!sb_rdonly(sb)) {
1965 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | 1965 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
1966 ON_ERRORS_CONTINUE))) { 1966 ON_ERRORS_CONTINUE))) {
1967 ntfs_error(sb, "%s and neither on_errors=" 1967 ntfs_error(sb, "%s and neither on_errors="
@@ -2010,7 +2010,7 @@ get_ctx_vol_failed:
2010 2010
2011 es1 = err < 0 ? es1a : es1b; 2011 es1 = err < 0 ? es1a : es1b;
2012 /* If a read-write mount, convert it to a read-only mount. */ 2012 /* If a read-write mount, convert it to a read-only mount. */
2013 if (!(sb->s_flags & MS_RDONLY)) { 2013 if (!sb_rdonly(sb)) {
2014 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | 2014 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
2015 ON_ERRORS_CONTINUE))) { 2015 ON_ERRORS_CONTINUE))) {
2016 ntfs_error(sb, "%s and neither on_errors=" 2016 ntfs_error(sb, "%s and neither on_errors="
@@ -2028,8 +2028,7 @@ get_ctx_vol_failed:
2028 NVolSetErrors(vol); 2028 NVolSetErrors(vol);
2029 } 2029 }
2030 /* If (still) a read-write mount, mark the volume dirty. */ 2030 /* If (still) a read-write mount, mark the volume dirty. */
2031 if (!(sb->s_flags & MS_RDONLY) && 2031 if (!sb_rdonly(sb) && ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
2032 ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
2033 static const char *es1 = "Failed to set dirty bit in volume " 2032 static const char *es1 = "Failed to set dirty bit in volume "
2034 "information flags"; 2033 "information flags";
2035 static const char *es2 = ". Run chkdsk."; 2034 static const char *es2 = ". Run chkdsk.";
@@ -2075,8 +2074,7 @@ get_ctx_vol_failed:
2075 } 2074 }
2076#endif 2075#endif
2077 /* If (still) a read-write mount, empty the logfile. */ 2076 /* If (still) a read-write mount, empty the logfile. */
2078 if (!(sb->s_flags & MS_RDONLY) && 2077 if (!sb_rdonly(sb) && !ntfs_empty_logfile(vol->logfile_ino)) {
2079 !ntfs_empty_logfile(vol->logfile_ino)) {
2080 static const char *es1 = "Failed to empty $LogFile"; 2078 static const char *es1 = "Failed to empty $LogFile";
2081 static const char *es2 = ". Mount in Windows."; 2079 static const char *es2 = ". Mount in Windows.";
2082 2080
@@ -2121,7 +2119,7 @@ get_ctx_vol_failed:
2121 static const char *es2 = ". Run chkdsk."; 2119 static const char *es2 = ". Run chkdsk.";
2122 2120
2123 /* If a read-write mount, convert it to a read-only mount. */ 2121 /* If a read-write mount, convert it to a read-only mount. */
2124 if (!(sb->s_flags & MS_RDONLY)) { 2122 if (!sb_rdonly(sb)) {
2125 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | 2123 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
2126 ON_ERRORS_CONTINUE))) { 2124 ON_ERRORS_CONTINUE))) {
2127 ntfs_error(sb, "%s and neither on_errors=" 2125 ntfs_error(sb, "%s and neither on_errors="
@@ -2139,8 +2137,7 @@ get_ctx_vol_failed:
2139 NVolSetErrors(vol); 2137 NVolSetErrors(vol);
2140 } 2138 }
2141 /* If (still) a read-write mount, mark the quotas out of date. */ 2139 /* If (still) a read-write mount, mark the quotas out of date. */
2142 if (!(sb->s_flags & MS_RDONLY) && 2140 if (!sb_rdonly(sb) && !ntfs_mark_quotas_out_of_date(vol)) {
2143 !ntfs_mark_quotas_out_of_date(vol)) {
2144 static const char *es1 = "Failed to mark quotas out of date"; 2141 static const char *es1 = "Failed to mark quotas out of date";
2145 static const char *es2 = ". Run chkdsk."; 2142 static const char *es2 = ". Run chkdsk.";
2146 2143
@@ -2165,7 +2162,7 @@ get_ctx_vol_failed:
2165 static const char *es2 = ". Run chkdsk."; 2162 static const char *es2 = ". Run chkdsk.";
2166 2163
2167 /* If a read-write mount, convert it to a read-only mount. */ 2164 /* If a read-write mount, convert it to a read-only mount. */
2168 if (!(sb->s_flags & MS_RDONLY)) { 2165 if (!sb_rdonly(sb)) {
2169 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO | 2166 if (!(vol->on_errors & (ON_ERRORS_REMOUNT_RO |
2170 ON_ERRORS_CONTINUE))) { 2167 ON_ERRORS_CONTINUE))) {
2171 ntfs_error(sb, "%s and neither on_errors=" 2168 ntfs_error(sb, "%s and neither on_errors="
@@ -2183,7 +2180,7 @@ get_ctx_vol_failed:
2183 NVolSetErrors(vol); 2180 NVolSetErrors(vol);
2184 } 2181 }
2185 /* If (still) a read-write mount, stamp the transaction log. */ 2182 /* If (still) a read-write mount, stamp the transaction log. */
2186 if (!(sb->s_flags & MS_RDONLY) && !ntfs_stamp_usnjrnl(vol)) { 2183 if (!sb_rdonly(sb) && !ntfs_stamp_usnjrnl(vol)) {
2187 static const char *es1 = "Failed to stamp transaction log " 2184 static const char *es1 = "Failed to stamp transaction log "
2188 "($UsnJrnl)"; 2185 "($UsnJrnl)";
2189 static const char *es2 = ". Run chkdsk."; 2186 static const char *es2 = ". Run chkdsk.";
@@ -2314,7 +2311,7 @@ static void ntfs_put_super(struct super_block *sb)
2314 * If a read-write mount and no volume errors have occurred, mark the 2311 * If a read-write mount and no volume errors have occurred, mark the
2315 * volume clean. Also, re-commit all affected inodes. 2312 * volume clean. Also, re-commit all affected inodes.
2316 */ 2313 */
2317 if (!(sb->s_flags & MS_RDONLY)) { 2314 if (!sb_rdonly(sb)) {
2318 if (!NVolErrors(vol)) { 2315 if (!NVolErrors(vol)) {
2319 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) 2316 if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY))
2320 ntfs_warning(sb, "Failed to clear dirty bit " 2317 ntfs_warning(sb, "Failed to clear dirty bit "