Thursday, July 1, 2010

The 1st of the rest - _rename_r

This was the first task at hand, before the coding phase of GSoC 2010 begun. This was just to make sure I get hold to things I need to do in the summer. I had to move the numbers up, which would ensure I have all the infrastructure in place and know how to handle things. Fortunately, with support from the mentors and the folks on #rtems, I could do it. And better... I could hit a big chunk in the first shot (Psssst, with a single call).

About the routine:

Signature:

int _rename_r(
struct _reent *ptr __attribute__((unused)),
const char *old,
const char *new
);

old - The path, absolute or relative of the node (file / directory) which needs to be changed

new - The new path, absolute or relative to which the old path is to be renamed. This path needs to be complete. new cannot be an existing directory on to which we are trying to move the file. _rename_r is not mv.

Purpose:

* Rename an existing node as a new node

Misc:

* It is the reentrant version of the rename routine (which I don't see)

Flow:

* Get the old parent location info
* Resolve the old path
* Evaluate the parent of the new path
* Make sure that the rename is within the same filesystem
* Invoke the filesystem's rename routine
* Free the used location info variables
* Return

Test cases:

With IMFS,
* Valid old path and valid new path, both absolute
* Invalid old path, absolute
* Invalid new path, absolute
* Valid old and new paths, both relative
* Mount new filesystem, and attempt to rename across filesystems

Changes to RTEMS, issues with routine:

* The routine returned the errno, instead of the status. PR 1522 - Fixed.
* Few macros were converted to functions under libcsupport/. PR 1541 - Fixed.
* mount system call was changed. PR 1517 - Fixed.


Coverage result:

* _rename_r is now completely covered. Changes to mount call required changes to the test cases and were dealt with (not me)


Challenges:


* The initial setup was hard to get.
* Moving through the code tree to find the routines invoked
* Understanding the data structures used
* Understanding the path evaluation routine
* Understanding the filesystem and mount related concepts

Submitted patch:

PR on rtems-bugzilla - NA.

https://code.google.com/p/rtems-coverage-improvements-gsoc-2010/source/browse/#svn/trunk/_rename_r

Learnings:

* Learnt how to better use emacs. :)
* How path evaluation works, well... most of it.
* Filesystem and mount related concepts.
* _rename_r is not mv of linux
* How to submit a patch (v1).
* How not to submit a patch (v1)
* Destroying the coverage infrastructure and getting it back. :D
* Creating a "PR" and submitting the patch at bugzilla


Next:

fifo/pipe routines

No comments:

Post a Comment