Pathname.mountpoint?
bindmount されてる場合には使えないのね…
[root@foo work]# mkdir ./a ./b [root@foo work]# mount --bind ./a ./b [root@foo work]# mount /dev/sda6 on /home type ext3 (rw) /home/xcorp/work/a on /home/xcorp/work/b type none (rw,bind)
#!/usr/bin/ruby -- require 'pathname' a = Pathname.new('/home/xcorp/work/a') b = Pathname.new('/home/xcorp/work/b') if a.mountpoint? then puts "/home/xcorp/work/a is mountpoint" else puts "/home/xcorp/work/a is NOT mountpoint" end if b.mountpoint? then puts "/home/xcorp/work/b is mountpoint" else puts "/home/xcorp/work/b is NOT mountpoint" end c = Pathname.new('/dev/sda6') d = Pathname.new('/home') if c.mountpoint? then puts "/dev/sda6 is mountpoint" else puts "/dev/sda6 is NOT mountpoint" end if d.mountpoint? then puts "/home is mountpoint" else puts "/home is NOT mountpoint" end
[root@foo work]# ./test.rb /home/xcorp/work/a is NOT mountpoint /home/xcorp/work/b is NOT mountpoint /dev/sda6 is NOT mountpoint /home is mountpoint