aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cat.c13
-rw-r--r--src/copy.c10
-rw-r--r--src/tail.c16
-rw-r--r--src/test.c11
4 files changed, 28 insertions, 22 deletions
diff --git a/src/cat.c b/src/cat.c
index 30a923cce..9b94ee124 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -645,14 +645,17 @@ main (int argc, char **argv)
idx_t outsize = io_blksize (&stat_buf);
/* Device, I-node number and lazily-acquired flags of the output. */
- dev_t out_dev;
- ino_t out_ino;
+ struct
+ {
+ dev_t st_dev;
+ ino_t st_ino;
+ } out_id;
int out_flags = -2;
bool have_out_dev = ! (S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf));
if (have_out_dev)
{
- out_dev = stat_buf.st_dev;
- out_ino = stat_buf.st_ino;
+ out_id.st_dev = stat_buf.st_dev;
+ out_id.st_ino = stat_buf.st_ino;
}
/* True if the output is a regular file. */
@@ -714,7 +717,7 @@ main (int argc, char **argv)
if (! (S_ISFIFO (stat_buf.st_mode) || S_ISSOCK (stat_buf.st_mode)
|| S_TYPEISSHM (&stat_buf) || S_TYPEISTMO (&stat_buf))
&& have_out_dev
- && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino)
+ && SAME_INODE (stat_buf, out_id))
{
off_t in_pos = lseek (input_desc, 0, SEEK_CUR);
if (0 <= in_pos)
diff --git a/src/copy.c b/src/copy.c
index 147814a8c..5a3d4e836 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -109,8 +109,8 @@
struct dir_list
{
struct dir_list *parent;
- ino_t ino;
- dev_t dev;
+ ino_t st_ino;
+ dev_t st_dev;
};
/* Initial size of the cp.dest_info hash table. */
@@ -690,7 +690,7 @@ is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
{
while (ancestors != 0)
{
- if (ancestors->ino == sb->st_ino && ancestors->dev == sb->st_dev)
+ if (PSAME_INODE (ancestors, sb))
return true;
ancestors = ancestors->parent;
}
@@ -2903,8 +2903,8 @@ skip:
dir = alloca (sizeof *dir);
dir->parent = ancestors;
- dir->ino = src_sb.st_ino;
- dir->dev = src_sb.st_dev;
+ dir->st_ino = src_sb.st_ino;
+ dir->st_dev = src_sb.st_dev;
if (new_dst || !S_ISDIR (dst_sb.st_mode))
{
diff --git a/src/tail.c b/src/tail.c
index 5579b2b71..9046c00f8 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -125,8 +125,8 @@ struct File_spec
/* Attributes of the file the last time we checked. */
struct timespec mtime;
- dev_t dev;
- ino_t ino;
+ dev_t st_dev;
+ ino_t st_ino;
mode_t mode;
/* If a regular file, the file's read position the last time we
@@ -413,8 +413,8 @@ record_open_fd (struct File_spec *f, int fd,
{
f->fd = fd;
f->mtime = get_stat_mtime (st);
- f->dev = st->st_dev;
- f->ino = st->st_ino;
+ f->st_dev = st->st_dev;
+ f->st_ino = st->st_ino;
f->mode = st->st_mode;
if (S_ISREG (st->st_mode))
f->read_pos = (read_pos < 0
@@ -1061,7 +1061,7 @@ recheck (struct File_spec *f, bool blocking)
_("%s has appeared; following new file"),
quoteaf (f->prettyname));
}
- else if (f->ino != new_stats.st_ino || f->dev != new_stats.st_dev)
+ else if (!SAME_INODE (*f, new_stats))
{
/* File has been replaced (e.g., via log rotation) --
tail the new one. */
@@ -1583,7 +1583,7 @@ tail_forever_inotify (int wd, struct File_spec *f, int n_files,
struct stat stats;
if (! (stat (f[i].name, &stats) < 0
- || (f[i].dev == stats.st_dev && f[i].ino == stats.st_ino)))
+ || SAME_INODE (f[i], stats)))
{
error (0, errno, _("%s was replaced"),
quoteaf (f[i].prettyname));
@@ -1988,8 +1988,8 @@ tail_file (struct File_spec *f, count_t n_files, count_t n_units)
f->fd = -1;
f->errnum = errno;
f->ignore = ! reopen_inaccessible_files;
- f->ino = 0;
- f->dev = 0;
+ f->st_dev = 0;
+ f->st_ino = 0;
}
error (0, errno, _("cannot open %s for reading"),
quoteaf (f->prettyname));
diff --git a/src/test.c b/src/test.c
index 583cf74c9..0c0785b9c 100644
--- a/src/test.c
+++ b/src/test.c
@@ -287,7 +287,6 @@ static bool
binary_operator (bool l_is_l, enum binop bop)
{
int op;
- struct stat stat_buf, stat_spare;
if (l_is_l)
advance (false);
@@ -339,9 +338,13 @@ binary_operator (bool l_is_l, enum binop bop)
case EF_BINOP:
if (l_is_l | r_is_l)
test_syntax_error (_("-ef does not accept -l"));
- return (stat (argv[op - 1], &stat_buf) == 0
- && stat (argv[op + 1], &stat_spare) == 0
- && SAME_INODE (stat_buf, stat_spare));
+ else
+ {
+ struct stat st[2];
+ return (stat (argv[op - 1], &st[0]) == 0
+ && stat (argv[op + 1], &st[1]) == 0
+ && psame_inode (&st[0], &st[1]));
+ }
case EQ_STRING_BINOP:
case NE_STRING_BINOP: