diff options
author | Ken Sumrall <ksumrall@android.com> | 2011-03-23 22:08:53 -0700 |
---|---|---|
committer | Ken Sumrall <ksumrall@android.com> | 2011-03-24 19:53:30 -0700 |
commit | 2ae7663e1e064000356ee9e49ebd08bdddc545f9 (patch) | |
tree | 038d0149c7d7f779da0487442bf3f4bf20c729b7 /ext4_utils/ext4_utils.c | |
parent | 8c00dae657ce7941121ec218d07adeab9ee3d8a1 (diff) | |
download | extras-2ae7663e1e064000356ee9e49ebd08bdddc545f9.tar.gz |
Implement poor man's exception handling to prevent errors from killling recovery
make_ext4fs was originally designed to be a standalone program, and the
error() macro calls exit() after printing a diagnostic. However, when
it was turned into a library that recovery links against, calling exit()
kills the entire recovery process, which the kernel starts back up,
which dies, and the cycle continues.
This changes make_ext4fs to use setjmp() early, and changes error to
use longjmp to return to that point. When longjmp is called, the
error handler just returns an error. If it was invoked as a standalone
program, this causes the program to exit with an error. If it was
invoked as a library function, the error return is gracefully handled
by recovery.
Change-Id: Iad50f46cac0ac399b5cdfd083d5712f88a10e48e
Diffstat (limited to 'ext4_utils/ext4_utils.c')
-rw-r--r-- | ext4_utils/ext4_utils.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c index 211448c6..f4f04d90 100644 --- a/ext4_utils/ext4_utils.c +++ b/ext4_utils/ext4_utils.c @@ -42,6 +42,8 @@ int force = 0; struct fs_info info; struct fs_aux_info aux_info; +jmp_buf setjmp_env; + /* returns 1 if a is a power of b */ static int is_power_of(int a, int b) { |