PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/usr.bin/csup/fattr.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 118 lines | 63 code | 16 blank | 39 comment | 0 complexity | ede34946c6299fe9ddb487e9dda208df MD5 | raw file
  1/*-
  2 * Copyright (c) 2003-2006, Maxime Henrion <mux@FreeBSD.org>
  3 * All rights reserved.
  4 *
  5 * Redistribution and use in source and binary forms, with or without
  6 * modification, are permitted provided that the following conditions
  7 * are met:
  8 * 1. Redistributions of source code must retain the above copyright
  9 *    notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 *    notice, this list of conditions and the following disclaimer in the
 12 *    documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 24 * SUCH DAMAGE.
 25 *
 26 * $FreeBSD$
 27 */
 28#ifndef _FATTR_H_
 29#define _FATTR_H_
 30
 31#include <sys/types.h>
 32
 33#include <fcntl.h>
 34#include <time.h>
 35
 36/*
 37 * File types.
 38 */
 39#define	FT_UNKNOWN	0			/* Unknown file type. */
 40#define	FT_FILE		1			/* Regular file. */
 41#define	FT_DIRECTORY	2			/* Directory. */
 42#define	FT_CDEV		3			/* Character device. */
 43#define	FT_BDEV		4			/* Block device. */
 44#define	FT_SYMLINK	5			/* Symbolic link. */
 45#define	FT_MAX		FT_SYMLINK		/* Maximum file type number. */
 46#define	FT_NUMBER	(FT_MAX + 1)		/* Number of file types. */
 47
 48/*
 49 * File attributes.
 50 */
 51#define	FA_FILETYPE	0x0001		/* True for all supported file types. */
 52#define	FA_MODTIME	0x0002		/* Last file modification time. */
 53#define	FA_SIZE		0x0004		/* Size of the file. */
 54#define	FA_LINKTARGET	0x0008		/* Target of a symbolic link. */
 55#define	FA_RDEV		0x0010		/* Device for a device node. */
 56#define	FA_OWNER	0x0020		/* Owner of the file. */
 57#define	FA_GROUP	0x0040		/* Group of the file. */
 58#define	FA_MODE		0x0080		/* File permissions. */
 59#define	FA_FLAGS	0x0100		/* 4.4BSD flags, a la chflags(2). */
 60#define	FA_LINKCOUNT	0x0200		/* Hard link count. */
 61#define	FA_DEV		0x0400		/* Device holding the inode. */
 62#define	FA_INODE	0x0800		/* Inode number. */
 63
 64#define	FA_MASK		0x0fff
 65
 66#define	FA_NUMBER	12		/* Number of file attributes. */
 67
 68/* Attributes that we might be able to change. */
 69#define	FA_CHANGEABLE	(FA_MODTIME | FA_OWNER | FA_GROUP | FA_MODE | FA_FLAGS)
 70
 71/*
 72 * Attributes that we don't want to save in the "checkouts" file
 73 * when in checkout mode.
 74 */
 75#define	FA_COIGNORE	(FA_MASK & ~(FA_FILETYPE|FA_MODTIME|FA_SIZE|FA_MODE))
 76
 77/* These are for fattr_frompath(). */
 78#define	FATTR_FOLLOW	0
 79#define	FATTR_NOFOLLOW	1
 80
 81struct stat;
 82struct fattr;
 83
 84typedef int	fattr_support_t[FT_NUMBER];
 85
 86extern const struct fattr *fattr_bogus;
 87
 88void		 fattr_init(void);
 89void		 fattr_fini(void);
 90
 91struct fattr	*fattr_new(int, time_t);
 92struct fattr	*fattr_default(int);
 93struct fattr	*fattr_fromstat(struct stat *);
 94struct fattr	*fattr_frompath(const char *, int);
 95struct fattr	*fattr_fromfd(int);
 96struct fattr	*fattr_decode(char *);
 97struct fattr	*fattr_forcheckout(const struct fattr *, mode_t);
 98struct fattr	*fattr_dup(const struct fattr *);
 99char		*fattr_encode(const struct fattr *, fattr_support_t, int);
100int		 fattr_type(const struct fattr *);
101void		 fattr_maskout(struct fattr *, int);
102int		 fattr_getmask(const struct fattr *);
103nlink_t		 fattr_getlinkcount(const struct fattr *);
104char		*fattr_getlinktarget(const struct fattr *);
105void		 fattr_umask(struct fattr *, mode_t);
106void		 fattr_merge(struct fattr *, const struct fattr *);
107void		 fattr_mergedefault(struct fattr *);
108void		 fattr_override(struct fattr *, const struct fattr *, int);
109int		 fattr_makenode(const struct fattr *, const char *);
110int		 fattr_delete(const char *path);
111int		 fattr_install(struct fattr *, const char *, const char *);
112int		 fattr_equal(const struct fattr *, const struct fattr *);
113void		 fattr_free(struct fattr *);
114int		 fattr_supported(int);
115off_t		 fattr_filesize(const struct fattr *);
116
117
118#endif /* !_FATTR_H_ */