libfru 3.0
FRU Manupulation Library
Loading...
Searching...
No Matches
Common

Common definitions for the library. More...

Data Structures

struct  fru_errno_t
 

Enumerations

enum  fru_error_code_t {
  FENONE ,
  FEGENERIC ,
  FEINIT ,
  FENONPRINT ,
  FENONHEX ,
  FERANGE ,
  FENOTEVEN ,
  FEAUTOENC ,
  FEBADENC ,
  FE2SMALL ,
  FE2BIG ,
  FESIZE ,
  FEHDRVER ,
  FEHDRCKSUM ,
  FEHDRBADPTR ,
  FEDATACKSUM ,
  FEAREADUP ,
  FEAREANOTSUP ,
  FEAREABADTYPE ,
  FENOTERM ,
  FEBDATE ,
  FENOFIELD ,
  FENOREC ,
  FEBADDATA ,
  FENODATA ,
  FEMRMGMTBAD ,
  FEMRNOTSUP ,
  FEMREND ,
  FEAPOS ,
  FENOTEMPTY ,
  FEAENABLED ,
  FEADISABLED ,
  FELIB ,
  FETOTALCOUNT
}
 Defines the errors specific to libfru. More...
 
enum  fru_error_source_t {
  FERR_LOC_INTERNAL ,
  FERR_LOC_CHASSIS ,
  FERR_LOC_BOARD ,
  FERR_LOC_PRODUCT ,
  FERR_LOC_MR ,
  FERR_LOC_GENERAL ,
  FERR_LOC_CALLER ,
  FERR_LOC_COUNT
}
 Describes an offending area, see fru_errno_t. More...
 

Functions

const char * fru_strerr (fru_errno_t)
 Get a description of the given fru_errno value.
 
void fru_clearerr (void)
 Clear the error status of the library.
 

Variables

fru_error_code_t fru_errno_t::code
 
fru_error_source_t fru_errno_t::src
 The source of error.
 
int fru_errno_t::index
 Index of the offending entity within the source, that is, an index of a field (for FRU_*_INFO) or a record (for FRU_MR).
 
__thread fru_errno_t fru_errno
 Numeric code of an error.
 

Detailed Description

Common definitions for the library.

Enumeration Type Documentation

◆ fru_error_code_t

Defines the errors specific to libfru.

These values are applicable to fru_errno.code

Enumerator
FENONE 

No libfru error.

FEGENERIC 

Generic error, check errno.

FEINIT 

Uninitialized FRU structure.

FENONPRINT 

Field data contains non-printable bytes.

FENONHEX 

Input string contains non-hex characters.

FERANGE 

Field data exceeds range for the requested encoding.

FENOTEVEN 

Not an even number of nibbles.

FEAUTOENC 

Unable to auto-detect encoding.

FEBADENC 

Invalid encoding for a field.

FE2SMALL 

File is too small.

FE2BIG 

Data or file is too big.

FESIZE 

Data size mismatch.

FEHDRVER 

Bad header version.

FEHDRCKSUM 

Bad header checksum.

FEHDRBADPTR 

Area pointer beyond the end of file/buffer.

FEDATACKSUM 

Bad data checksum.

FEAREADUP 

Duplicate area in area order.

FEAREANOTSUP 

Unsupported area type (For a particular operation)

FEAREABADTYPE 

Bad area type (A completely wrong value)

FENOTERM 

Unterminated area.

FEBDATE 

Board manufacturing date is out of range.

FENOFIELD 

No such field.

FENOREC 

No such record.

FEBADDATA 

Malformed data.

FENODATA 

No data.

FEMRMGMTBAD 

Bad management record subtype.

FEMRNOTSUP 

Unsupported record type.

FEMREND 

End of MR records (not an error)

FEAPOS 

Invalid area position.

FENOTEMPTY 

List is not empty.

FEAENABLED 

Area is (already) enabled.

FEADISABLED 

Area is (already) disabled.

FELIB 

Internal library error (bug)

FETOTALCOUNT 

The total count of possible libfru error codes.

◆ fru_error_source_t

Describes an offending area, see fru_errno_t.

For area-related values this enum matches fru_area_type_t

Enumerator
FERR_LOC_INTERNAL 

The error is in the internal use area.

FERR_LOC_CHASSIS 

The error is in the chassis information area.

FERR_LOC_BOARD 

The error is in the board information area.

FERR_LOC_PRODUCT 

The error is in the product information area.

FERR_LOC_MR 

The error is in the multirecord area.

FERR_LOC_GENERAL 

The error is about FRU file or structure in general, not about any specific area.

This is also used when a non-area specific call, such as fru_setfield(), encounters an error.

FERR_LOC_CALLER 

The error is in the calling code (bad arguments?)

FERR_LOC_COUNT 

The total count of possible error locations.

Function Documentation

◆ fru_clearerr()

void fru_clearerr ( void  )

Clear the error status of the library.

Use this before library calls that may set fru_errno without returning an error status to ensure that the value of fru_errno that you get has indeed been set by the function you've called.

◆ fru_strerr()

const char * fru_strerr ( fru_errno_t  )

Get a description of the given fru_errno value.

Converts a numeric error represented by fru_errno into a string description of the error. If fru_errno is FEGENERIC, this function will call strerror() to obtain the description of the generic libc error.

Returns
A pointer to a constant string with the description of the error
Return values
NULLNo description found for the given value.

Variable Documentation

◆ code

fru_error_code_t fru_errno_t::code

◆ fru_errno

__thread fru_errno_t fru_errno
extern

Numeric code of an error.

Similar to errno, this thread-local variable is modified by most functons in libfru in the event of an error.

Call fru_clearerr() before invocation of any libfru function, check for non-zero values of the code field after the invocation.

Unlike errno, this variable contains the information about not just the error, but also about the part of FRU where it was detected. If the fru_errno.code is FEGENERIC, then you need to check errno for the actual error.

Please also see fru_strerr()

◆ index

int fru_errno_t::index

Index of the offending entity within the source, that is, an index of a field (for FRU_*_INFO) or a record (for FRU_MR).

This is (-1) when not applicable. That is, the area indicated by src doesn't have any fields/records, or the error is in the area as a whole, not in some particular field/record, or the error is not in a FRU area at all (e.g., src == FERR_LOC_CALLER).

For info areas this is less than the respective FRU_*_FIELD_COUNT for the standard/mandatory fields, or is FRU_*_FIELD_COUNT + X, where X is the index of the offending custom field.

For FEAREANOTSUP and FEAREABADTYPE this field contains the bad area type (see fru_area_type_t).

◆ src

fru_error_source_t fru_errno_t::src

The source of error.