GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > FILE / V3-8-0

Constituent: file_path     Tag: mv2304


Interface   Data Structures   File List   Data Fields   Globals  

FILE_path.h File Reference

File Path Utility Library. More...

#include "FILE/FILE_path_msg.h"
#include "FILE/FILE_defs.h"
#include <sys/types.h>

Include dependency graph for FILE_path.h:

This graph shows which files directly or indirectly include this file:


Defines

#define FILE_M_MODULE   ( 0x0200 )
 Module number in the errno sense.
#define FILE_S_SUCCESS   ( FILE_M_MODULE | 0x0000 )
 File opened successfully (not a read-only request).
#define FILE_S_NOHED   ( FILE_M_MODULE | 0x0004 )
 File opened successfully (no FSW header found).
#define FILE_S_HEDNOCMP   ( FILE_M_MODULE | 0x0008 )
 File opened successfully (FSW header found, file not compressed).
#define FILE_S_HEDCMP   ( FILE_M_MODULE | 0x000c )
 File opened successfully (FSW header found, file compressed).
#define FILE_E_CORRUPT   ( FILE_M_MODULE | 0x0003 )
 File open failed (the adler32 checksum of the body failed).
#define FILE_E_NOMKDIR   ( FILE_M_MODULE | 0x0007 )
 File open failed (could not create directory for temporary file).
#define FILE_E_NOSLOT   ( FILE_M_MODULE | 0x000b )
 File open failed (no more slots to store temporary file info).
#define FILE_E_NOTMPOPN   ( FILE_M_MODULE | 0x000f )
 File open failed (could not open temporary file).
#define FILE_E_NOINFLAT   ( FILE_M_MODULE | 0x0013 )
 File open failed (inflation step failed).
#define FILE_E_NOREOPEN   ( FILE_M_MODULE | 0x0017 )
 File open failed (could not reopen temporary file read-only).

Functions

unsigned int FILE_pathInit (const char *usrName5, const char *usrName6)
 Initialize the file path mapping library.
unsigned int FILE_pathSizeof (void)
 Get the size of a file path string.
unsigned int FILE_pathIdToNum (unsigned int id, unsigned int *dev, unsigned int *dir, unsigned int *file)
 Translates a file ID word into component numbers.
unsigned int FILE_pathNumToId (unsigned int *id, unsigned int dev, unsigned int dir, unsigned int file)
 Translates file component numbers to an ID word.
unsigned int FILE_pathIdToPath (unsigned int id, char *str)
 Translates file ID word to an ASCII path name.
int FILE_close (int fid)
 Close a FSW file (regular, headed/not-headed, compressed/not-compressed).
int FILE_open (const char *fil, int opt, mode_t mod)
 Open a FSW file (regular, headed/not-headed, compressed/not-compressed).

Detailed Description

File Path Utility Library.

Author:
D.L. Wood
This library contains functions for manipulating LAT file ID and path elements.

Function Documentation

int FILE_close int  fd  ) 
 

Close a FSW file (regular, headed/not-headed, compressed/not-compressed).

Parameters:
fd (in) File descriptor (conventional meaning)
Return values:
0 Success
-1 Failure (use errno for retrieve further details)
FILE_close() is the complement to FILE_open(). The only value added of FILE_close() over close() is that FILE_close() will check the file descriptor of the file being closed, and if it corresponds to a temporary inflation file, it will delete the file.

int FILE_open const char *  fil,
int  flg,
mode_t  mod
 

Open a FSW file (regular, headed/not-headed, compressed/not-compressed).

Parameters:
fil (in) File name
flg (in) Open flags (O_RDONLY, O_WRONLY, O_RDWR, O_CREAT)
mod (in) Access mode (only used for NFS file creation)
Return values:
x File descriptor
-1 Failure
Warning:
If you open a file with FILE_open(), you must close it with FILE_close().
FILE_open() is designed to overlay the classic open() routine, adding the ability to deal with special format files peculiar to flight software. The call structure is identical to open(). If the open mode is O_WRONLY or O_RDWR, FILE_open() and open() are indistinguishable. If the open mode is O_RDONLY, things start to get exciting.

Flight software files appear in three different formats:

  • Regular file
  • Prefixed by a header, uncompressed
  • Prefixed by a header, compressed

When FILE_open() is asked to open any of these formats, it will first inspect the file to classify it. The adler32 checksum in the header is very powerful here. Subsequent processing depends on the file format:

  • Regular file. Indistinguishable from open() on the same file.
  • Prefixed by a header, uncompressed. The body of the file is adler32 check-summed. If it passes, the caller is returned a regular file descriptor with the file pointer pointing to the first byte past the header.
  • Prefixed by a header, compressed. The body of the file is adler32 check-summed. If it passes, the file is inflated in a temporary file (in /tmp/d000 on unix, in /ram/d000 in VxWorks). The original file is closed, the inflated file is opened O_RDONLY, and a file descriptor for the inflated file is returned to the caller. The temporary file is deleted when the file is closed (though the caller must use FILE_close() to close the file, not a simple close() call).

In keeping with the idea that FILE_open() is modeled on open(), the errno method is used to return extra information. One unusual feature of this is that errno can contain helpful information, even when the file open is successful.

If the return value is not -1 (i.e. the open succeeded), errno can contain:

  • FILE_S_SUCCESS Successfully opened a regular file, not in O_RDONLY mode
  • FILE_S_NOHED Successfully opened a regular file, in O_RDONLY mode
  • FILE_S_HEDNOCMP Successfully opened an uncompressed file with FSW header
  • FILE_S_HEDCMP Successfully opened a compressed file with FSW header

If the return value is -1 (i.e. the open failed), errno, in addition to any of the regular values that open() can return, can contain:

  • FILE_E_CORRUPT Adler32 of file body failed
  • FILE_E_NOMKDIR Could not make a temporary directory for inflation
  • FILE_E_NOSLOT Could not allocate a temporary file slot
  • FILE_E_NOTMPOPN Could not open the temporary file
  • FILE_E_NOINFLAT File inflation failed
  • FILE_E_NOREPOEN Could not reopen the temporary file after inflation

If you wish to use these values for additional checking, note that errno is a four byte word encoded as two two-byte units. The most significant unit is a module number and the lower unit is the "error" number. The additional error codes defined by FILE_open() are module 0x200 (to avoid collisions with unix and VxWorks error codes), and the error numbers obey MSG conventions, i.e. if the least significant bit is clear, the operation was a success.

unsigned int FILE_pathIdToNum unsigned int  id,
unsigned int *  dev,
unsigned int *  dir,
unsigned int *  file
 

Translates a file ID word into component numbers.

Breaks a file ID word into its numerical components, which are stored in the user supplied dev, dir, and file locations.

Parameters:
id The file ID word.
dev Storage for the device number.
dir Storage for the directory number.
file Storage for the file number.
Returns:
A FILE MSG value.

unsigned int FILE_pathIdToPath unsigned int  id,
char *  str
 

Translates file ID word to an ASCII path name.

Creates a file system path string from a set of file ID components. The result is stored in the user supplied str location. The resulting path string is appropriate for use with the file system API functions.

Parameters:
id The file ID word.
str Storage for the file path string.
Returns:
A FILE MSG value.

unsigned int FILE_pathInit const char *  usrName5,
const char *  usrName6
 

Initialize the file path mapping library.

Sets the root partition names for device numbers '5' and '6' (FILE_DEV_NUM_USR0 and FILE_DEV_NUM_USR1). The names from usrName5 and usrName6 will be used when calling function FILE_pathIdToPath().

Parameters:
usrName5 Root name for device 5; must start with '/' (use NULL to invalidate).
usrName6 Root name for device 6; must start with '/' (use NULL to invalidate).
Returns:
A FILE MSG value.

unsigned int FILE_pathNumToId unsigned int *  id,
unsigned int  dev,
unsigned int  dir,
unsigned int  file
 

Translates file component numbers to an ID word.

Composes a new file ID word from its numerical components. The result is stored in the user supplied id location.

Parameters:
id Storage for the file ID word.
dev The device number.
dir The directory number.
file The file number.
Returns:
A FILE MSG value.

unsigned int FILE_pathSizeof void   ) 
 

Get the size of a file path string.

Returns the number of bytes needed to hold an on-board file path string.

Returns:
The path string size in bytes.


Generated on Sun Oct 9 20:28:43 2005 by  doxygen 1.4.4