Clarification need on Keil RL Flash file system

Hello Team,

Good day! 

In one of our product we are using keil RL Flash file system, file system crash has observed during the file creation and file rename operation.  Please let us know the reason to cause file system crash.

One more observation has found in file rename operation.  During the file rename operation, file lock status checking is there to check the file status, sometimes file has locked due to this problem file rename is not happening successfully.  Please clarify me of following questions,

1) What is the purpose of  fs_efs_lock function in file create and file rename operation?

2) Is this necessary to have in file rename function?

3) What is causing file rename failure other than above operation?

Please let me know your solution and suggestion as soon as possible.  If you need any other details or queries, please let me know.

Regards,

Saranbabu KM

Parents
  • Hello  ,

    Please refer the following link about RL Flash file system,

    https://www.keil.com/support/man/docs/rlarm/rlarm_fs_flashfs.htm

    Refer the following source which I'm having frename API,

    int frename (const char *oldname, const char *newname) {
      /* Rename a file from 'oldname' to 'newname'. */
      IOB *fcb;

      START_LOCK (int);

      /* Find unused _iob structure. */
      fcb = fs_find_iob (NULL);
      if (fcb == NULL) {
        /* No free _iob blocks found. */
        RETURN (1);
      }

      /* Set the Volume driver. */
      oldname = fs_map_drive (oldname, fcb);
      if (fcb->vol == NULL) {
        /* Non existing Drive. */
        RETURN (1);
      }

      if (fcb->flags & _IOFAT) {
        /* FAT drive */
        if (fat_rename (oldname, newname, fcb->vol) == fsOK) {
          RETURN (0);
        }
      }
      else {
        /* Embedded Flash drive. */
        if (efs_find (newname, fcb) == __TRUE) {
          /* File with 'newname' already exists. */
          RETURN (1);
        }
        if (efs_find (oldname, fcb) == __FALSE) {
          /* File with 'oldname' does not exist. */
          RETURN (1);
        }
        if (fs_efs_lock (fcb, _FOPEN) == __TRUE) {
          /* Error, the file is locked. */
          RETURN (1);
        }      
        if (efs_rename (newname, fcb) == __TRUE) {
          RETURN (0);
        }
      }
      /* File rename failed. */
      RETURN (1);

      END_LOCK;
    }
    Above source has fs_efs_lock function, please do recheck from your end.  If you need any other details, please let me know.
    Please clarify me for my questions, which is mentioned above.
    Note: Every time it is working fine, when comment the fs_efs_lock in frename API.
    Regards
    Saranbabu KM
Reply
  • Hello  ,

    Please refer the following link about RL Flash file system,

    https://www.keil.com/support/man/docs/rlarm/rlarm_fs_flashfs.htm

    Refer the following source which I'm having frename API,

    int frename (const char *oldname, const char *newname) {
      /* Rename a file from 'oldname' to 'newname'. */
      IOB *fcb;

      START_LOCK (int);

      /* Find unused _iob structure. */
      fcb = fs_find_iob (NULL);
      if (fcb == NULL) {
        /* No free _iob blocks found. */
        RETURN (1);
      }

      /* Set the Volume driver. */
      oldname = fs_map_drive (oldname, fcb);
      if (fcb->vol == NULL) {
        /* Non existing Drive. */
        RETURN (1);
      }

      if (fcb->flags & _IOFAT) {
        /* FAT drive */
        if (fat_rename (oldname, newname, fcb->vol) == fsOK) {
          RETURN (0);
        }
      }
      else {
        /* Embedded Flash drive. */
        if (efs_find (newname, fcb) == __TRUE) {
          /* File with 'newname' already exists. */
          RETURN (1);
        }
        if (efs_find (oldname, fcb) == __FALSE) {
          /* File with 'oldname' does not exist. */
          RETURN (1);
        }
        if (fs_efs_lock (fcb, _FOPEN) == __TRUE) {
          /* Error, the file is locked. */
          RETURN (1);
        }      
        if (efs_rename (newname, fcb) == __TRUE) {
          RETURN (0);
        }
      }
      /* File rename failed. */
      RETURN (1);

      END_LOCK;
    }
    Above source has fs_efs_lock function, please do recheck from your end.  If you need any other details, please let me know.
    Please clarify me for my questions, which is mentioned above.
    Note: Every time it is working fine, when comment the fs_efs_lock in frename API.
    Regards
    Saranbabu KM
Children