~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/openat.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

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-2011 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
 
 
29
_GL_INLINE_HEADER_BEGIN
 
30
 
30
31
#if !HAVE_OPENAT
31
32
 
32
33
int openat_permissive (int fd, char const *file, int flags, mode_t mode,
47
48
/* Using these function names makes application code
48
49
   slightly more readable than it would be with
49
50
   fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW).  */
50
 
static inline int
 
51
 
 
52
#if GNULIB_FCHOWNAT
 
53
 
 
54
# ifndef FCHOWNAT_INLINE
 
55
#  define FCHOWNAT_INLINE _GL_INLINE
 
56
# endif
 
57
 
 
58
FCHOWNAT_INLINE int
51
59
chownat (int fd, char const *file, uid_t owner, gid_t group)
52
60
{
53
61
  return fchownat (fd, file, owner, group, 0);
54
62
}
55
63
 
56
 
static inline int
 
64
FCHOWNAT_INLINE int
57
65
lchownat (int fd, char const *file, uid_t owner, gid_t group)
58
66
{
59
67
  return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
60
68
}
61
69
 
62
 
static inline int
 
70
#endif
 
71
 
 
72
#if GNULIB_FCHMODAT
 
73
 
 
74
# ifndef FCHMODAT_INLINE
 
75
#  define FCHMODAT_INLINE _GL_INLINE
 
76
# endif
 
77
 
 
78
FCHMODAT_INLINE int
63
79
chmodat (int fd, char const *file, mode_t mode)
64
80
{
65
81
  return fchmodat (fd, file, mode, 0);
66
82
}
67
83
 
68
 
static inline int
 
84
FCHMODAT_INLINE int
69
85
lchmodat (int fd, char const *file, mode_t mode)
70
86
{
71
87
  return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
72
88
}
73
89
 
74
 
static inline int
 
90
#endif
 
91
 
 
92
#if GNULIB_FSTATAT
 
93
 
 
94
# ifndef FSTATAT_INLINE
 
95
#  define FSTATAT_INLINE _GL_INLINE
 
96
# endif
 
97
 
 
98
FSTATAT_INLINE int
75
99
statat (int fd, char const *name, struct stat *st)
76
100
{
77
101
  return fstatat (fd, name, st, 0);
78
102
}
79
103
 
80
 
static inline int
 
104
FSTATAT_INLINE int
81
105
lstatat (int fd, char const *name, struct stat *st)
82
106
{
83
107
  return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
84
108
}
85
109
 
 
110
#endif
 
111
 
86
112
/* For now, there are no wrappers named laccessat or leuidaccessat,
87
113
   since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
88
114
   since access rights on symlinks are of limited utility.  Likewise,
89
115
   wrappers are not provided for accessat or euidaccessat, so as to
90
116
   avoid dragging in -lgen on some platforms.  */
91
117
 
 
118
_GL_INLINE_HEADER_END
 
119
 
92
120
#endif /* _GL_HEADER_OPENAT */