diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-11-23 06:10:36 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-11-23 06:10:36 +0400 |
commit | 1f3b374d39a76709cb24a0aa025dfaa12abc9c10 (patch) | |
tree | 8f98476af1879ba017770bcf75cd48e6141ede94 | |
parent | 7dd3317a96273b8b22099265863bfb7e517dcddf (diff) | |
download | illumos-packaging-1f3b374d39a76709cb24a0aa025dfaa12abc9c10.tar.gz |
util-illumos (2.10+2) unstable; urgency=low
* Added /usr/bin/mountpoint
-rw-r--r-- | util-illumos/debian/changelog | 6 | ||||
-rw-r--r-- | util-illumos/debian/copyright | 2 | ||||
-rw-r--r-- | util-illumos/debian/mountpoint.c | 120 | ||||
-rwxr-xr-x | util-illumos/debian/rules | 4 | ||||
-rw-r--r-- | util-illumos/debian/util-illumos.install | 1 |
5 files changed, 131 insertions, 2 deletions
diff --git a/util-illumos/debian/changelog b/util-illumos/debian/changelog index bef9569..d8b4a40 100644 --- a/util-illumos/debian/changelog +++ b/util-illumos/debian/changelog @@ -1,3 +1,9 @@ +util-illumos (2.10+2) unstable; urgency=low + + * Added /usr/bin/mountpoint + + -- Igor Pashev <pashev.igor@gmail.com> Sat, 23 Nov 2013 06:03:17 +0400 + util-illumos (2.10+1) unstable; urgency=low * Added pbind-no-isaexec.patch diff --git a/util-illumos/debian/copyright b/util-illumos/debian/copyright index 92d3a40..dd40472 100644 --- a/util-illumos/debian/copyright +++ b/util-illumos/debian/copyright @@ -1,5 +1,5 @@ Files: debian/* -Copyright: 2012, Igor Pashev <pashev.igor@gmail.com> +Copyright: 2012-2013, Igor Pashev <pashev.igor@gmail.com> License: WTFPL-2 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 diff --git a/util-illumos/debian/mountpoint.c b/util-illumos/debian/mountpoint.c new file mode 100644 index 0000000..c802aa1 --- /dev/null +++ b/util-illumos/debian/mountpoint.c @@ -0,0 +1,120 @@ +/* + * Written by Igor Pashev <pashev.igor@gmail.com> + * + * The author has placed this work in the Public Domain, + * thereby relinquishing all copyrights. Everyone is free + * to use, modify, republish, sell or give away this work + * without prior consent from anybody. + * + */ + +#include <errno.h> +#include <getopt.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> +#include <unistd.h> + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +static int flag_q = 0; +static int flag_d = 0; +static int flag_x = 0; +static int rc; + +static struct stat st, st_up; +static const char *path; +static char path_up[PATH_MAX]; + +static void +usage (void) +{ + fprintf (stderr, "Usage: mountpoint [-q] [-d] [-x] path\n"); + exit (1); +} + +static void +xstat (const char *p, struct stat *s) +{ + if (flag_x) + rc = lstat (p, s); + else + rc = stat (p, s); + + if (rc != 0) + { + if (!flag_q) + fprintf (stderr, "mountpoint: %s: %s\n", path, strerror (errno)); + exit (1); + } +} + +int +main (int argc, char *argv[]) +{ + while ((rc = getopt (argc, argv, "qdx")) != EOF) + switch (rc) + { + case 'q': + flag_q++; + break; + case 'd': + flag_d++; + break; + case 'x': + flag_x++; + break; + default: + usage (); + break; + } + if (optind != argc - 1) + usage (); + + path = argv[optind]; + xstat (path, &st); + + if (flag_x) + { + if (S_ISBLK (st.st_mode) || S_ISCHR (st.st_mode)) + { + printf ("%u:%u\n", major (st.st_rdev), minor (st.st_rdev)); + return 0; + } + if (!flag_q) + fprintf (stderr, "mountpoint: %s: not a block device\n", path); + return 1; + } + + if (!S_ISDIR (st.st_mode)) + { + if (!flag_q) + fprintf (stderr, "mountpoint: %s: not a directory\n", path); + return 1; + } + + + rc = snprintf (path_up, sizeof (path_up), "%s/..", path); + if ((size_t) rc >= sizeof (path_up)) + { + if (!flag_q) + fprintf (stderr, "mountpoint: internal error: path is too long: %s\n", + path); + return 1; + } + + xstat (path_up, &st_up); + rc = (st.st_dev != st_up.st_dev) || (st.st_dev == st_up.st_dev + && st.st_ino == st_up.st_ino); + + if (flag_d) + printf ("%u:%u\n", major (st.st_dev), minor (st.st_dev)); + else if (!flag_q) + printf ("%s is %sa mountpoint\n", path, rc ? "" : "not "); + + return rc ? 0 : 1; +} diff --git a/util-illumos/debian/rules b/util-illumos/debian/rules index 0bf9532..6a3e774 100755 --- a/util-illumos/debian/rules +++ b/util-illumos/debian/rules @@ -89,6 +89,7 @@ install-stamp: build-stamp install -m 755 -t debian/tmp/sbin/ soconfig install -m 755 -t debian/tmp/sbin/ autopush install -m 755 -t debian/tmp/sbin/ dmesg + install -m 755 -t debian/tmp/usr/bin/ mountpoint ln -sf ../../sbin/dmesg debian/tmp/usr/sbin/dmesg install -m 755 usr/src/cmd/initpkg/swapadd.sh debian/tmp/sbin/swapadd touch $@ @@ -98,6 +99,7 @@ build build-arch build-indep: build-stamp build-stamp: dirs-stamp patch-stamp $(CC) $(CFLAGS) $(LDFLAGS) ./usr/src/cmd/cmd-inet/usr.sbin/soconfig.c -o soconfig $(CC) $(CFLAGS) $(LDFLAGS) ./usr/src/cmd/autopush/autopush.c -o autopush + $(CC) $(CFLAGS) $(LDFLAGS) ./debian/mountpoint.c -o mountpoint : gcc -fno-builtin -nostdinc -c -o mboot.o ./usr/src/psm/stand/bootblks/ufs/i386/mboot.S ld -nostdlib -N -Ttext 600 -o mboot.exec mboot.o @@ -133,6 +135,6 @@ binary-stamp: install-stamp clean: unpatch dh_testdir dh_testroot - dh_clean dmesg soconfig autopush mboot + dh_clean dmesg soconfig autopush mboot mountpoint rm -rf usr .pc diff --git a/util-illumos/debian/util-illumos.install b/util-illumos/debian/util-illumos.install index a802ac1..b90a8e2 100644 --- a/util-illumos/debian/util-illumos.install +++ b/util-illumos/debian/util-illumos.install @@ -10,6 +10,7 @@ sbin/zonename usr/bin/isainfo usr/bin/isalist usr/bin/mesg +usr/bin/mountpoint usr/bin/newtask usr/bin/optisa usr/bin/zonename |