TFTP driver changes
Till Straumann
strauman at SLAC.Stanford.EDU
Tue Sep 25 23:33:14 UTC 2001
Eric Norum wrote:
> Till Straumann wrote:
> > Sounds great! I'd appreciate if you could send me an (alpha) version
> > for testing...
>
> .....ask and it shall be given.....
>
> As you can see, your node_access idea was right on the money. Thanks
> again!
> Let me know if/how this works for you.
Hmm - as I said; I'm not quite happy with the node_access idea anymore
because it's quite difficult to properly track memory allocation/deallocation.
libc quite often copies rtems_filesystem_location_info_t structs around
and dangling pointers to the strdup()ed pathname must be avoided :-(
I could discover memory leaks and other related problems at least under
two conditions:
1) If an attempt to open("/TFTP/somedir/") fails for some reason after
the path evaluation succeeds (libc/open.c), the node 'loc' and hence
the pathname copy will never be released --> memleak.
2) If an attempt to open("/TFTP/somedir/") _does_ succeed (e.g. because
a file (or directory) "somedir" exists on the host), 'loc' is copied to the
filesystem_location_info_t contained in the rtems_libio_t structure
and released, i.e. the string copy is free()ed leaving a dangling pointer
in the libio structure (maybe that's not a big drama - probably it's
never accessed anyway).
IMO, 1) is a bug in rtems proper. At least if the open fails after a successful
path lookup, rtems_filesystem_freenode() should be called.
For 2) it could be argued that node_access in the rtems_libio_t must not
be accessed (because it was released at the end of 'open()'). However,
IMO it would be cleaner to _not_ call ..._freenode() if open succeeds
but to call it from close().
Then there is another tiny problem with the TFTPfs modification:
rtems_tftp_eval_path() should append the pathname to pathloc->node_access
if the latter is non_NULL because the lookup could also be relative to a CWD on
TFTPfs...
Anyway - I would like a real RTEMS filesystem expert to explain the exact
paradigms of using the node_access field.
-- Till.
More information about the users
mailing list