Resolve conflicts

This commit is contained in:
Doug Barton 2003-10-06 01:55:17 +00:00
parent 0734ae29f1
commit dad5d4e08c

View File

@ -37,12 +37,22 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if 0 #if 0
#ifndef lint #ifndef lint
__RCSID("$NetBSD: stat.c,v 1.10 2003/05/08 13:05:38 atatat Exp $"); __RCSID("$NetBSD: stat.c,v 1.13 2003/07/25 03:21:17 atatat Exp $");
#endif #endif
#endif #endif
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#if HAVE_CONFIG_H
#include "config.h"
#else /* HAVE_CONFIG_H */
#define HAVE_STRUCT_STAT_ST_FLAGS 1
#define HAVE_STRUCT_STAT_ST_GEN 1
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
#define HAVE_DEVNAME 1
#endif /* HAVE_CONFIG_H */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -57,16 +67,44 @@ __FBSDID("$FreeBSD$");
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#if HAVE_STRUCT_STAT_ST_FLAGS
#define DEF_F "%#Xf "
#define RAW_F "%f "
#define SHELL_F " st_flags=%f"
#else /* HAVE_STRUCT_STAT_ST_FLAGS */
#define DEF_F
#define RAW_F
#define SHELL_F
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
#define DEF_B "\"%SB\" "
#define RAW_B "%B "
#define SHELL_B "st_birthtime=%B "
#else /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
#define DEF_B
#define RAW_B
#define SHELL_B
#endif /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
#if HAVE_STRUCT_STAT_ST_ATIM
#define st_atimespec st_atim
#define st_ctimespec st_ctim
#define st_mtimespec st_mtim
#endif /* HAVE_STRUCT_STAT_ST_ATIM */
#define DEF_FORMAT \ #define DEF_FORMAT \
"%d %i %Sp %l %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%Sc\" \"%SB\" %k %b %N" "%d %i %Sp %l %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%Sc\" " DEF_B \
#define RAW_FORMAT "%d %i %#p %l %u %g %r %z %a %m %c %B %k %b %N" "%k %b " DEF_F "%N"
#define RAW_FORMAT "%d %i %#p %l %u %g %r %z %a %m %c " RAW_B \
"%k %b " RAW_F "%N"
#define LS_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%SY" #define LS_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%SY"
#define LSF_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%T%SY" #define LSF_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%T%SY"
#define SHELL_FORMAT \ #define SHELL_FORMAT \
"st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l " \ "st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l " \
"st_uid=%u st_gid=%g st_rdev=%r st_size=%z " \ "st_uid=%u st_gid=%g st_rdev=%r st_size=%z " \
"st_atime=%a st_mtime=%m st_ctime=%c st_birthtime=%B " \ "st_atime=%a st_mtime=%m st_ctime=%c " SHELL_B \
"st_blksize=%k st_blocks=%b" "st_blksize=%k st_blocks=%b" SHELL_F
#define LINUX_FORMAT \ #define LINUX_FORMAT \
" File: \"%N\"%n" \ " File: \"%N\"%n" \
" Size: %-11z FileType: %HT%n" \ " Size: %-11z FileType: %HT%n" \
@ -525,6 +563,7 @@ format1(const struct stat *st,
case SHOW_st_rdev: case SHOW_st_rdev:
small = (sizeof(st->st_dev) == 4); small = (sizeof(st->st_dev) == 4);
data = (what == SHOW_st_dev) ? st->st_dev : st->st_rdev; data = (what == SHOW_st_dev) ? st->st_dev : st->st_rdev;
#if HAVE_DEVNAME
sdata = (what == SHOW_st_dev) ? sdata = (what == SHOW_st_dev) ?
devname(st->st_dev, S_IFBLK) : devname(st->st_dev, S_IFBLK) :
devname(st->st_rdev, devname(st->st_rdev,
@ -533,6 +572,7 @@ format1(const struct stat *st,
0U); 0U);
if (sdata == NULL) if (sdata == NULL)
sdata = "???"; sdata = "???";
#endif /* HAVE_DEVNAME */
if (hilo == HIGH_PIECE) { if (hilo == HIGH_PIECE) {
data = major(data); data = major(data);
hilo = 0; hilo = 0;
@ -542,7 +582,11 @@ format1(const struct stat *st,
hilo = 0; hilo = 0;
} }
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
#if HAVE_DEVNAME
FMTF_STRING; FMTF_STRING;
#else /* HAVE_DEVNAME */
0;
#endif /* HAVE_DEVNAME */
if (ofmt == 0) if (ofmt == 0)
ofmt = FMTF_UNSIGNED; ofmt = FMTF_UNSIGNED;
break; break;
@ -632,9 +676,11 @@ format1(const struct stat *st,
if (tsp == NULL) if (tsp == NULL)
tsp = &st->st_ctimespec; tsp = &st->st_ctimespec;
/* FALLTHROUGH */ /* FALLTHROUGH */
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
case SHOW_st_btime: case SHOW_st_btime:
if (tsp == NULL) if (tsp == NULL)
tsp = &st->st_birthtimespec; tsp = &st->st_birthtimespec;
#endif /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
ts = *tsp; /* copy so we can muck with it */ ts = *tsp; /* copy so we can muck with it */
small = (sizeof(ts.tv_sec) == 4); small = (sizeof(ts.tv_sec) == 4);
data = ts.tv_sec; data = ts.tv_sec;
@ -671,6 +717,7 @@ format1(const struct stat *st,
if (ofmt == 0) if (ofmt == 0)
ofmt = FMTF_UNSIGNED; ofmt = FMTF_UNSIGNED;
break; break;
#if HAVE_STRUCT_STAT_ST_FLAGS
case SHOW_st_flags: case SHOW_st_flags:
small = (sizeof(st->st_flags) == 4); small = (sizeof(st->st_flags) == 4);
data = st->st_flags; data = st->st_flags;
@ -679,6 +726,8 @@ format1(const struct stat *st,
if (ofmt == 0) if (ofmt == 0)
ofmt = FMTF_UNSIGNED; ofmt = FMTF_UNSIGNED;
break; break;
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
#if HAVE_STRUCT_STAT_ST_GEN
case SHOW_st_gen: case SHOW_st_gen:
small = (sizeof(st->st_gen) == 4); small = (sizeof(st->st_gen) == 4);
data = st->st_gen; data = st->st_gen;
@ -687,6 +736,7 @@ format1(const struct stat *st,
if (ofmt == 0) if (ofmt == 0)
ofmt = FMTF_UNSIGNED; ofmt = FMTF_UNSIGNED;
break; break;
#endif /* HAVE_STRUCT_STAT_ST_GEN */
case SHOW_symlink: case SHOW_symlink:
small = 0; small = 0;
data = 0; data = 0;
@ -725,7 +775,12 @@ format1(const struct stat *st,
break; break;
case S_IFLNK: (void)strcat(sdata, "@"); break; case S_IFLNK: (void)strcat(sdata, "@"); break;
case S_IFSOCK: (void)strcat(sdata, "="); break; case S_IFSOCK: (void)strcat(sdata, "="); break;
#ifdef S_IFWHT
case S_IFWHT: (void)strcat(sdata, "%"); break; case S_IFWHT: (void)strcat(sdata, "%"); break;
#endif /* S_IFWHT */
#ifdef S_IFDOOR
case S_IFDOOR: (void)strcat(sdata, ">"); break;
#endif /* S_IFDOOR */
} }
hilo = 0; hilo = 0;
} }
@ -738,7 +793,12 @@ format1(const struct stat *st,
case S_IFREG: sdata = "Regular File"; break; case S_IFREG: sdata = "Regular File"; break;
case S_IFLNK: sdata = "Symbolic Link"; break; case S_IFLNK: sdata = "Symbolic Link"; break;
case S_IFSOCK: sdata = "Socket"; break; case S_IFSOCK: sdata = "Socket"; break;
#ifdef S_IFWHT
case S_IFWHT: sdata = "Whiteout File"; break; case S_IFWHT: sdata = "Whiteout File"; break;
#endif /* S_IFWHT */
#ifdef S_IFDOOR
case S_IFDOOR: sdata = "Door"; break;
#endif /* S_IFDOOR */
default: sdata = "???"; break; default: sdata = "???"; break;
} }
hilo = 0; hilo = 0;