nasa / FM

The Core Flight System (cFS) File Manager (FM) application.
Apache License 2.0
42 stars 24 forks source link

Directory entries are read even after packet is full (not necessary) #42

Closed skliper closed 2 years ago

skliper commented 2 years ago

Checklist (Please check before submitting)

Is your feature request related to a problem? Please describe. Could simplify logic and avoid looping through entire directory even after packet is full: https://github.com/nasa/FM/blob/9210c2d314d3506fb50560d9bc6513c2b7fb4983/fsw/src/fm_child.c#L1247-L1266

Describe the solution you'd like

        while (Status == OS_SUCCESS && FM_GlobalData.DirListPkt.PacketFiles < FM_DIR_LIST_PKT_ENTRIES)
        {
            /* Read next directory entry */
            Status = OS_DirectoryRead(DirId, &DirEntry);

            if (Status == OS_SUCCESS && (strcmp(OS_DIRENTRY_NAME(DirEntry), FM_THIS_DIRECTORY) != 0) &&
                     (strcmp(OS_DIRENTRY_NAME(DirEntry), FM_PARENT_DIRECTORY) != 0))
            {
                /* Do not count the "." and ".." directory entries */
                FM_GlobalData.DirListPkt.TotalFiles++;

                /* Start collecting directory entries at command specified offset */
                /* Stop collecting directory entries when telemetry packet is full */
                if (FM_GlobalData.DirListPkt.TotalFiles > FM_GlobalData.DirListPkt.FirstFile)
                {

Describe alternatives you've considered None

Additional context None

Requester Info Jacob Hageman - NASA/GSFC

skliper commented 2 years ago

Nevermind. This entire directory is traversed so that TotalFiles is accurate. Marking invalid.