From ddf6fb8686b1ed6a26d5f1c76a642d0fb5fe7ba7 Mon Sep 17 00:00:00 2001 From: Aaron Burgemeister Date: Thu, 15 Jul 2010 19:54:49 -0600 Subject: stat: add %m to output the mount point for a file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * src/find-mount-point.c: A new file refactoring find_mount_point() out from df.c * src/find-mount-point.h: Likewise. * src/df.c: Use the new find-mount-point module. * src/stat.c (print_stat): Handle the new %m format. (find_bind_mount): A new function to return the bind mount for a file if any. (out_mount_mount): Print the bind mount for a file, or else the standard mount point given by the find-mount-point module. (usage): Document the %m format directive. * src/Makefile.am: Reference the refactored find-mount-point.c * po/POTFILES.in: Add find_mount_point.c to the translation list * doc/coreutils.texi (stat invocation): Document %m, and how it may differ from the mount point that df outputs. * test/misc/stat-mount: A new test to correlate mount points output from df and stat. * tests/Makefile.am: Reference the new test. * NEWS: Mention the new feature * THANKS: Add the author Signed-off-by: Pádraig Brady --- tests/Makefile.am | 1 + tests/misc/stat-mount | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 tests/misc/stat-mount (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 4aa93bf9e..5619d0b76 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -241,6 +241,7 @@ TESTS = \ misc/split-l \ misc/stat-fmt \ misc/stat-hyphen \ + misc/stat-mount \ misc/stat-printf \ misc/stat-slash \ misc/stdbuf \ diff --git a/tests/misc/stat-mount b/tests/misc/stat-mount new file mode 100755 index 000000000..c1c43d49c --- /dev/null +++ b/tests/misc/stat-mount @@ -0,0 +1,31 @@ +#!/bin/sh +# Test stat -c%m + +# Copyright (C) 2010 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +# Note we assume that the current directory is not bind mounted +# (as then, stat and df may have different results). +# This should be the case given the directory is temporary +# for the duration of the test. + +df_mnt=$(df -P . | sed -n '2s/.* \([^ ]*$\)/\1/p') +stat_mnt=$(stat -c%m .) + +test "$df_mnt" = "$stat_mnt" || fail=1 + +Exit $fail -- cgit v1.2.3-70-g09d2