10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5331Samw * Common Development and Distribution License (the "License"). 6*5331Samw * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * Declarations for the functions in libcmdutils. 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _LIBCMDUTILS_H 310Sstevel@tonic-gate #define _LIBCMDUTILS_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * This is a private header file. Applications should not directly include 370Sstevel@tonic-gate * this file. 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate 40*5331Samw #include <stdio.h> 41*5331Samw #include <unistd.h> 42*5331Samw #include <stdlib.h> 43*5331Samw #include <errno.h> 44*5331Samw #include <fcntl.h> 45*5331Samw #include <limits.h> 46*5331Samw #include <libintl.h> 47*5331Samw #include <string.h> 48*5331Samw #include <dirent.h> 49*5331Samw #include <attr.h> 500Sstevel@tonic-gate #include <sys/avl.h> 510Sstevel@tonic-gate #include <sys/types.h> 52*5331Samw #include <sys/stat.h> 53*5331Samw #include <sys/mman.h> 54*5331Samw #include <libnvpair.h> 550Sstevel@tonic-gate 560Sstevel@tonic-gate #ifdef __cplusplus 570Sstevel@tonic-gate extern "C" { 580Sstevel@tonic-gate #endif 590Sstevel@tonic-gate 60*5331Samw /* extended system attribute support */ 61*5331Samw #define _NOT_SATTR 0 62*5331Samw #define _RO_SATTR 1 63*5331Samw #define _RW_SATTR 2 64*5331Samw 65*5331Samw #define MAXMAPSIZE (1024*1024*8) /* map at most 8MB */ 66*5331Samw #define SMALLFILESIZE (32*1024) /* don't use mmap on little file */ 67*5331Samw #define ISREG(A) (((A).st_mode & S_IFMT) == S_IFREG) 68*5331Samw 690Sstevel@tonic-gate /* avltree */ 700Sstevel@tonic-gate #define OFFSETOF(s, m) ((size_t)(&(((s *)0)->m))) 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* Type used for a node containing a device id and inode number */ 730Sstevel@tonic-gate typedef struct tree_node { 740Sstevel@tonic-gate dev_t node_dev; 750Sstevel@tonic-gate ino_t node_ino; 760Sstevel@tonic-gate avl_node_t avl_link; 770Sstevel@tonic-gate } tree_node_t; 780Sstevel@tonic-gate 79*5331Samw 80*5331Samw /* extended system attribute support */ 81*5331Samw 82*5331Samw /* Determine if a file is the name of an extended system attribute file */ 83*5331Samw extern int sysattr_type(char *); 84*5331Samw 85*5331Samw /* Determine if the underlying file system supports system attributes */ 86*5331Samw extern int sysattr_support(char *, int); 87*5331Samw 88*5331Samw /* Copies the content of the source file to the target file */ 89*5331Samw extern int writefile(int, int, char *, char *, char *, char *, 90*5331Samw struct stat *, struct stat *); 91*5331Samw 92*5331Samw /* Gets file descriptors of the source and target attribute files */ 93*5331Samw extern int get_attrdirs(int, int, char *, int *, int *); 94*5331Samw 95*5331Samw /* Move extended attribute and extended system attribute */ 96*5331Samw extern int mv_xattrs(char *, char *, char *, int, int); 97*5331Samw 98*5331Samw /* Returns non default extended system attribute list */ 99*5331Samw extern nvlist_t *sysattr_list(char *, int, char *); 100*5331Samw 101*5331Samw 102*5331Samw 103*5331Samw /* avltree */ 104*5331Samw 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * Used to compare two nodes. We are attempting to match the 1st 1070Sstevel@tonic-gate * argument (node) against the 2nd argument (a node which 1080Sstevel@tonic-gate * is already in the search tree). 1090Sstevel@tonic-gate */ 110*5331Samw 1110Sstevel@tonic-gate extern int tnode_compare(const void *, const void *); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* 1140Sstevel@tonic-gate * Used to add a single node (containing the input device id and 1150Sstevel@tonic-gate * inode number) to the specified search tree. The calling 1160Sstevel@tonic-gate * application must set the tree pointer to NULL before calling 1170Sstevel@tonic-gate * add_tnode() for the first time. 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate extern int add_tnode(avl_tree_t **, dev_t, ino_t); 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate /* 1220Sstevel@tonic-gate * Used to destroy a whole tree (all nodes) without rebalancing. 1230Sstevel@tonic-gate * The calling application is responsible for setting the tree 1240Sstevel@tonic-gate * pointer to NULL upon return. 1250Sstevel@tonic-gate */ 1260Sstevel@tonic-gate extern void destroy_tree(avl_tree_t *); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate #ifdef __cplusplus 1290Sstevel@tonic-gate } 1300Sstevel@tonic-gate #endif 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #endif /* _LIBCMDUTILS_H */ 133