From d1151f9bab097777251f26772ebcc50468637a12 Mon Sep 17 00:00:00 2001 From: Jason King Date: Sun, 11 Jun 2017 01:01:30 -0500 Subject: [PATCH] 8369 libcmdutils should be better about large file support 8370 libcmdutils needlessly defines its own OFFSETOF() macro Reviewed by: Yuri Pankov Reviewed by: Toomas Soome Reviewed by: Robert Mustacchi Approved by: Gordon Ross --- usr/src/lib/libcmdutils/common/avltree.c | 7 ++++--- usr/src/lib/libcmdutils/libcmdutils.h | 31 +++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/usr/src/lib/libcmdutils/common/avltree.c b/usr/src/lib/libcmdutils/common/avltree.c index 53e919ed34..7146ad4c97 100644 --- a/usr/src/lib/libcmdutils/common/avltree.c +++ b/usr/src/lib/libcmdutils/common/avltree.c @@ -22,13 +22,14 @@ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2017 Joyent, Inc. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include +#include #include "libcmdutils.h" /* @@ -175,7 +176,7 @@ add_tnode(avl_tree_t **stree, dev_t device, ino_t inode) avl_create(*stree, tnode_compare, sizeof (tree_node_t), - OFFSETOF(tree_node_t, avl_link)); + offsetof(tree_node_t, avl_link)); } /* Initialize the node */ diff --git a/usr/src/lib/libcmdutils/libcmdutils.h b/usr/src/lib/libcmdutils/libcmdutils.h index 7c3d0ebbc1..933ceb0fde 100644 --- a/usr/src/lib/libcmdutils/libcmdutils.h +++ b/usr/src/lib/libcmdutils/libcmdutils.h @@ -26,7 +26,7 @@ * Copyright (c) 2013 RackTop Systems. */ /* - * Copyright 2016 Joyent, Inc. + * Copyright 2017 Joyent, Inc. */ /* @@ -36,6 +36,11 @@ #ifndef _LIBCMDUTILS_H #define _LIBCMDUTILS_H +#if !defined(_LP64) && \ + !((_FILE_OFFSET_BITS == 64) || defined(_LARGEFILE64_SOURCE)) +#error "libcmdutils.h can only be used in a largefile compilation environment" +#endif + /* * This is a private header file. Applications should not directly include * this file. @@ -70,16 +75,21 @@ extern "C" { #define MAXMAPSIZE (1024*1024*8) /* map at most 8MB */ #define SMALLFILESIZE (32*1024) /* don't use mmap on little file */ -/* avltree */ -#define OFFSETOF(s, m) ((size_t)(&(((s *)0)->m))) - /* Type used for a node containing a device id and inode number */ + +#if defined(_LP64) || (_FILE_OFFSET_BITS == 64) typedef struct tree_node { dev_t node_dev; ino_t node_ino; avl_node_t avl_link; } tree_node_t; - +#else +typedef struct tree_node { + dev_t node_dev; + ino64_t node_ino; + avl_node_t avl_link; +} tree_node_t; +#endif /* extended system attribute support */ @@ -90,8 +100,13 @@ extern int sysattr_type(char *); extern int sysattr_support(char *, int); /* Copies the content of the source file to the target file */ +#if defined(_LP64) || (_FILE_OFFSET_BITS == 64) extern int writefile(int, int, char *, char *, char *, char *, -struct stat *, struct stat *); + struct stat *, struct stat *); +#else +extern int writefile(int, int, char *, char *, char *, char *, + struct stat64 *, struct stat64 *); +#endif /* Gets file descriptors of the source and target attribute files */ extern int get_attrdirs(int, int, char *, int *, int *); @@ -120,7 +135,11 @@ extern int tnode_compare(const void *, const void *); * application must set the tree pointer to NULL before calling * add_tnode() for the first time. */ +#if defined(_LP64) || (_FILE_OFFSET_BITS == 64) extern int add_tnode(avl_tree_t **, dev_t, ino_t); +#else +extern int add_tnode(avl_tree_t **, dev_t, ino64_t); +#endif /* * Used to destroy a whole tree (all nodes) without rebalancing. -- 2.11.4.GIT