Subscribe

the function "snapshot-changes" returns list witch may include incorrect name

The tool contacts NetApp Filer to perform a snapdiff operation between two snapshots for the specified NAS volume. It calls the function "na_elem_child(naElement, "snapshot-changes")" and this function returns list witch may include incorrect name if name has the symbol '\r'. The symbol '\r' (0x0D) will be changed to 0x0A. This problem appears on Linux platform and only for objects which has '\r' in their names.

I get difference between 2 snapshots in the following code:

na_elem_t *naElementStart = na_server_invoke(naSrvHandleP,                  
                                             "snapdiff-iter-start",
                                             "volume", nasVolume,
                                             "base-snapshot", baseSnapshot,
                                             "diff-snapshot", osDiffSnapshot,
                                             "atime", "0",
                                             "max-diffs", NA_MAX_NUM_DIFFS_STR,
                                             NULL);
const char *naSessionId = na_child_get_string(naElementStart, "session-id");

na_elem_t *naElement = na_server_invoke(naSrvHandleP,
                                        "snapdiff-iter-next",
                                        "session-id", naSessionId,
                                        NULL);

int naNumChanges = na_child_get_int(naElement, "num-changes", 0);

if ((naNumChanges > 0) && (naNumChanges <= NA_MAX_NUM_DIFFS))
{
   na_elem_t *naSnapshotChangeRec = na_elem_child(naElement, "snapshot-changes");

   ...

   na_elem_iter_t naIter =  na_child_iterator(naSnapshotChangeRec);
   for (i=0; i<naNumChanges; i++)
   {
      /*=================================================================
        Get change information from each entry in the list.
       =================================================================*/
      na_elem_t *naOneSnapshotChange;
      if ((naOneSnapshotChange = na_iterator_next(&naIter)) != NULL)
      {
         /*=== Determine type of change and the changed file/dir path ===*/
         nasChangeType     = na_child_get_string(naOneSnapshotChange, "change-type");
         getNasChangedPath = na_child_get_string(naOneSnapshotChange, "filename");
      }
   }
}


The value getNasChangedPath will be corrupted because API changes the symbol "0x0D" to "0x0A".
The file with symbol "\r" can be created by the command (echo "12345" > $(echo "/fs/tested_file\r").
Can we say in this case that this is bug of SDK?

Re: the function "snapshot-changes" returns list witch may include incorrect name

Please let me know if you need more information about this problem.