~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to lib/openat.h

  • Committer: Steve Langasek
  • Date: 2012-06-29 02:07:40 UTC
  • mfrom: (4.1.9 sid)
  • Revision ID: steve.langasek@canonical.com-20120629020740-qqikrblzana08v2y
Merge version 1.5-1.1 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* provide a replacement openat function
2
 
   Copyright (C) 2004-2006, 2008-2010 Free Software Foundation, Inc.
 
2
   Copyright (C) 2004-2006, 2008-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
23
23
 
24
24
#include <sys/types.h>
25
25
#include <sys/stat.h>
26
 
#include <dirent.h>
27
26
#include <unistd.h>
28
27
#include <stdbool.h>
29
28
 
30
 
#ifndef __attribute__
31
 
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
32
 
#  define __attribute__(x) /* empty */
33
 
# endif
34
 
#endif
35
 
 
36
 
#ifndef ATTRIBUTE_NORETURN
37
 
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
38
 
#endif
39
 
 
40
29
#if !HAVE_OPENAT
41
30
 
42
31
int openat_permissive (int fd, char const *file, int flags, mode_t mode,
51
40
 
52
41
#endif
53
42
 
54
 
void openat_restore_fail (int) ATTRIBUTE_NORETURN;
55
 
void openat_save_fail (int) ATTRIBUTE_NORETURN;
 
43
_Noreturn void openat_restore_fail (int);
 
44
_Noreturn void openat_save_fail (int);
56
45
 
57
46
/* Using these function names makes application code
58
47
   slightly more readable than it would be with
59
48
   fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW).  */
 
49
 
 
50
#if GNULIB_FCHOWNAT
 
51
 
60
52
static inline int
61
53
chownat (int fd, char const *file, uid_t owner, gid_t group)
62
54
{
69
61
  return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
70
62
}
71
63
 
 
64
#endif
 
65
 
 
66
#if GNULIB_FCHMODAT
 
67
 
72
68
static inline int
73
69
chmodat (int fd, char const *file, mode_t mode)
74
70
{
81
77
  return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
82
78
}
83
79
 
 
80
#endif
 
81
 
 
82
#if GNULIB_FSTATAT
 
83
 
84
84
static inline int
85
85
statat (int fd, char const *name, struct stat *st)
86
86
{
93
93
  return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
94
94
}
95
95
 
96
 
#if GNULIB_FACCESSAT
 
96
#endif
 
97
 
97
98
/* For now, there are no wrappers named laccessat or leuidaccessat,
98
99
   since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
99
 
   since access rights on symlinks are of limited utility.  */
100
 
 
101
 
static inline int
102
 
accessat (int fd, char const *file, int mode)
103
 
{
104
 
  return faccessat (fd, file, mode, 0);
105
 
}
106
 
 
107
 
static inline int
108
 
euidaccessat (int fd, char const *file, int mode)
109
 
{
110
 
  return faccessat (fd, file, mode, AT_EACCESS);
111
 
}
112
 
#endif
 
100
   since access rights on symlinks are of limited utility.  Likewise,
 
101
   wrappers are not provided for accessat or euidaccessat, so as to
 
102
   avoid dragging in -lgen on some platforms.  */
113
103
 
114
104
#endif /* _GL_HEADER_OPENAT */