OSDN Git Service

Implement poor man's exception handling to prevent errors from killling recovery
authorKen Sumrall <ksumrall@android.com>
Thu, 24 Mar 2011 05:08:53 +0000 (22:08 -0700)
committerKen Sumrall <ksumrall@android.com>
Fri, 25 Mar 2011 02:53:30 +0000 (19:53 -0700)
commit2ae7663e1e064000356ee9e49ebd08bdddc545f9
tree038d0149c7d7f779da0487442bf3f4bf20c729b7
parent8c00dae657ce7941121ec218d07adeab9ee3d8a1
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
ext4_utils/ext4_utils.c
ext4_utils/ext4_utils.h
ext4_utils/make_ext4fs.c