Esempio n. 1
0
/*---------------------------------------------------------------------------------------
    Name: OS_initfs

    Purpose: Inititalizes a file system on the target
    
    Returns: OS_FS_ERR_INVALID_POINTER if devname is NULL
             OS_FS_DRIVE_NOT_CREATED if the OS calls to create the the drive failed
             OS_FS_SUCCESS on creating the disk
---------------------------------------------------------------------------------------*/
int32 OS_initfs (char *address,char *devname, char *volname, 
                uint32 blocksize, uint32 numblocks)
{
    int i;
/*    char Command[ OS_MAX_PATH_LEN +10 ]; */
    char FolderName[OS_MAX_PATH_LEN];
    
    /* find an open entry in the Volume Table */
    for (i = 0; i < NUM_TABLE_ENTRIES; i++)
    {
        if (OS_VolumeTable[i].FreeFlag == TRUE && OS_VolumeTable[i].IsMounted == FALSE
            && strcmp(OS_VolumeTable[i].DeviceName, devname) == 0)
            break;
    }

    if (i >= NUM_TABLE_ENTRIES)
        return OS_FS_ERR_DEVICE_NOT_FREE;


    /* make a disk if it is FS based */
    /*------------------------------- */
    if (OS_VolumeTable[i].VolumeType == FS_BASED)
    {

       /* now enter the info in the table */

       OS_VolumeTable[i].FreeFlag = FALSE;
       strcpy(OS_VolumeTable[i].VolumeName, volname);
       OS_VolumeTable[i].BlockSize = blocksize;
    
       /* note we don't know the mount point yet */
    
       /* for linux/osx we need to make the folder where this drive is located */
       strcpy(FolderName, OS_VolumeTable[i].PhysDevName);
       strcat(FolderName, devname);

    
       /* make the directory where the file system lives */
/*       sprintf(Command,"mkdir -p %s", FolderName);
       system(Command); */
       OS_mkdir(FolderName,0);
       
    }   /* VolumeType is something else that is not supported right now */
    else
    {
        return OS_FS_ERROR;
    }

   return OS_FS_SUCCESS; 
}/* end OS_initfs */
Esempio n. 2
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int main(void)
{

    /*
    ** API function hook handlers
    */
    UTF_SB_set_function_hook(CFE_SB_SUBSCRIBE_HOOK, (void *)&CFE_SB_SubscribeHook);


    /*
    ** Set up output file and HK packet handler
    */
    UTF_set_output_filename("fm_utest.out");
    UTF_set_packet_handler(FM_HK_TLM_MID, (utf_packet_handler)PrintHKPacket);
    UTF_set_packet_handler(FM_DIR_LIST_TLM_MID, (utf_packet_handler)PrintListPacket);
    UTF_set_packet_handler(FM_FILE_INFO_TLM_MID, (utf_packet_handler)PrintInfoPacket);
    UTF_set_packet_handler(FM_OPEN_FILES_TLM_MID, (utf_packet_handler)PrintOpenPacket);
    UTF_set_packet_handler(FM_FREE_SPACE_TLM_MID, (utf_packet_handler)PrintFreePacket);

    /*
    ** Initialize time data structures
    */
    UTF_init_sim_time(0.0);

    /*
    ** Initialize ES application data
    */
    UTF_ES_InitAppRecords();
    UTF_ES_AddAppRecord("FM",0);
    CFE_ES_RegisterApp();

    /*
    ** Initialize CDS and table services data structures
    */
    CFE_ES_CDS_EarlyInit();
    CFE_TBL_EarlyInit();

    CFE_EVS_Register(NULL, 0, 0);
    /*
     * Setup the virtual/physical file system mapping...
     *
     * The following local machine directory structure is required:
     *
     * ... fm/fsw/unit_test      <-- this is the current working directory
     * ... fm/fsw/unit_test/ram  <-- physical location for virtual disk "/ram"
     */
    UTF_add_volume("/", "ram", FS_BASED, FALSE, FALSE, TRUE, "RAM", "/ram", 0);

    OS_mkdir("/ram/sub",0);
    OS_mkdir("/ram/sub2",0);
    OS_mkdir("/ram/sub2/sub22",0);
    OS_mkdir("/ram/sub3",0);

    /*
    ** Run FM application unit tests
    */
    UT_TotalTestCount = 0;
    UT_TotalFailCount = 0;

    UTF_put_text("\n*** FM -- Testing fm_app.c ***\n");
    Test_app();

    UTF_put_text("\n*** FM -- Testing fm_cmds.c ***\n");
    Test_cmds();

    UTF_put_text("\n*** FM -- Testing fm_cmd_utils.c ***\n");
    Test_utils();

    UTF_put_text("\n*** FM -- Testing fm_child.c ***\n");
    Test_child();

    UTF_put_text("\n*** FM -- Testing fm_tbl.c ***\n");
    Test_tbl();

    UTF_put_text("\n*** FM -- Total test count = %d, total test errors = %d\n\n", UT_TotalTestCount, UT_TotalFailCount);

    /*
    ** Remove directories created for these tests...
    */
    OS_rmdir("/ram/sub3");
    OS_rmdir("/ram/sub2/sub22");
    OS_rmdir("/ram/sub2");
    OS_rmdir("/ram/sub");

    /*
    ** Invoke the main loop test now because the program will end
    **  when the last entry in the SB sim input file is read.
    */
    UTF_CFE_ES_Set_Api_Return_Code(CFE_ES_RUNLOOP_PROC, TRUE);
    FM_AppMain();
    UTF_CFE_ES_Use_Default_Api_Return_Code(CFE_ES_RUNLOOP_PROC);

    return 0;

} /* End of main() */