GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LFS / V1-12-3 > lfs_lcp / mv2304


Interface   Data Structures   File List   Data Fields   Globals  

LFS_lcp_command.c File Reference

Routines associated with CCSDS commands to subsystem LFS. More...

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <PBI/Endianness.h>
#include <PBS/WCT.h>
#include <PBS/SEM.h>
#include <PBS/WUT.h>
#include <MSG/MSG_pubdefs.h>
#include <CCSDS/CCSDS_pkt.h>
#include <ITC/ITC_pubdefs.h>
#include <LSF/LSF.h>
#include <LSF/LSF_ids.h>
#include <FBS/FBS_pubrtos.h>
#include <LFS/LFS_cmddefs.h>
#include <LFS/LFS_cmdxtrn.h>
#include <LFS/LFS_tlmdefs.h>
#include <LFS/LFS_msg.h>
#include <QLFS/QLFS.h>
#include <LFS_lcp_private.h>

Defines

#define CREAT(_path, _mode)   creat((_path), 0666)
#define MKDIR(_path)   mkdir((_path), 0777)
#define STATFS(_path, _buf)   statfs((_path), (_buf))
#define DIR_EXISTS   (EEXIST)

Typedefs

typedef struct statfs STATFS_T

Functions

static unsigned int LFS_dumpDir (LFS_Control *ctl, DIR *directory, unsigned int cpu, unsigned int devNum, unsigned int dirNum, unsigned int xactId)
static unsigned int LFS_dumpRoot (LFS_Control *ctl, DIR *directory, unsigned int cpu, unsigned int devNum, unsigned int xactId)
static unsigned int LFS_dirEmpty (LFS_Control *ctl, unsigned int cpu, unsigned int devNum, unsigned int dirNum, unsigned int xactId)
unsigned int LFS_FileDelete (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSFILEDELETE command.
unsigned int LFS_FileCopy (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSFILECOPY command.
unsigned int LFS_DirCreate (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSDIRCREATE command.
unsigned int LFS_DirDelete (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSDIRDELETE command.
unsigned int LFS_FileDumpCTDB (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSFILEDUMPC command.
unsigned int LFS_FileDumpSSR (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSFILEDUMPS command.
unsigned int LFS_DirDump (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSDIRDUMP command.
unsigned int LFS_SysStatus (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSSYSSTATUS command.
unsigned int LFS_SysFormat (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSSYSFORMAT command.
unsigned int LFS_SysCheck (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSSYSCHECK command.
unsigned int LFS_SysRepair (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSSYSREPAIR command.
unsigned int LFS_SysMount (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSSYSMOUNT command.
unsigned int LFS_Noop (void *prm, const struct _ITC_QueueItem *qitem, void *pay, unsigned int len)
 Callback function for the LFSNOOP command.


Detailed Description

Routines associated with CCSDS commands to subsystem LFS.

Author:
D.L. Wood

Define Documentation

#define CREAT ( _path,
_mode   )     creat((_path), 0666)

Portable macro for creat() system call.

Referenced by LFS_FileCopy().

#define DIR_EXISTS   (EEXIST)

Portable errno value for directory overwrite protection.

Referenced by LFS_DirCreate().

#define MKDIR ( _path   )     mkdir((_path), 0777)

Portable macro for mkdir() system call.

Referenced by LFS_DirCreate().

#define STATFS ( _path,
_buf   )     statfs((_path), (_buf))

Portable call to statfs()/statvfs() system call.

Referenced by LFS_SysStatus().


Typedef Documentation

Portable definition for statfs/statvfs structure.


Function Documentation

unsigned int LFS_DirCreate ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSDIRCREATE command.

After translating the target directory path, the directory is created.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, DIR_EXISTS, _LFS_DirCreate_Prm::fileId, _LFS_DirCreate_Prm::flag, MKDIR, _LFS_Control::node_id, _LFS_Control::path_str_0, _LFS_Control::path_str_1, and _LFS_NODETRANID::us.

unsigned int LFS_DirDelete ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSDIRDELETE command.

After translating the target directory path, the directory is deleted.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, _LFS_DirDelete_Prm::fileId, _LFS_DirDelete_Prm::flag, _LFS_Control::node_id, _LFS_Control::path_str_0, and _LFS_NODETRANID::us.

unsigned int LFS_DirDump ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSDIRDUMP command.

The target directory is opened for reading, and either LFS_dumpDir() or LFS_dumpRoot() is called to generate the telemetry response diagnostic packets.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, _LFS_DirDump_Prm::fileId, _LFS_DirDump_Prm::flag, LFS_bootDumpDir(), LFS_dumpDir(), LFS_dumpRoot(), _LFS_Control::node_id, _LFS_Control::path_str_0, and _LFS_NODETRANID::us.

static unsigned int LFS_dirEmpty ( LFS_Control ctl,
unsigned int  cpu,
unsigned int  devNum,
unsigned int  dirNum,
unsigned int  xactId 
) [static]

Sends a single LLFSDIREMPTY telemetry packet to positively acknowledge a LFSDIRDUMP telecommand when the target root or sub directory is empty.

Parameters:
ctl LFS control structure.
cpu The LAT CPU unit number.
devNum The device number.
dirNum The directory number.
xactId The transaction ID.
Returns:
A LFS MSG code.

References _LFS_DUMPSTFLAGS::bf, _LFS_LLFSDIREMPTY_Tlm::dmpFlags, _LFS_LLFSDIREMPTY_Tlm::fileId, _LFS_Control::itc_hdr_size, LFS_freeTelem(), LFS_LLFSDIREMPTY_TLM_APID, _LFS_Control::node_id, _LFS_Control::telem_buf, _LFS_Control::telem_hdr_size, _LFS_Control::telem_pool, _LFS_Control::telem_sem, _LFS_FILESTID::ui, and _LFS_DUMPSTFLAGS::us.

Referenced by LFS_dumpDir(), and LFS_dumpRoot().

static unsigned int LFS_dumpDir ( LFS_Control ctl,
DIR *  directory,
unsigned int  cpu,
unsigned int  devNum,
unsigned int  dirNum,
unsigned int  xactId 
) [static]

Dumps the contents of a sub-directory into directory dump telemetry packets. The function is called in response to a LFSDIRDUMP telecommand when the directory number is not '127' (regular subdirectory). A series of LLFSDIRLIST telemetry packets is generated, one for each entry in the directory. Only regular files should be stored here.

Parameters:
ctl LFS control structure.
directory The directory stream pointer.
cpu The LAT CPU unit number.
devNum The device number.
dirNum The directory number.
xactId The transaction ID.
Returns:
A LFS MSG code.

References _LFS_FILESTFLAGS::bf, _LFS_DUMPSTFLAGS::bf, _LFS_LLFSDIRLIST_Tlm::dmpFlags, _LFS_LLFSDIRLIST_Tlm::fileBlocks, _LFS_LLFSDIRLIST_Tlm::fileFlags, _LFS_LLFSDIRLIST_Tlm::fileHdr, _LFS_LLFSDIRLIST_Tlm::fileId, _LFS_LLFSDIRLIST_Tlm::fileSize, _LFS_LLFSDIRLIST_Tlm::fileTime, _LFS_Control::itc_hdr_size, LFS_dirEmpty(), LFS_freeTelem(), LFS_LLFSDIRLIST_TLM_APID, _LFS_Control::node_id, _LFS_Control::telem_buf, _LFS_Control::telem_hdr_size, _LFS_Control::telem_pool, _LFS_Control::telem_sem, _LFS_FILESTID::ui, _LFS_FILESTFLAGS::us, and _LFS_DUMPSTFLAGS::us.

Referenced by LFS_DirDump().

static unsigned int LFS_dumpRoot ( LFS_Control ctl,
DIR *  directory,
unsigned int  cpu,
unsigned int  devNum,
unsigned int  xactId 
) [static]

Dumps the contents of the root directory into directory dump telemetry packets. The function is called in response to a LFSDIRDUMP telecommand when the directory number is specified as '127'. A series of LLFSROOTLIST telemetry packets is generated, one for each entry in the device root directory. Only sub-directories should be stored here.

Parameters:
ctl LFS control structure.
directory The directory stream pointer.
cpu The LAT CPU unit number.
devNum The device number.
xactId The trasaction ID.
Returns:
A LFS MSG code.

References _LFS_FILESTFLAGS::bf, _LFS_DUMPSTFLAGS::bf, _LFS_LLFSROOTLIST_Tlm::dmpFlags, _LFS_LLFSROOTLIST_Tlm::fileBlocks, _LFS_LLFSROOTLIST_Tlm::fileFlags, _LFS_LLFSROOTLIST_Tlm::fileId, _LFS_LLFSROOTLIST_Tlm::fileSize, _LFS_LLFSROOTLIST_Tlm::fileTime, _LFS_Control::itc_hdr_size, LFS_dirEmpty(), LFS_freeTelem(), LFS_LLFSROOTLIST_TLM_APID, _LFS_Control::node_id, _LFS_Control::telem_buf, _LFS_Control::telem_hdr_size, _LFS_Control::telem_pool, _LFS_Control::telem_sem, _LFS_FILESTID::ui, _LFS_FILESTFLAGS::us, and _LFS_DUMPSTFLAGS::us.

Referenced by LFS_DirDump().

unsigned int LFS_FileCopy ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSFILECOPY command.

After translating the file system paths, the source file contents are copied to the destination file.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, _LFS_Control::config, _LFS_Control::copy_buf, CREAT, _LFS_FileCopy_Prm::destFileId, _LFS_FileCopy_Prm::flag, _LFS_Control::node_id, _LFS_Control::path_str_0, _LFS_Control::path_str_1, _LFS_FileCopy_Prm::srcFileId, and _LFS_NODETRANID::us.

unsigned int LFS_FileDelete ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSFILEDELETE command.

After translating the target file path, the file is deleted.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, _LFS_FileDelete_Prm::fileId, _LFS_FileDelete_Prm::flag, _LFS_Control::node_id, _LFS_Control::path_str_0, and _LFS_NODETRANID::us.

unsigned int LFS_FileDumpCTDB ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSFILEDUMPC command.

After translating the file ID to a path, the file is opened for reading and a series of LLFSDUMPCTDB telemetry packets is generated. Each telemetry packet contains a portion of the file data, and the offset and size members provide the attributes of the data contained in each packet. These telemetry packets are delivered to the CTDB interface.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_DUMPSTFLAGS::bf, _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, _LFS_Control::config, _LFS_LLFSDUMPCTDB_Tlm::dmpFlags, _LFS_LLFSDUMPCTDB_Tlm::dmpSize, _LFS_LLFSDUMPCTDB_Tlm::fileData, _LFS_LLFSDUMPCTDB_Tlm::fileId, _LFS_FileDumpCTDB_Prm::fileId, _LFS_LLFSDUMPCTDB_Tlm::fileOffset, _LFS_FileDumpCTDB_Prm::flag, _LFS_Control::itc_hdr_size, LFS_bootDumpFile(), LFS_FILE_DUMP_PARAM_SIZE, LFS_freeTelem(), LFS_LLFSDUMPCTDB_TLM_APID, _LFS_Control::node_id, _LFS_Control::path_str_0, _LFS_Control::telem_buf, _LFS_Control::telem_hdr_size, _LFS_Control::telem_pool, _LFS_Control::telem_sem, _LFS_FILESTID::ui, _LFS_DUMPSTFLAGS::us, and _LFS_NODETRANID::us.

unsigned int LFS_FileDumpSSR ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSFILEDUMPS command.

After translating the file ID to a path, the file is opened for reading and a series of LLFSDUMPSSR telemetry packets is generated. Each telemetry packet contains a portion of the file data, and the offset and size members provide the attributes of the data contained in each packet. These telemetry packets are delivered to the SSR interface. Each telemetry packet contains one QLFS datagram.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODETRANID::bf, _LFS_Control::cmd_hdr_size, _LFS_Control::config, _LFS_FileDumpSSR_Prm::fileId, _LFS_FileDumpSSR_Prm::flag, _LFS_Control::itc_hdr_size, LFS_apidMap(), LFS_bootDumpFileSSR(), LFS_freeTelemSSR(), _LFS_Control::node_id, _LFS_Control::path_str_0, _LFS_Control::telem_buf, _LFS_Control::telem_hdr_size, _LFS_Control::telem_sem, and _LFS_NODETRANID::us.

unsigned int LFS_Noop ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSNOOP command.

Do nothing except generate command confirm reply.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODEPAD::bf, _LFS_Control::cmd_hdr_size, _LFS_Noop_Prm::flag, _LFS_Control::node_id, and _LFS_NODEPAD::us.

unsigned int LFS_SysCheck ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSSYSCHECK command.

Consistency check an on-board file system by running the 'chkdsk' utility.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODEPAD::bf, _LFS_Control::cmd_hdr_size, _LFS_SysCheck_Prm::fileID, _LFS_SysCheck_Prm::flag, _LFS_Control::node_id, and _LFS_NODEPAD::us.

unsigned int LFS_SysFormat ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSSYSFORMAT command.

Re-format an on-board file system. This is potentially dangerous.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODEPAD::bf, _LFS_Control::cmd_hdr_size, _LFS_SysFormat_Prm::fileID, _LFS_SysFormat_Prm::flag, _LFS_Control::node_id, _LFS_SysFormat_Prm::sysOffset, and _LFS_NODEPAD::us.

unsigned int LFS_SysMount ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSSYSMOUNT command.

Manually mount an on-board file system.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODEPAD::bf, _LFS_Control::cmd_hdr_size, _LFS_SysMount_Prm::fileID, _LFS_SysMount_Prm::flag, _LFS_Control::node_id, and _LFS_NODEPAD::us.

unsigned int LFS_SysRepair ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSSYSREPAIR command.

Repair an on-board file system by running the 'chkdsk' utility with the repair flag set to true.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_NODEPAD::bf, _LFS_Control::cmd_hdr_size, _LFS_SysRepair_Prm::fileID, _LFS_SysRepair_Prm::flag, _LFS_Control::node_id, and _LFS_NODEPAD::us.

unsigned int LFS_SysStatus ( void *  prm,
const struct _ITC_QueueItem qitem,
void *  pay,
unsigned int  len 
)

Callback function for the LFSSYSSTATUS command.

After the target file system status is obtained from the system, a single LLFSSYSREPORT telemetry packet is generated to report the results.

Parameters:
prm User context parameter
qitem Queue item
pay Payload pointer
len Payload length
Returns:
A LFS MSG code.

References _LFS_DUMPSTFLAGS::bf, _LFS_NODETRANID::bf, _LFS_LLFSSYSLIST_Tlm::blkFree, _LFS_LLFSSYSLIST_Tlm::blkSize, _LFS_LLFSSYSLIST_Tlm::blkTotal, _LFS_Control::cmd_hdr_size, _LFS_LLFSSYSLIST_Tlm::dmpFlags, _LFS_LLFSSYSLIST_Tlm::fileId, _LFS_SysStatus_Prm::fileId, _LFS_SysStatus_Prm::flag, _LFS_Control::itc_hdr_size, LFS_freeTelem(), LFS_LLFSSYSLIST_TLM_APID, _LFS_Control::node_id, _LFS_Control::path_str_0, STATFS, _LFS_Control::telem_buf, _LFS_Control::telem_hdr_size, _LFS_Control::telem_pool, _LFS_Control::telem_sem, _LFS_FILESTID::ui, _LFS_DUMPSTFLAGS::us, and _LFS_NODETRANID::us.


Generated on Wed Nov 21 21:49:08 2012 by  doxygen 1.5.8