Merge of master-melb:xfs-cmds:25838a by kenmcd.
+[cvs]
+ - Fix a case where xfs_repair could incorrectly flag extent
+ b+tree nodes as corrupt.
+ - Portability changes, get xfs_repair compiling on IRIX.
+ - Parent pointer updates in xfs_io checker command.
+
xfsprogs-2.7.17 (05 April 2006)
- Fix libxfs access(2) check on /proc/mounts, which was
causing issues when xfs_check/xfs_repair run on readonly
optreset = 0;
}
+static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
+{
+ return uuid_compare(uu1, uu2, NULL);
+}
+
+static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer)
+{
+ uint32_t status;
+ char *str;
+ uuid_to_string(uu, &str, &status);
+ if (status == uuid_s_ok)
+ strcpy(buf, str);
+ else *buf = '\0';
+ free(str);
+}
+
+static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
+{
+ uint32_t status;
+ uuid_from_string(buffer, uu, &status);
+ return (status == uuid_s_ok);
+}
+
+static __inline__ int platform_uuid_is_null(uuid_t *uu)
+{
+ return uuid_is_nil(uu, NULL);
+}
+
+static __inline__ void platform_uuid_generate(uuid_t *uu)
+{
+ uuid_create(uu, NULL);
+}
+
+static __inline__ void platform_uuid_clear(uuid_t *uu)
+{
+ uuid_create_nil(uu, NULL);
+}
+
+static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
+{
+ memcpy(dst, src, sizeof(uuid_t));
+}
+
#define __int8_t int8_t
#define __int16_t int16_t
#define __int32_t int32_t
optind = 0;
}
-/*
- * Implement Linux libuuid functions in terms of DEC DCE's uuid
- * functions from FreeBSD libc.
- */
-
-static __inline__ int gnu_uuid_compare(uuid_t a, uuid_t b)
+static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
{
- return uuid_compare(&a, &b, NULL);
+ return uuid_compare(uu1, uu2, NULL);
}
-#define uuid_compare gnu_uuid_compare
-static __inline__ int uuid_is_null(uuid_t uid)
-{
- return uuid_is_nil(&uid, NULL);
-}
-
-static __inline__ void uuid_unparse(uuid_t uid, char *buf)
+static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer)
{
uint32_t status;
- char *str;
- uuid_to_string(&uid, &str, &status);
+ char *s;
+ uuid_to_string(uu, &s, &status);
if (status == uuid_s_ok)
- strcpy(buf, str);
- else *buf = '\0';
- free(str);
+ strcpy(*buffer, s);
+ else *buffer[0] = '\0';
+ free(s);
}
-static __inline__ int gnu_uuid_parse(const char *buf, uuid_t *uid)
+static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
{
uint32_t status;
- uuid_from_string(buf, uid, &status);
+ uuid_from_string(buffer, uu, &status);
return (status == uuid_s_ok);
}
-#define uuid_parse(s,u) gnu_uuid_parse((s), &(u))
-#define uuid_generate(uid) uuid_create(&(uid), NULL)
-#define uuid_clear(uid) uuid_create_nil(&(uid), NULL)
-#define uuid_copy(dst, src) memcpy(&(dst), &(src), sizeof(uuid_t))
+static __inline__ int platform_uuid_is_null(uuid_t *uu)
+{
+ return uuid_is_nil(uu, NULL);
+}
+
+static __inline__ void platform_uuid_generate(uuid_t *uu)
+{
+ uuid_create(uu, NULL);
+}
+
+static __inline__ void platform_uuid_clear(uuid_t *uu)
+{
+ uuid_create_nil(uu, NULL);
+}
+
+static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
+{
+ memcpy(dst, src, sizeof(uuid_t));
+}
#endif /* __XFS_FREEBSD_H__ */
#define __BYTE_ORDER BYTE_ORDER
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
-#define __fswab16(x) (x)
-#define __fswab32(x) (x)
-#define __fswab64(x) (x)
+#define HAVE_SWABMACROS 1
+#define INT_SWAP16(type,var) (var)
+#define INT_SWAP32(type,var) (var)
+#define INT_SWAP64(type,var) (var)
/* Map some gcc macros for the MipsPRO compiler */
#ifndef __GNUC__
+#define __builtin_constant_p(x) (0)
+#define __FUNCTION__ "XFS"
#define __sgi__ __sgi
#define __inline__ __inline
#define inline __inline
getoptreset();
}
+static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
+{
+ uint_t status;
+ return uuid_compare(uu1, uu2, &status);
+}
+
+static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer)
+{
+ uint_t status;
+ char *s;
+ uuid_to_string(uu, &s, &status);
+ if (status == uuid_s_ok)
+ strcpy(*buffer, s);
+ else *buffer[0] = '\0';
+ free(s);
+}
+
+static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
+{
+ uint_t status;
+ uuid_from_string(buffer, uu, &status);
+ return (status == uuid_s_ok);
+}
+
+static __inline__ int platform_uuid_is_null(uuid_t *uu)
+{
+ uint status;
+ return uuid_is_nil(uu, &status);
+}
+
+static __inline__ void platform_uuid_generate(uuid_t *uu)
+{
+ uint_t status;
+ uuid_create(uu, &status);
+}
+
+static __inline__ void platform_uuid_clear(uuid_t *uu)
+{
+ uint_t status;
+ uuid_create_nil(uu, &status);
+}
+
+static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
+{
+ memcpy(dst, src, sizeof(uuid_t));
+}
+
static __inline__ char * strsep(char **s, const char *ct)
{
char *sbegin = *s, *end;
/* Shared utility routines */
extern unsigned int libxfs_log2_roundup(unsigned int i);
+extern void cmn_err(int, char *, ...);
+enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
#include <xfs/xfs_ialloc.h>
#include <xfs/xfs_rtalloc.h>
#define unlikely(x) (x)
#define min(a,b) ((a) < (b) ? (a) : (b))
-#if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95))
-# define xlog_warn(fmt,args...) \
- ( fprintf(stderr,fmt,## args), fputc('\n', stderr) )
-# define cmn_err(sev,fmt,args...) \
- xlog_warn(fmt,## args)
-# define xlog_exit(fmt,args...) \
- ( xlog_warn(fmt,## args), exit(1) )
-# define xlog_panic(fmt,args...) \
- xlog_exit(fmt,## args)
-#else
-# define xlog_warn(...) \
- ( fprintf(stderr,__VA_ARGS__), fputc('\n', stderr) )
-# define cmn_err(sev,...) \
- xlog_warn(__VA_ARGS__)
-# define xlog_exit(...) \
- ( xlog_warn(__VA_ARGS__), exit(1) )
-# define xlog_panic(...) \
- xlog_exit(__VA_ARGS__)
-#endif
+extern void xlog_warn(char *fmt,...);
+extern void xlog_exit(char *fmt,...);
+extern void xlog_panic(char *fmt,...);
#define xlog_get_bp(log,bbs) libxfs_getbuf(x.logdev, 0, (bbs))
#define xlog_put_bp(bp) libxfs_putbuf(bp)
optind = 0;
}
-#ifndef O_DIRECT
-# if defined (__powerpc__)
-# define O_DIRECT 0400000
-# elif defined (__sparc__)
-# define O_DIRECT 0x100000
-# endif
-#endif
+static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
+{
+ return uuid_compare(*uu1, *uu2);
+}
+
+static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer)
+{
+ uuid_unparse(*uu, *buffer);
+}
+
+static __inline__ int platform_uuid_is_null(uuid_t *uu)
+{
+ return uuid_is_null(*uu);
+}
#if (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 1))
# define constpp const char * const *
#endif
#define ENOATTR ENODATA /* Attribute not found */
-#define EFSCORRUPTED 990 /* Filesystem is corrupted */
+#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
typedef loff_t xfs_off_t;
typedef __uint64_t xfs_ino_t;
7, 7, 7, 7, 7, 7, 7, 7, /* f8 .. ff */
};
-/*
- * Count of bits set in byte, 0..8.
- */
-static const char xfs_countbit[256] = {
- 0, 1, 1, 2, 1, 2, 2, 3, /* 00 .. 07 */
- 1, 2, 2, 3, 2, 3, 3, 4, /* 08 .. 0f */
- 1, 2, 2, 3, 2, 3, 3, 4, /* 10 .. 17 */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 18 .. 1f */
- 1, 2, 2, 3, 2, 3, 3, 4, /* 20 .. 27 */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 28 .. 2f */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 30 .. 37 */
- 3, 4, 4, 5, 4, 5, 5, 6, /* 38 .. 3f */
- 1, 2, 2, 3, 2, 3, 3, 4, /* 40 .. 47 */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 48 .. 4f */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 50 .. 57 */
- 3, 4, 4, 5, 4, 5, 5, 6, /* 58 .. 5f */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 60 .. 67 */
- 3, 4, 4, 5, 4, 5, 5, 6, /* 68 .. 6f */
- 3, 4, 4, 5, 4, 5, 5, 6, /* 70 .. 77 */
- 4, 5, 5, 6, 5, 6, 6, 7, /* 78 .. 7f */
- 1, 2, 2, 3, 2, 3, 3, 4, /* 80 .. 87 */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 88 .. 8f */
- 2, 3, 3, 4, 3, 4, 4, 5, /* 90 .. 97 */
- 3, 4, 4, 5, 4, 5, 5, 6, /* 98 .. 9f */
- 2, 3, 3, 4, 3, 4, 4, 5, /* a0 .. a7 */
- 3, 4, 4, 5, 4, 5, 5, 6, /* a8 .. af */
- 3, 4, 4, 5, 4, 5, 5, 6, /* b0 .. b7 */
- 4, 5, 5, 6, 5, 6, 6, 7, /* b8 .. bf */
- 2, 3, 3, 4, 3, 4, 4, 5, /* c0 .. c7 */
- 3, 4, 4, 5, 4, 5, 5, 6, /* c8 .. cf */
- 3, 4, 4, 5, 4, 5, 5, 6, /* d0 .. d7 */
- 4, 5, 5, 6, 5, 6, 6, 7, /* d8 .. df */
- 3, 4, 4, 5, 4, 5, 5, 6, /* e0 .. e7 */
- 4, 5, 5, 6, 5, 6, 6, 7, /* e8 .. ef */
- 4, 5, 5, 6, 5, 6, 6, 7, /* f0 .. f7 */
- 5, 6, 6, 7, 6, 7, 7, 8, /* f8 .. ff */
-};
-
/*
* xfs_lowbit32: get low bit set out of 32-bit argument, -1 if none set.
*/
return;
}
-void
-platform_get_blocksize(int fd, char *path)
-{
- return BBSIZE;
-}
-
void
platform_flush_device(int fd, dev_t device)
{
INT_SET(op->oh_res2, ARCH_CONVERT, 0);
/* and the data for this op */
- memcpy(p + sizeof(xlog_op_header_t), &magic, sizeof(magic));
+ memcpy((char *)p + sizeof(xlog_op_header_t), &magic, sizeof(magic));
}
static xfs_caddr_t next(xfs_caddr_t ptr, int offset, void *private)
{
xfs_buf_t *bp;
xfs_buf_log_item_t *bip;
- xfs_buftarg_t bdev = { dev };
+ xfs_buftarg_t bdev;
if (tp == NULL)
return libxfs_getbuf(dev, d, len);
+ bdev.dev = dev;
if (tp->t_items.lic_next == NULL)
bp = xfs_trans_buf_item_match(tp, &bdev, d, len);
else
xfs_buf_t *bp;
xfs_buf_log_item_t *bip;
int error;
- xfs_buftarg_t bdev = { dev };
+ xfs_buftarg_t bdev;
if (tp == NULL) {
bp = libxfs_getbuf(mp->m_dev, blkno, len);
return error;
}
+ bdev.dev = dev;
if (tp->t_items.lic_next == NULL)
bp = xfs_trans_buf_item_match(tp, &bdev, blkno, len);
else
#include <xfs.h>
#include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
/*
* Change the requested timestamp in the given inode.
*tp = ntp;
if ((i = xfs_trans_reserve(*tp, 0, 0, 0, 0, 0))) {
fprintf(stderr, _("%s: cannot reserve space: %s\n"),
- progname, strerror(errno));
+ progname, strerror(i));
exit(1);
}
xfs_trans_bjoin(*tp, ialloc_context);
*ipp = ip;
return error;
}
+
+/*
+ * Userspace versions of common diagnostic routines (varargs fun).
+ */
+void
+xfs_fs_repair_cmn_err(int level, xfs_mount_t *mp, char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, " This is a bug.\n");
+ fprintf(stderr, "Please report it to xfs@oss.sgi.com.\n");
+ va_end(ap);
+}
+
+void
+xfs_fs_cmn_err(int level, xfs_mount_t *mp, char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ va_end(ap);
+}
+
+void
+cmn_err(int level, char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ va_end(ap);
+}
#define spinlock_init(a,b) ((void) 0)
#define spin_lock(a) ((void) 0)
#define spin_unlock(a) ((void) 0)
-#define __return_address __builtin_return_address(0)
#define xfs_btree_reada_bufl(m,fsb,c) ((void) 0)
#define xfs_btree_reada_bufs(m,fsb,c,x) ((void) 0)
#define XFS_SB_LOCK(mp) 0
#define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl) 0
#define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl) 0
-/* These are lifted from the kernel */
+#ifdef __GNUC__
+#define __return_address __builtin_return_address(0)
#define get_unaligned(ptr) \
({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
-
#define put_unaligned(val, ptr) \
({ __typeof__(*(ptr)) __tmp = (val); \
memmove((ptr), &__tmp, sizeof(*(ptr))); \
(void)0; })
-
-#define REPAIR_MESSAGE _(" This is a bug.\n" \
- "Please report it to linux-xfs@oss.sgi.com.\n")
-#if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95))
-# define xfs_fs_repair_cmn_err(a,b,msg,args...) \
- ( fprintf(stderr, msg, ## args), fprintf(stderr, REPAIR_MESSAGE) )
-# define xfs_fs_cmn_err(a,b,msg,args...)( fprintf(stderr, msg, ## args) )
-# define cmn_err(a,msg,args...) ( fprintf(stderr, msg, ## args) )
-# define printk(msg,args...) ( fprintf(stderr, msg, ## args) )
#else
-# define xfs_fs_repair_cmn_err(a,b,...) \
- ( fprintf(stderr, __VA_ARGS__), fprintf(stderr, REPAIR_MESSAGE) )
-# define xfs_fs_cmn_err(a,b,...) ( fprintf(stderr, __VA_ARGS__) )
-# define cmn_err(a,...) ( fprintf(stderr, __VA_ARGS__) )
-# define printk(...) ( fprintf(stderr, __VA_ARGS__) )
+#define get_unaligned(ptr) (*(ptr))
+#define put_unaligned(val, ptr) (*(ptr) = (val))
#endif
-#define rol32(x,y) (((x) << (y)) | ((x) >> (32 - (y))))
-#define do_mod(a, b) ((a) % (b))
-#define do_div(n,base) ({ \
- int __res; \
- __res = ((unsigned long) n) % (unsigned) base; \
- n = ((unsigned long) n) / (unsigned) base; \
- __res; })
+extern void xfs_fs_repair_cmn_err(int, struct xfs_mount *, char *, ...);
+extern void xfs_fs_cmn_err(int, struct xfs_mount *, char *, ...);
-static inline int atomicIncWithWrap(int *a, int b)
+static inline int __do_div(unsigned long long *n, unsigned base)
{
- int r = *a;
- (*a)++;
- if (*a == b)
- *a = 0;
- return r;
+ int __res;
+ __res = (int)(((unsigned long) *n) % (unsigned) base);
+ *n = ((unsigned long) *n) / (unsigned) base;
+ return __res;
}
+#define do_div(n,base) (__do_div(&(n), (base)))
+#define do_mod(a, b) ((a) % (b))
+#define rol32(x,y) (((x) << (y)) | ((x) >> (32 - (y))))
/*
static int
header_check_uuid(xfs_mount_t *mp, xlog_rec_header_t *head)
{
- char uu_log[64], uu_sb[64];
+ char uu_log[64], uu_sb[64], *uup_log = &uu_log[0], *uup_sb = &uu_sb[0];
if (print_skip_uuid) return 0;
- if (!uuid_compare(mp->m_sb.sb_uuid, head->h_fs_uuid)) return 0;
+ if (!platform_uuid_compare(&mp->m_sb.sb_uuid, &head->h_fs_uuid)) return 0;
- uuid_unparse(mp->m_sb.sb_uuid, uu_sb);
- uuid_unparse(head->h_fs_uuid, uu_log);
+ platform_uuid_unparse(&mp->m_sb.sb_uuid, &uup_sb);
+ platform_uuid_unparse(&head->h_fs_uuid, &uup_log);
printf(_("* ERROR: mismatched uuid in log\n"
"* SB : %s\n* log: %s\n"),
int
xlog_header_check_mount(xfs_mount_t *mp, xlog_rec_header_t *head)
{
- if (uuid_is_null(head->h_fs_uuid)) return 0;
+ if (platform_uuid_is_null(&head->h_fs_uuid)) return 0;
if (header_check_uuid(mp, head)) {
/* bail out now or just carry on regardless */
if (print_exit)
}
return 0;
}
+
+/*
+ * Userspace versions of common diagnostic routines (varargs fun).
+ */
+void
+xlog_warn(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ va_end(ap);
+}
+
+void
+xlog_exit(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ va_end(ap);
+ exit(1);
+}
+
+void
+xlog_panic(char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fputs("\n", stderr);
+ va_end(ap);
+ abort();
+}