tpmc: Make 'tpmc def' replace the existing space by default

In chromium:895549, we want to have consistent behavior of
'tpmc def' between TPM 1.2 and TPM 2.0.
In TPM 1.2, define space command will undefine the existing space,
and create a new one. So we make the 'tpmc def' act as this by
default.

Also, provide a option for whom may want to define a new space
only if it is not defined yet. It will return TPM error code
at that case.

BUG=chromium:895549
BRANCH=None
TEST=unit test; manually test:

 # For TPM 2.0 use AUTHREAD|AUTHWRITE
 tpmc tpmversion | grep 2.0 && export PERM=0x40004
 tpmc tpmversion | grep 1.2 && export PERM=0x1

 # Define the space
 tpmc def 0x1020 0x1 "$PERM"

 # Redefine the space, default will overwrite
 tpmc def 0x1020 0x1 "$PERM"
 # Expected: Success

 tpmc def 0x1020 0x1 "$PERM" --no-overwrite
 # Expected: output error for the space is already defined.
 # For TPM 2.0, it should output:
 #  command "def" failed with code 0x14c
 #  the TPM error code is unknown to this program
 # For TPM 1.2, it should output:
 #  The space is existing but --no-overwrite is set.

Change-Id: I9b4e742f2935578443ebcc69e91d0aebc84deed8
Reviewed-on: https://chromium-review.googlesource.com/1298098
Commit-Ready: Meng-Huan Yu <menghuan@chromium.org>
Tested-by: Meng-Huan Yu <menghuan@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
1 file changed