>Synopsis:      Single arg invocation of mount does not mount symlink
to a dir

>Category:      system

>Environment:

        System      : OpenBSD 5.2

        Details     : OpenBSD 5.2 (GENERIC.MP) #339: Wed Aug  1
10:13:24 MDT 2012


[1][email protected]:/usr/src/sys/arch/i386/compile/GENERIC.MP



        Architecture: OpenBSD.i386

        Machine     : i386

>Description:

        When trying to mount an fstab entry with mount point as a
symlink to a d

irectory, mount fails. mount_mfs can mount the same symlink but mount
doesn't. mount(2) and mount(8) were not clear as to whether node or dir
can be a symlink or not.





>How-To-Repeat:



# fgrep /tmp/c /etc/fstab

swap /tmp/c mfs rw,-s=20000 0 0



# ls -la /tmp

total 10

drwxrwxrwt   4 root  wheel  512 Mar  8 19:10 .

drwxr-xr-x  15 root  wheel  512 Mar  7 18:44 ..

drwx------   3 root  wheel  512 Mar  8 19:09 a

lrwx------   1 root  wheel    3 Mar  8 19:09 c -> a/b

drwxrwxrwt   2 root  wheel  512 Mar  8 19:10 vi.recover



# mount /tmp/c

mount: can't find fstab entry for /tmp/c.



# mount_mfs -s 20000 swap /tmp/c

mount_mfs: reduced number of fragments per cylinder group from 2496 to
2472 to e

nlarge last cylinder group



# mount | fgrep tmp

mfs:3744 on /tmp type mfs (asynchronous, local, nodev, nosuid,
size=300000 512-b

locks)

mfs:3682 on /tmp/a/b type mfs (asynchronous, local, size=20000
512-blocks)



# umount /tmp/c

# mount | fgrep tmp

mfs:3744 on /tmp type mfs (asynchronous, local, nodev, nosuid,
size=300000 512-b

locks)





Ktrace output indicating realpath() converting symlink to the target
dir :

------

 14227 mount    CALL  lstat(0xcfbc0a84,0xcfbbfdb8)

 14227 mount    NAMI  "/tmp"

 14227 mount    STRU  struct stat { dev=65280, ino=2, mode=drwxrwxrwt ,
nlink=4,

 uid=0, gid=0, rdev=1208, atime=1362750114, mtime=1362750034.293781669,
ctime=13

62750034.293781669, size=512, blocks=2, blksize=8192, flags=0x0,
gen=0xd6d887d9

}

 14227 mount    RET   lstat 0

 14227 mount    CALL  lstat(0xcfbc0a84,0xcfbbfdb8)

 14227 mount    NAMI  "/tmp/c"

ESC[7m/home/dexter/tr1.outESC[27mESC[K^MESC[KESC[HESC[JESC[H 14227
mount    STRU

  struct stat { dev=65280, ino=3, mode=lrwx------ , nlink=1, uid=0,
gid=0, rdev=

6434657, atime=1362749949.572503607, mtime=1362749949.572503607,
ctime=136274994

9.572503607, size=3, blocks=0, blksize=8192, flags=0x0, gen=0x9089c7ff
}

 14227 mount    RET   lstat 0

 14227 mount    CALL  readlink(0xcfbc0a84,0xcfbbfe28,0x3ff)

 14227 mount    NAMI  "/tmp/c"

 14227 mount    RET   readlink 3

 14227 mount    CALL  lstat(0xcfbc0a84,0xcfbbfdb8)

 14227 mount    NAMI  "/tmp/a"

 14227 mount    STRU  struct stat { dev=65280, ino=18688,
mode=drwx------ , nlin

k=3, uid=0, gid=0, rdev=74408, atime=1362749947.002464837,
mtime=1362749942.0123

89559, ctime=1362749942.012389559, size=512, blocks=2, blksize=8192,
flags=0x0,

gen=0xfb109d74 }

 14227 mount    RET   lstat 0

 14227 mount    CALL  lstat(0xcfbc0a84,0xcfbbfdb8)

 14227 mount    NAMI  "/tmp/a/b"

 14227 mount    STRU  struct stat { dev=65280, ino=18689,
mode=drwx------ , nlin

k=2, uid=0, gid=0, rdev=74409, atime=1362749942.012389559,
mtime=1362749942.0123

89559, ctime=1362749942.012389559, size=512, blocks=2, blksize=8192,
flags=0x0,

gen=0xb5e63444 }

 14227 mount    RET   lstat 0

 14227 mount    CALL  stat(0x3c0006eb,0xcfbc09b8)



The target dir is then compared to the fstab entry instead of the
symlink given

in the cmd line.



>Fix:



Following patch to mount.c fixes this issue :-

*** mount.c.original    Thu Mar  7 19:55:11 2013

--- mount.c     Thu Mar  7 19:55:22 2013

***************

*** 233,238 ****

--- 233,239 ----

                } else {

                        if ((fs = getfsfile(mntpath)) == NULL &&

                            (fs = getfsspec(mntpath)) == NULL &&

+                           (fs = getfsfile(*argv)) == NULL &&

                            (fs = getfsspec(*argv)) == NULL)

                                errx(1, "can't find fstab entry for
%s.",

                                    *argv);



# /usr/src/sbin/mount/mount /tmp/c

mount_mfs: reduced number of fragments per cylinder group from 2496 to
2472 to e

nlarge last cylinder group



# df -h /tmp/c

Filesystem     Size    Used   Avail Capacity  Mounted on

mfs:4880       9.3M    1.0K    8.8M     0%    /tmp/a/b

# df -h /tmp/a/b

Filesystem     Size    Used   Avail Capacity  Mounted on

mfs:4880       9.3M    1.0K    8.8M     0%    /tmp/a/b









dmesg:

OpenBSD 5.2 (GENERIC.MP) #339: Wed Aug  1 10:13:24 MDT 2012


[2][email protected]:/usr/src/sys/arch/i386/compile/GENERIC.MP

cpu0: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz ("GenuineIntel"
686-class) 2.50 GHz

cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36
,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,NXE,LONG,SSE3,PCLMUL,MW
AIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,POPCNT
,AES,XSAVE,AVX,LAHF

real mem  = 3625263104 (3457MB)

avail mem = 3555172352 (3390MB)

mainbus0 at root

bios0 at mainbus0: AT/286+ BIOS, date 06/11/12, BIOS32 rev. 0 @
0xfc000, SMBIOS rev. 2.7 @ 0xe0840 (61 entries)

bios0: vendor LENOVO version "5FCN34WW" date 06/11/2012

bios0: LENOVO IdeaPad Z580

acpi at bios0 function 0x0 not configured

mpbios at bios0 function 0x0 not configured

pcibios0 at bios0: rev 3.0 @ 0xf0000/0x62d

pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfa710/448 (26 entries)

pcibios0: PCI Interrupt Router at 000:31:0 ("Intel 82371FB ISA" rev
0x00)

pcibios0: PCI bus #3 is the last bus

bios0: ROM list: 0xc0000/0xee00

cpu0 at mainbus0: (uniprocessor)

pci0 at mainbus0 bus 0: configuration mode 1 (bios)

pchb0 at pci0 dev 0 function 0 "Intel Core 3G Host" rev 0x09

vga1 at pci0 dev 2 function 0 "Intel HD Graphics 4000" rev 0x09

wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)

wsdisplay0: screen 1-5 added (80x25, vt100 emulation)

intagp at vga1 not configured

"Intel 7 Series xHCI" rev 0x04 at pci0 dev 20 function 0 not configured

"Intel 7 Series MEI" rev 0x04 at pci0 dev 22 function 0 not configured

ehci0 at pci0 dev 26 function 0 "Intel 7 Series USB" rev 0x04: irq 11

usb0 at ehci0: USB revision 2.0

uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1

azalia0 at pci0 dev 27 function 0 "Intel 7 Series HD Audio" rev 0x04:
irq 10

azalia0: codecs: Realtek ALC269, Intel/0x2806, using Realtek ALC269

audio0 at azalia0

ppb0 at pci0 dev 28 function 0 "Intel 7 Series PCIE" rev 0xc4: irq 11

pci1 at ppb0 bus 1

ppb1 at pci0 dev 28 function 1 "Intel 7 Series PCIE" rev 0xc4: irq 10

pci2 at ppb1 bus 2

re0 at pci2 dev 0 function 0 "Realtek 8101E" rev 0x05: RTL8105E
(0x4080), irq 10, address

ukphy0 at re0 phy 7: Generic IEEE 802.3u media interface, rev. 2: OUI
0x000732, model 0x0008

ppb2 at pci0 dev 28 function 2 "Intel 7 Series PCIE" rev 0xc4: irq 7

pci3 at ppb2 bus 3

"Broadcom BCM4313" rev 0x01 at pci3 dev 0 function 0 not configured

ehci1 at pci0 dev 29 function 0 "Intel 7 Series USB" rev 0x04: irq 11

usb1 at ehci1: USB revision 2.0

uhub1 at usb1 "Intel EHCI root hub" rev 2.00/1.00 addr 1

pcib0 at pci0 dev 31 function 0 "Intel HM76 LPC" rev 0x04

ahci0 at pci0 dev 31 function 2 "Intel 7 Series AHCI" rev 0x04: irq 7,
AHCI 1.3

scsibus0 at ahci0: 32 targets

sd0 at scsibus0 targ 0 lun 0: <ATA, ST9500325AS, 0011> SCSI3 0/direct
fixed naa.5000c5005197cffa

sd0: 476940MB, 512 bytes/sector, 976773168 sectors

cd0 at scsibus0 targ 2 lun 0: <MATSHITA, DVD-RAM UJ8C1, 8.20> ATAPI
5/cdrom removable

ichiic0 at pci0 dev 31 function 3 "Intel 7 Series SMBus" rev 0x04: irq
7

iic0 at ichiic0

spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM PC3-12800 SO-DIMM

isa0 at pcib0

isadma0 at isa0

pckbc0 at isa0 port 0x60/5

pckbd0 at pckbc0 (kbd slot)

pckbc0: using irq 1 for kbd slot

wskbd0 at pckbd0: console keyboard, using wsdisplay0

pms0 at pckbc0 (aux slot)

pckbc0: using irq 12 for aux slot

wsmouse0 at pms0 mux 0

pms0: Synaptics clickpad, firmware 8.1

pcppi0 at isa0 port 0x61

spkr0 at pcppi0

npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16

mtrr: Pentium Pro MTRR support

uhub2 at uhub0 port 1 "Intel Rate Matching Hub" rev 2.00/0.00 addr 2

uhidev0 at uhub2 port 1 configuration 1 interface 0 "Trust USB OPTICAL
MOUSE" rev 1.10/1.00 addr 3

uhidev0: iclass 3/1, 1 report id

ums0 at uhidev0 reportid 1: 3 buttons, Z dir

wsmouse1 at ums0 mux 0

ugen0 at uhub2 port 3 "Generic USB2.0-CRW" rev 2.00/39.60 addr 4

uhub3 at uhub1 port 1 "Intel Rate Matching Hub" rev 2.00/0.00 addr 2

uvideo0 at uhub3 port 3 configuration 1 interface 0
"LOEAAI011P2S01125K16466 Lenovo EasyCamera" rev 2.00/0.18 addr 3

video0 at uvideo0

ugen1 at uhub3 port 4 "Broadcom Corp BCM20702A0" rev 2.00/1.12 addr 4

vscsi0 at root

scsibus1 at vscsi0: 256 targets

softraid0 at root

scsibus2 at softraid0: 256 targets

root on sd0a (19378acd3782c.a) swap on sd0b dump on sd0b

sd0: 450306MB, 512 bytes/sector, 922226864 sectors



Cordially,

Srikant Tangirala.

References

1. mailto:[email protected]
2. mailto:[email protected]

Reply via email to