Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168942839
D10939.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D10939.diff
View Options
Index: head/usr.bin/hexdump/display.c
===================================================================
--- head/usr.bin/hexdump/display.c
+++ head/usr.bin/hexdump/display.c
@@ -39,6 +39,8 @@
#include <sys/param.h>
#include <sys/capsicum.h>
+#include <sys/conf.h>
+#include <sys/ioctl.h>
#include <sys/stat.h>
#include <capsicum_helpers.h>
@@ -57,6 +59,7 @@
static off_t eaddress; /* end address */
static void print(PR *, u_char *);
+static void noseek(void);
void
display(void)
@@ -386,7 +389,7 @@
void
doskip(const char *fname, int statok)
{
- int cnt;
+ int type;
struct stat sb;
if (statok) {
@@ -398,16 +401,37 @@
return;
}
}
- if (statok && S_ISREG(sb.st_mode)) {
- if (fseeko(stdin, skip, SEEK_SET))
+ if (!statok || S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) {
+ noseek();
+ return;
+ }
+ if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
+ if (ioctl(fileno(stdin), FIODTYPE, &type))
err(1, "%s", fname);
- address += skip;
- skip = 0;
- } else {
- for (cnt = 0; cnt < skip; ++cnt)
- if (getchar() == EOF)
- break;
- address += cnt;
- skip -= cnt;
+ /*
+ * Most tape drives don't support seeking,
+ * yet fseek() would succeed.
+ */
+ if (type & D_TAPE) {
+ noseek();
+ return;
+ }
}
+ if (fseeko(stdin, skip, SEEK_SET)) {
+ noseek();
+ return;
+ }
+ address += skip;
+ skip = 0;
+}
+
+static void
+noseek(void)
+{
+ int count;
+ for (count = 0; count < skip; ++count)
+ if (getchar() == EOF)
+ break;
+ address += count;
+ skip -= count;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 31, 9:19 PM (5 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37722740
Default Alt Text
D10939.diff (1 KB)
Attached To
Mode
D10939: hexdump(1): Speed up -s flag on devices
Attached
Detach File
Event Timeline
Log In to Comment