Bug 84298

Summary: [patch] allow mount(8) to recognize relative pathnames as mountpoints
Product: Base System Reporter: Mikolaj Rydzewski <miki>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me Keywords: patch
Priority: Normal    
Version: 5.4-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
mount_patch none

Description Mikolaj Rydzewski 2005-07-29 13:50:19 UTC
	Current version of mount(8) requires to specify absolute mountpoint
	pathname. Let's assume one has some mountpoints located in /mnt:
	/mnt/cdrom, /mnt/floppy, /mnt/usb
	It should be possible to call mount(8) like this:
	mount cdrom (assuming the current directory is /mnt). It has
	more practical impact when system is configured to allow non-root
	users to mount (cdroms, usb sticks) to mountpoints in their home
	directories. It's much more flexible to run mount ~/usb than 
	mount /home/<username>/usb.
	And last but not least ;-) mount(8) is supposed to behave in such
	way - there's a correct call to realpath(3), but infortunately
	previous function checks mountpoint validity without using
	realpath(3) call.
	So my patch just polishes existing code.

Fix: Apply attached patch.
How-To-Repeat: 	Try to mount a filesystem using non absolute path name - an error
	will occur.
Comment 1 brooks 2005-07-29 17:06:56 UTC
> >Description:
> 	Current version of mount(8) requires to specify absolute mountpoint
> 	pathname. Let's assume one has some mountpoints located in /mnt:
> 	/mnt/cdrom, /mnt/floppy, /mnt/usb
> 	It should be possible to call mount(8) like this:
> 	mount cdrom (assuming the current directory is /mnt). It has
> 	more practical impact when system is configured to allow non-root
> 	users to mount (cdroms, usb sticks) to mountpoints in their home
> 	directories. It's much more flexible to run mount ~/usb than 
> 	mount /home/<username>/usb.

Not really an objection, but this last example is bogus.  As the example
below shows, tcsh, bash, sh, and csh all make this work since ~expansion
happens before the command is run by the shell:

[7:22pm] brooks@pagefault (/usr/ports): echo ~brooks
/usr/home/brooks
[9:04am] brooks@pagefault (/usr/ports): bash
brooks@pagefault$ echo ~brooks
/usr/home/brooks
brooks@pagefault$ exit
[9:04am] brooks@pagefault (/usr/ports): sh
$ echo ~brooks
/usr/home/brooks
$ [9:04am] brooks@pagefault (/usr/ports): csh
[9:04am] brooks@pagefault (/usr/ports): echo ~brooks
/usr/home/brooks
[9:04am] brooks@pagefault (/usr/ports): exit

-- Brooks
Comment 2 Mikolaj Rydzewski 2005-07-29 22:36:33 UTC
On Fri, 29 Jul 2005, Brooks Davis wrote:

>> 	Current version of mount(8) requires to specify absolute mountpoint
>> 	pathname. Let's assume one has some mountpoints located in /mnt:
>> 	/mnt/cdrom, /mnt/floppy, /mnt/usb
>> 	It should be possible to call mount(8) like this:
>> 	mount cdrom (assuming the current directory is /mnt). It has
>> 	more practical impact when system is configured to allow non-root
>> 	users to mount (cdroms, usb sticks) to mountpoints in their home
>> 	directories. It's much more flexible to run mount ~/usb than
>> 	mount /home/<username>/usb.
>
> Not really an objection, but this last example is bogus.  As the example
> below shows, tcsh, bash, sh, and csh all make this work since ~expansion
> happens before the command is run by the shell:

Yes, you're right, thanks for pointing this.

But the problem with mount ignoring relative mountpoint pathnames still 
exists.

Regards

-- 
Mikolaj Rydzewski    <miki@ma.krakow.pl>    PGP KeyID: 8b12ab02
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:38 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:38:57 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>