~ubuntu-branches/ubuntu/precise/gzip/precise

« back to all changes in this revision

Viewing changes to lib/fchmodat.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-10-19 11:42:42 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20111019114242-d8wiiu8kbvdtgmgj
Tags: 1.4-1ubuntu1
* Merge with Debian testing.  Remaining Ubuntu changes:
  - debian/{control,rules}: Remove the Win32 build and mingw64
    build-dependency, since mingw is in universe, and will remain so for
    the forseeable future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Change the protections of file relative to an open directory.
 
2
   Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
 
3
 
 
4
   This program is free software: you can redistribute it and/or modify
 
5
   it under the terms of the GNU General Public License as published by
 
6
   the Free Software Foundation; either version 3 of the License, or
 
7
   (at your option) any later version.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License
 
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
16
 
 
17
/* written by Jim Meyering */
 
18
 
 
19
#include <config.h>
 
20
 
 
21
#include <sys/stat.h>
 
22
 
 
23
#include <errno.h>
 
24
 
 
25
#ifndef HAVE_LCHMOD
 
26
/* Use a different name, to avoid conflicting with any
 
27
   system-supplied declaration.  */
 
28
# undef lchmod
 
29
# define lchmod lchmod_rpl
 
30
static int
 
31
lchmod (char const *f _GL_UNUSED, mode_t m _GL_UNUSED)
 
32
{
 
33
  errno = ENOSYS;
 
34
  return -1;
 
35
}
 
36
#endif
 
37
 
 
38
/* Solaris 10 has no function like this.
 
39
   Invoke chmod or lchmod on file, FILE, using mode MODE, in the directory
 
40
   open on descriptor FD.  If possible, do it without changing the
 
41
   working directory.  Otherwise, resort to using save_cwd/fchdir,
 
42
   then (chmod|lchmod)/restore_cwd.  If either the save_cwd or the
 
43
   restore_cwd fails, then give a diagnostic and exit nonzero.
 
44
   Note that an attempt to use a FLAG value of AT_SYMLINK_NOFOLLOW
 
45
   on a system without lchmod support causes this function to fail.  */
 
46
 
 
47
#define AT_FUNC_NAME fchmodat
 
48
#define AT_FUNC_F1 lchmod
 
49
#define AT_FUNC_F2 chmod
 
50
#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
 
51
#define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode, int flag
 
52
#define AT_FUNC_POST_FILE_ARGS        , mode
 
53
#include "at-func.c"