#1536 closed defect (fixed)

TFTP file system does not handle relative paths

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 4.10
Component: fs Version: 4.10
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

The TFTP file system does not handle relative paths. Mount the TFTP file system then read a file without a '/' at the start from the root directory. For example:

$ mount -t tftpfs null /c

mounts the TFTP file system to /c (the default in the code currently is /TFTP) then:

$ cat c/readme

The evaluate only handles a chdir to the /c directory where the path is saved as a string. This is fine. When the open is called it passes in 'c/readme' and the node_access field of the pathloc is not set (not a directory). We have to assume the pathloc's node_access field is not initialised. It may be set else where in the code or cleared how-ever open assumes it is a pointer to a string that it appends 'c/readme' to.

The fix is to save the file name as is and to use that in open. If you look in the other file system they all access the file via some internal reference provided by evaluate. For example in the RFS it is the inode number of the file.

The path passed to open is not used and thinking about this it cannot be used in its current form in any useful way. I think the open file handler interface is open broken passing pathname.

Change History (1)

comment:1 Changed on Jun 2, 2010 at 12:17:35 AM by Chris Johns

Resolution: fixed
Status: assignedclosed

The TFTP file system code has been updated so you can have more than one instance active at once. The mount command for the TFTP file system is:

mount -t tftpfs host:/dir /target

Where the host can be an IP address or host name. Currently the code uses gethostbyname which is not reenterant. TFTP servers may allow an absolute path, how-ever for security this is often rejected. You can handle both absolute and relative paths. For an absolute path where all accesses must be under /tftpboot on a server called 'server' use:

$ mount -t tftpfs server:/tftpboot /boot

To read a file called 'one' under /tftpboot on 'server' do:

$ cat /boot/one

For a relative path on 'rtems.org' of 'ftp' use:

$ mount -t tftpfs rtems.org:ftp /rtemsftp

To read a file called 'Welcome' you would:

$ cat /rtemsftp/Welcome

You can also reference the top of the TFTP path on a relative server with:

$ mount -t tftpfs server: /server

Note, no need for the path component.

Note: See TracTickets for help on using tickets.