summaryrefslogtreecommitdiff
path: root/usr.bin/fstat
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
commitd1d015864103b253b3fcb2f72a0da5b0cfeb31b6 (patch)
tree22b131dceb13c3df96da594fbaadb693504797c7 /usr.bin/fstat
parent12d4083451fc39b3e831d4ea0bfa67d3b32cfb54 (diff)
parentb6f49c23a36f329cbf1e7f28078e17fd87f0e245 (diff)
downloadsrc-test-d1d015864103b253b3fcb2f72a0da5b0cfeb31b6.tar.gz
src-test-d1d015864103b253b3fcb2f72a0da5b0cfeb31b6.zip
Merge from head
Notes
Notes: svn path=/projects/bmake/; revision=255263
Diffstat (limited to 'usr.bin/fstat')
-rw-r--r--usr.bin/fstat/fstat.12
-rw-r--r--usr.bin/fstat/fstat.c29
2 files changed, 31 insertions, 0 deletions
diff --git a/usr.bin/fstat/fstat.1 b/usr.bin/fstat/fstat.1
index 7403a8e725ee2..268b70f4526f7 100644
--- a/usr.bin/fstat/fstat.1
+++ b/usr.bin/fstat/fstat.1
@@ -155,6 +155,8 @@ using a symbolic format (see
otherwise, the mode is printed
as an octal number.
.It Li SZ\&|DV
+If the file is a semaphore,
+prints the current value of the semaphore.
If the file is not a character or block special, prints the size of
the file in bytes.
Otherwise, if the
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index 265791d1daacf..1aeee67511dd7 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -84,6 +84,8 @@ static void print_pipe_info(struct procstat *procstat,
struct filestat *fst);
static void print_pts_info(struct procstat *procstat,
struct filestat *fst);
+static void print_sem_info(struct procstat *procstat,
+ struct filestat *fst);
static void print_shm_info(struct procstat *procstat,
struct filestat *fst);
static void print_socket_info(struct procstat *procstat,
@@ -294,6 +296,9 @@ print_file_info(struct procstat *procstat, struct filestat *fst,
case PS_FST_TYPE_SHM:
print_shm_info(procstat, fst);
break;
+ case PS_FST_TYPE_SEM:
+ print_sem_info(procstat, fst);
+ break;
default:
if (vflg)
fprintf(stderr,
@@ -424,6 +429,30 @@ print_pts_info(struct procstat *procstat, struct filestat *fst)
}
static void
+print_sem_info(struct procstat *procstat, struct filestat *fst)
+{
+ struct semstat sem;
+ char errbuf[_POSIX2_LINE_MAX];
+ char mode[15];
+ int error;
+
+ error = procstat_get_sem_info(procstat, fst, &sem, errbuf);
+ if (error != 0) {
+ printf("* error");
+ return;
+ }
+ if (nflg) {
+ printf(" ");
+ (void)snprintf(mode, sizeof(mode), "%o", sem.mode);
+ } else {
+ printf(" %-15s", fst->fs_path != NULL ? fst->fs_path : "-");
+ strmode(sem.mode, mode);
+ }
+ printf(" %10s %6u", mode, sem.value);
+ print_access_flags(fst->fs_fflags);
+}
+
+static void
print_shm_info(struct procstat *procstat, struct filestat *fst)
{
struct shmstat shm;