aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-06-07 07:47:58 +0000
committerGuy Harris <guy@alum.mit.edu>2002-06-07 07:47:58 +0000
commit1b72ef68e6acc8800a2c0a5a719e48aaf5d54c79 (patch)
tree68df58860828572a89856bd914f93204c8265d47 /wiretap/file.c
parent2aad75bb826b45ee1a78be2bbe2687e488748f8b (diff)
Add a new error for attempts to open a pipe or FIFO for random access.
Have "wtap_open_offline()", if asked to open a FIFO, return that error if it was asked to open the file for random access. svn path=/trunk/; revision=5643
Diffstat (limited to 'wiretap/file.c')
-rw-r--r--wiretap/file.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/wiretap/file.c b/wiretap/file.c
index 973cc94821..516eae2c12 100644
--- a/wiretap/file.c
+++ b/wiretap/file.c
@@ -1,6 +1,6 @@
/* file.c
*
- * $Id: file.c,v 1.91 2002/06/07 07:27:34 guy Exp $
+ * $Id: file.c,v 1.92 2002/06/07 07:47:57 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -179,11 +179,33 @@ wtap* wtap_open_offline(const char *filename, int *err, gboolean do_random)
*err = errno;
return NULL;
}
- if (! S_ISREG(statb.st_mode) && ! S_ISFIFO(statb.st_mode)) {
- if (S_ISDIR(statb.st_mode))
- *err = EISDIR;
- else
- *err = WTAP_ERR_NOT_REGULAR_FILE;
+ if (S_ISFIFO(statb.st_mode)) {
+ /*
+ * Opens of FIFOs are allowed only when not opening
+ * for random access.
+ *
+ * XXX - currently, we do seeking when trying to find
+ * out the file type, so we don't actually support
+ * opening FIFOs. However, we may eventually
+ * do buffering that allows us to do at least some
+ * file type determination even on pipes, so we
+ * allow FIFO opens and let things fail later when
+ * we try to seek.
+ */
+ if (do_random) {
+ *err = WTAP_ERR_RANDOM_OPEN_PIPE;
+ return NULL;
+ }
+ } else if (S_ISDIR(statb.st_mode)) {
+ /*
+ * Return different errors for "this is a directory"
+ * and "this is some random special file type", so
+ * the user can get a potentially more helpful error.
+ */
+ *err = EISDIR;
+ return NULL;
+ } else if (! S_ISREG(statb.st_mode)) {
+ *err = WTAP_ERR_NOT_REGULAR_FILE;
return NULL;
}