aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-20 10:06:17 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-05-13 12:23:54 -0400
commit1a29af8bd740b2720caeafbffece1c0be6a9d06d (patch)
treeab0e9e7c327b20afbcbbc3ccf4063e8cd54a41a2 /fs
parent14ffd5d0b051b0b937df0cf3580a92f428ff70b1 (diff)
UBIFS: use EROFS when emulating failures
When the debugging failure emulation is enabled and UBIFS decides to emulate an I/O error, it uses EIO error code. In which case UBIFS switches into R/O mode later on. The for the user-space is that when a failure is emulated, the file-system sometimes returns EIO and sometimes EROFS. This makes it more difficult to implement user-space tests for the failure mode. Let's be consistent and return EROFS in all the cases. This patch is an improvement for the debugging code and does not affect the functionality at all. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/debug.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 06d171cefe45..ba4d795d63a3 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2650,7 +2650,7 @@ int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
2650 int len, int check) 2650 int len, int check)
2651{ 2651{
2652 if (in_failure_mode(desc)) 2652 if (in_failure_mode(desc))
2653 return -EIO; 2653 return -EROFS;
2654 return ubi_leb_read(desc, lnum, buf, offset, len, check); 2654 return ubi_leb_read(desc, lnum, buf, offset, len, check);
2655} 2655}
2656 2656
@@ -2660,7 +2660,7 @@ int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
2660 int err, failing; 2660 int err, failing;
2661 2661
2662 if (in_failure_mode(desc)) 2662 if (in_failure_mode(desc))
2663 return -EIO; 2663 return -EROFS;
2664 failing = do_fail(desc, lnum, 1); 2664 failing = do_fail(desc, lnum, 1);
2665 if (failing) 2665 if (failing)
2666 cut_data(buf, len); 2666 cut_data(buf, len);
@@ -2668,7 +2668,7 @@ int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
2668 if (err) 2668 if (err)
2669 return err; 2669 return err;
2670 if (failing) 2670 if (failing)
2671 return -EIO; 2671 return -EROFS;
2672 return 0; 2672 return 0;
2673} 2673}
2674 2674
@@ -2678,12 +2678,12 @@ int dbg_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf,
2678 int err; 2678 int err;
2679 2679
2680 if (do_fail(desc, lnum, 1)) 2680 if (do_fail(desc, lnum, 1))
2681 return -EIO; 2681 return -EROFS;
2682 err = ubi_leb_change(desc, lnum, buf, len, dtype); 2682 err = ubi_leb_change(desc, lnum, buf, len, dtype);
2683 if (err) 2683 if (err)
2684 return err; 2684 return err;
2685 if (do_fail(desc, lnum, 1)) 2685 if (do_fail(desc, lnum, 1))
2686 return -EIO; 2686 return -EROFS;
2687 return 0; 2687 return 0;
2688} 2688}
2689 2689
@@ -2692,12 +2692,12 @@ int dbg_leb_erase(struct ubi_volume_desc *desc, int lnum)
2692 int err; 2692 int err;
2693 2693
2694 if (do_fail(desc, lnum, 0)) 2694 if (do_fail(desc, lnum, 0))
2695 return -EIO; 2695 return -EROFS;
2696 err = ubi_leb_erase(desc, lnum); 2696 err = ubi_leb_erase(desc, lnum);
2697 if (err) 2697 if (err)
2698 return err; 2698 return err;
2699 if (do_fail(desc, lnum, 0)) 2699 if (do_fail(desc, lnum, 0))
2700 return -EIO; 2700 return -EROFS;
2701 return 0; 2701 return 0;
2702} 2702}
2703 2703
@@ -2706,19 +2706,19 @@ int dbg_leb_unmap(struct ubi_volume_desc *desc, int lnum)
2706 int err; 2706 int err;
2707 2707
2708 if (do_fail(desc, lnum, 0)) 2708 if (do_fail(desc, lnum, 0))
2709 return -EIO; 2709 return -EROFS;
2710 err = ubi_leb_unmap(desc, lnum); 2710 err = ubi_leb_unmap(desc, lnum);
2711 if (err) 2711 if (err)
2712 return err; 2712 return err;
2713 if (do_fail(desc, lnum, 0)) 2713 if (do_fail(desc, lnum, 0))
2714 return -EIO; 2714 return -EROFS;
2715 return 0; 2715 return 0;
2716} 2716}
2717 2717
2718int dbg_is_mapped(struct ubi_volume_desc *desc, int lnum) 2718int dbg_is_mapped(struct ubi_volume_desc *desc, int lnum)
2719{ 2719{
2720 if (in_failure_mode(desc)) 2720 if (in_failure_mode(desc))
2721 return -EIO; 2721 return -EROFS;
2722 return ubi_is_mapped(desc, lnum); 2722 return ubi_is_mapped(desc, lnum);
2723} 2723}
2724 2724
@@ -2727,12 +2727,12 @@ int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype)
2727 int err; 2727 int err;
2728 2728
2729 if (do_fail(desc, lnum, 0)) 2729 if (do_fail(desc, lnum, 0))
2730 return -EIO; 2730 return -EROFS;
2731 err = ubi_leb_map(desc, lnum, dtype); 2731 err = ubi_leb_map(desc, lnum, dtype);
2732 if (err) 2732 if (err)
2733 return err; 2733 return err;
2734 if (do_fail(desc, lnum, 0)) 2734 if (do_fail(desc, lnum, 0))
2735 return -EIO; 2735 return -EROFS;
2736 return 0; 2736 return 0;
2737} 2737}
2738 2738