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

« back to all changes in this revision

Viewing changes to lib/at-func.c

  • 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
 
/* Define an at-style functions like fstatat, unlinkat, fchownat, etc.
2
 
   Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
 
1
/* Define at-style functions like fstatat, unlinkat, fchownat, etc.
 
2
   Copyright (C) 2006, 2009-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
17
17
/* written by Jim Meyering */
18
18
 
19
19
#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
20
 
#include "openat.h"
21
 
#include "openat-priv.h"
22
 
#include "save-cwd.h"
 
20
 
 
21
#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
 
22
# include <errno.h>
 
23
# ifndef ENOTSUP
 
24
#  define ENOTSUP EINVAL
 
25
# endif
 
26
#else
 
27
# include "openat.h"
 
28
# include "openat-priv.h"
 
29
# include "save-cwd.h"
 
30
#endif
23
31
 
24
32
#ifdef AT_FUNC_USE_F1_COND
25
33
# define CALL_FUNC(F)                           \
51
59
 
52
60
/* Call AT_FUNC_F1 to operate on FILE, which is in the directory
53
61
   open on descriptor FD.  If AT_FUNC_USE_F1_COND is defined to a value,
54
 
   AT_FUNC_POST_FILE_PARAM_DECLS must inlude a parameter named flag;
 
62
   AT_FUNC_POST_FILE_PARAM_DECLS must include a parameter named flag;
55
63
   call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than
56
64
   AT_FUNC_USE_F1_COND.  Return int and fail with -1 unless AT_FUNC_RESULT
57
65
   or AT_FUNC_FAIL are defined.  If possible, do it without changing the
61
69
FUNC_RESULT
62
70
AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
63
71
{
 
72
  VALIDATE_FLAG (flag);
 
73
 
 
74
  if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
 
75
    return CALL_FUNC (file);
 
76
 
 
77
#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
 
78
  errno = ENOTSUP;
 
79
  return FUNC_FAIL;
 
80
#else
 
81
  {
64
82
  /* Be careful to choose names unlikely to conflict with
65
83
     AT_FUNC_POST_FILE_PARAM_DECLS.  */
66
84
  struct saved_cwd saved_cwd;
67
85
  int saved_errno;
68
86
  FUNC_RESULT err;
69
87
 
70
 
  VALIDATE_FLAG (flag);
71
 
 
72
 
  if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
73
 
    return CALL_FUNC (file);
74
 
 
75
88
  {
76
89
    char proc_buf[OPENAT_BUFFER_SIZE];
77
90
    char *proc_file = openat_proc_name (proc_buf, fd, file);
125
138
  if (saved_errno)
126
139
    errno = saved_errno;
127
140
  return err;
 
141
  }
 
142
#endif
128
143
}
129
144
#undef CALL_FUNC
130
145
#undef FUNC_RESULT