Opened on 09/10/15 at 11:31:53
Last modified on 02/15/17 at 13:37:51
#2415 assigned defect
Duplicate code in Untar_FromMemory(), Untar_FromFile() and rtems_tarfs_load()
Reported by: | Sebastian Huber | Owned by: | Needs Funding |
---|---|---|---|
Priority: | normal | Milestone: | Indefinite |
Component: | unspecified | Version: | 4.10 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: |
Description
These functions should use a general purpose TAR iterator function with specialized visitors.
Change History (6)
comment:1 Changed on 05/15/16 at 23:51:27 by Chris Johns
comment:2 follow-up: 3 Changed on 05/17/16 at 05:47:45 by Sebastian Huber
We should at least refactor the general TAR file iteration into an iterator function and use different visitor functions.
Another option for this direct mapping of some read-only content into an IMFS linear file would be mmap().
comment:3 Changed on 05/17/16 at 05:55:33 by Chris Johns
Replying to sebastian.huber:
We should at least refactor the general TAR file iteration into an iterator function and use different visitor functions.
I have changed untar.c (need to post for review) to have a ProcessHeader? call and the in-memory and file versions now share that code to handle the semantics. The only differences are the writes to the files. Further work could be done to make the code share more if there is a need. The important part is shared.
Another option for this direct mapping of some read-only content into an IMFS linear file would be mmap().
[ implementation here https://git.rtems.org/chrisj/rtl.git/tree/mmap.c ]
I think this is the other way around. The current tar functionality takes some memory and makes files in the IMFS while mmap takes a file and makes it appear as memory.
comment:4 Changed on 06/04/16 at 00:11:31 by Chris Johns <chrisj@…>
comment:5 Changed on 01/26/17 at 07:16:00 by Sebastian Huber
Milestone: | 4.11.1 → 4.11.2 |
---|
comment:6 Changed on 02/15/17 at 13:37:51 by Sebastian Huber
Milestone: | 4.11.2 → Indefinite |
---|---|
Owner: | set to Needs Funding |
Status: | new → assigned |
Reviewing the code I suspect it might be difficult to merge the functionality as things exist.
The loading of a tar file into the IMFS seems to be mixing POSIX functionality and internal IMFS functionality. The IMFS tar file load code directly references the tar image for the file contents. The referencing is nice where RAM usage is important but there are assumptions being made such as the storage for the tar file has to remain valid for the life time of the mount and there is no other activity in the IMFS when this call is made. I am also not sure how locking in the file system is managed when the references to the file contents are being made. Is this code thread safe in regards to the operation of the IMFS?
The libmisc untar code does not handle the full tar semantics when updating an existing directory tree. Ticket #2207 covers this issue. I am not sure how these semantics would relate to the IMFS implementation if that is at all possible.
I think special access to the IMFS to allow neat features such as adding a file node based on a piece of memory is a good idea but I think having things like tar code in the IMFS file system tree and a direct user API call is wrong. I wonder is the IMFS should be given a /dev node and ioctl calls made to access any special features. This would provide us with a robust user interface we could control. Once this is done we would be in a better position to provide a common implementation for tar loading as well as supporting the full tar semantics.