improved dev_t print format definition

This commit is contained in:
Gerhard Rieger 2012-11-17 15:30:27 +01:00
parent 2b1eabd058
commit 019cce7611
6 changed files with 31 additions and 28 deletions

View file

@ -89,6 +89,8 @@ corrections:
fixed configure.in bug on net/if.h check that caused IF_NAMESIZE to be
undefined
improved dev_t print format definition
docu mentions option so-bindtodev but correct name is so-bindtodevice.
Thanks to Jim Zimmerman for reporting.

View file

@ -304,27 +304,27 @@
/* all unsigned; default: unsigned long */
#if !defined(HAVE_TYPEOF_ST_DEV) || !HAVE_TYPEOF_ST_DEV
# undef HAVE_TYPEOF_ST_DEV
# define HAVE_TYPEOF_ST_DEV 6
#if !defined(HAVE_BASIC_DEV_T) || !HAVE_BASIC_DEV_T
# undef HAVE_BASIC_DEV_T
# define HAVE_BASIC_DEV_T 6
#endif
#ifndef F_st_dev
# if HAVE_TYPEOF_ST_DEV==1
#define F_st_dev "%hd"
# elif HAVE_TYPEOF_ST_DEV==2
#define F_st_dev "%hu"
# elif HAVE_TYPEOF_ST_DEV==3
#define F_st_dev "%d"
# elif HAVE_TYPEOF_ST_DEV==4
#define F_st_dev "%u"
# elif HAVE_TYPEOF_ST_DEV==5
#define F_st_dev "%ld"
# elif HAVE_TYPEOF_ST_DEV==6
#define F_st_dev "%lu"
# elif HAVE_TYPEOF_ST_DEV==7
#define F_st_dev "%Ld"
# elif HAVE_TYPEOF_ST_DEV==8
#define F_st_dev "%Lu"
#ifndef F_dev
# if HAVE_BASIC_DEV_T==1
#define F_dev "%hd"
# elif HAVE_BASIC_DEV_T==2
#define F_dev "%hu"
# elif HAVE_BASIC_DEV_T==3
#define F_dev "%d"
# elif HAVE_BASIC_DEV_T==4
#define F_dev "%u"
# elif HAVE_BASIC_DEV_T==5
#define F_dev "%ld"
# elif HAVE_BASIC_DEV_T==6
#define F_dev "%lu"
# elif HAVE_BASIC_DEV_T==7
#define F_dev "%Ld"
# elif HAVE_BASIC_DEV_T==8
#define F_dev "%Lu"
# else
#error "HAVE_TYPEOF_ST_DEV is out of range:" HAVE_TYPEOF_ST_DEV
# endif

View file

@ -456,10 +456,10 @@
#undef HAVE_BASIC_TIME_T
#undef HAVE_BASIC_OFF_T
#undef HAVE_BASIC_OFF64_T
#undef HAVE_BASIC_DEV_T
#undef HAVE_BASIC_SOCKLEN_T
#undef HAVE_TYPEOF_ST_DEV
#undef HAVE_TYPEOF_ST_INO
#undef HAVE_TYPEOF_ST_NLINK
#undef HAVE_TYPEOF_ST_SIZE

View file

@ -1446,7 +1446,8 @@ AC_BASIC_TYPE([#include <sys/types.h>
#include <unistd.h>], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic)
# oh god, __dev_t in Linux 2.4 is struct{int[2];}, not handled here yet.
AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_dev, HAVE_TYPEOF_ST_DEV, sc_cv_type_stat_stdev_basic)
AC_BASIC_TYPE([#include <sys/stat.h>], dev_t, HAVE_BASIC_DEV_T, sc_cv_type_dev_basic)
AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_ino, HAVE_TYPEOF_ST_INO, sc_cv_type_stat_stino_basic)
AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_nlink, HAVE_TYPEOF_ST_NLINK, sc_cv_type_stat_stnlink_basic)
AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_size, HAVE_TYPEOF_ST_SIZE, sc_cv_type_stat_stsize_basic)

View file

@ -263,7 +263,7 @@ int filan_stat(
headprinted = 1;
}
if (filan_rawoutput) {
snprintf(stdevstr, 8, F_st_dev, buf->st_dev);
snprintf(stdevstr, 8, F_dev, buf->st_dev);
} else {
snprintf(stdevstr, 8, "%hu,%hu", (unsigned short)buf->st_dev>>8, (unsigned short)buf->st_dev&0xff);
}

10
sycls.c
View file

@ -333,7 +333,7 @@ int Gettimeofday(struct timeval *tv, struct timezone *tz) {
int Mknod(const char *pathname, mode_t mode, dev_t dev) {
int result, _errno;
Debug3("mknod(\"%s\", 0%o, %d)", pathname, mode, dev);
Debug3("mknod(\"%s\", 0%o, "F_dev")", pathname, mode, dev);
result = mknod(pathname, mode, dev);
_errno = errno;
Debug1("mknod() -> %d", result);
@ -354,11 +354,11 @@ int Mkfifo(const char *pathname, mode_t mode) {
static void prtstat(const char *func, struct stat *buf, int result) {
char txt[256], *t = txt;
t += sprintf(t, "%s(, {"F_st_dev","F_st_ino","F_mode","F_st_nlink","F_uid","F_gid,
t += sprintf(t, "%s(, {"F_dev","F_st_ino","F_mode","F_st_nlink","F_uid","F_gid,
func, buf->st_dev, buf->st_ino,
buf->st_mode, buf->st_nlink, buf->st_uid, buf->st_gid);
#if HAVE_ST_RDEV
t += sprintf(t, ","F_st_dev, buf->st_rdev);
t += sprintf(t, ","F_dev, buf->st_rdev);
#endif
t += sprintf(t, ","F_st_size, buf->st_size);
#if HAVE_ST_BLKSIZE
@ -378,11 +378,11 @@ static void prtstat64(const char *func, struct stat64 *buf, int result) {
if (result < 0) {
sprintf(t, "%s(, {}) -> %d", func, result);
} else {
t += sprintf(t, "%s(, {"F_st_dev","F_st64_ino","F_mode","F_st_nlink","F_uid","F_gid,
t += sprintf(t, "%s(, {"F_dev","F_st64_ino","F_mode","F_st_nlink","F_uid","F_gid,
func, buf->st_dev, buf->st_ino,
buf->st_mode, buf->st_nlink, buf->st_uid, buf->st_gid);
#if HAVE_ST_RDEV
t += sprintf(t, ","F_st_dev, buf->st_rdev);
t += sprintf(t, ","F_dev, buf->st_rdev);
#endif
t += sprintf(t, ","F_st64_size, buf->st_size);
#if HAVE_ST_BLKSIZE