~ubuntu-branches/debian/wheezy/netatalk/wheezy

« back to all changes in this revision

Viewing changes to libatalk/vfs/unix.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2011-06-05 21:04:21 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110605210421-19gag2srevj0ocxh
Tags: 2.2~beta4-1
* New upstream release.
  + Fixes "Internal Error" after ad_open on sparc.
    Closes: bug#606005. Thanks to Alfredo Sola.
* Adjust references to unofficial packages in README.Debian.
* Use dversionmangle (not uversionmangle) in watch file. Fix add
  leading dash (-) to upstream version in mangling.
* Update patches:
  + Drop patches 107 and 294 (Zeroconf support): Implemented
    (differently) upstream now.
  + Drop patches 109 and 112 (avoid broken XFS linkage) obsolete.
  + Drop patch 200 (hostname resolving): adopted upstream.
  + Refresh patch 205.
* Rewrite copyright file using draft 174 of DEP-5 format.
* Build-depend on and recommend unversioned (i.e. default) BerkeleyDB
  packages.
  Closes: bug#621413. Thanks to Ondřej Surý.
  Simplify suggestions on older versioned BerkeleyDB packages.
* Stop installing some documentation dropped upstream, and let CDBS
  automagically handle some of the remains.
* Update control file:
  + Bump policy compliance to standards-version 3.9.2.
  + Shorten Vcs-* URLs.
* Add patches 115 and (for automade file) 214 to avoid installing
  unneeded /default dir.
  Closes: bug#628119. Thanks to Russell Muetzelfeldt and Luk Claes.
* Don't ship .la files. Closes: bug#621849. Thanks to Andreas Metzler
  and Luk Claes.
* Stop renaming afile and achfile, dropped upstream.
* Explicitly enable DDP (AppleTalk), now disabled by default.
* Enable Zeroconf, should be stable now.
* Simplify package relations:
  + Drop (build-)dependency fallback unneeded even for oldstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: unix.c,v 1.11 2010-04-18 16:14:51 hat001 Exp $
3
 
 *
4
2
 * Copyright (c) 1990,1993 Regents of The University of Michigan.
5
3
 * All Rights Reserved.  See COPYRIGHT.
6
 
 *
7
4
 */
8
5
 
9
6
#ifdef HAVE_CONFIG_H
24
21
#include <atalk/volume.h>
25
22
#include <atalk/logger.h>
26
23
#include <atalk/unix.h>
 
24
#include <atalk/acl.h>
27
25
 
28
26
/* -----------------------------
29
27
   a dropbox is a folder where w is set but not r eg:
103
101
/*
104
102
 * @brief system rmdir with afp error code.
105
103
 *
106
 
 * Supports *at semantics (cf openat) if HAVE_RENAMEAT. Pass dirfd=-1 to ignore this.
 
104
 * Supports *at semantics (cf openat) if HAVE_ATFUNCS. Pass dirfd=-1 to ignore this.
107
105
 */
108
106
int netatalk_rmdir_all_errors(int dirfd, const char *name)
109
107
{
110
108
    int err;
111
109
 
112
 
#ifdef HAVE_RENAMEAT
 
110
#ifdef HAVE_ATFUNCS
113
111
    if (dirfd == -1)
114
 
        dirfd = ATFD_CWD;
 
112
        dirfd = AT_FDCWD;
115
113
    err = unlinkat(dirfd, name, AT_REMOVEDIR);
116
114
#else
117
115
    err = rmdir(name);
138
136
/*
139
137
 * @brief System rmdir with afp error code, but ENOENT is not an error.
140
138
 *
141
 
 * Supports *at semantics (cf openat) if HAVE_RENAMEAT. Pass dirfd=-1 to ignore this.
 
139
 * Supports *at semantics (cf openat) if HAVE_ATFUNCS. Pass dirfd=-1 to ignore this.
142
140
 */
143
141
int netatalk_rmdir(int dirfd, const char *name)
144
142
{
190
188
 **************************************************************************/
191
189
 
192
190
/* 
193
 
 * Supports *at semantics if HAVE_RENAMEAT, pass dirfd=-1 to ignore this
 
191
 * Supports *at semantics if HAVE_ATFUNCS, pass dirfd=-1 to ignore this
194
192
 */
195
193
int copy_file(int dirfd, const char *src, const char *dst, mode_t mode)
196
194
{
201
199
    size_t  buflen;
202
200
    char   filebuf[8192];
203
201
 
204
 
#ifdef HAVE_RENAMEAT
 
202
#ifdef HAVE_ATFUNCS
205
203
    if (dirfd == -1)
206
 
        dirfd = ATFD_CWD;
 
204
        dirfd = AT_FDCWD;
207
205
    sfd = openat(dirfd, src, O_RDONLY);
208
206
#else
209
207
    sfd = open(src, O_RDONLY);
214
212
        return -1;
215
213
    }
216
214
 
217
 
    if ((dfd = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
 
215
    if ((dfd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, mode)) < 0) {
218
216
        LOG(log_error, logtype_afpd, "copy_file('%s'/'%s'): open '%s' error: %s",
219
217
            src, dst, dst, strerror(errno));
220
218
        ret = -1;
269
267
 */
270
268
int netatalk_unlinkat(int dirfd, const char *name)
271
269
{
272
 
#ifdef HAVE_RENAMEAT
 
270
#ifdef HAVE_ATFUNCS
273
271
    if (dirfd == -1)
274
272
        dirfd = AT_FDCWD;
275
273
 
298
296
/*
299
297
 * @brief This is equivalent of unix rename()
300
298
 *
301
 
 * unix_rename mulitplexes rename and renameat. If we dont HAVE_RENAMEAT, sfd and dfd
 
299
 * unix_rename mulitplexes rename and renameat. If we dont HAVE_ATFUNCS, sfd and dfd
302
300
 * are ignored.
303
301
 *
304
 
 * @param sfd        (r) if we HAVE_RENAMEAT, -1 gives AT_FDCWD
 
302
 * @param sfd        (r) if we HAVE_ATFUNCS, -1 gives AT_FDCWD
305
303
 * @param oldpath    (r) guess what
306
304
 * @param dfd        (r) same as sfd
307
305
 * @param newpath    (r) guess what
308
306
 */
309
307
int unix_rename(int sfd, const char *oldpath, int dfd, const char *newpath)
310
308
{
311
 
#ifdef HAVE_RENAMEAT
 
309
#ifdef HAVE_ATFUNCS
312
310
    if (sfd == -1)
313
311
        sfd = AT_FDCWD;
314
312
    if (dfd == -1)
319
317
#else
320
318
    if (rename(oldpath, newpath) < 0)
321
319
        return -1;
322
 
#endif  /* HAVE_RENAMEAT */
 
320
#endif  /* HAVE_ATFUNCS */
323
321
 
324
322
    return 0;
325
323
}
327
325
/* 
328
326
 * @brief stat/fsstatat multiplexer
329
327
 *
330
 
 * statat mulitplexes stat and fstatat. If we dont HAVE_RENAMEAT, dirfd is ignored.
 
328
 * statat mulitplexes stat and fstatat. If we dont HAVE_ATFUNCS, dirfd is ignored.
331
329
 *
332
 
 * @param dirfd   (r) Only used if HAVE_RENAMEAT, ignored else, -1 gives AT_FDCWD
 
330
 * @param dirfd   (r) Only used if HAVE_ATFUNCS, ignored else, -1 gives AT_FDCWD
333
331
 * @param path    (r) pathname
334
332
 * @param st      (rw) pointer to struct stat
335
333
 */
336
334
int statat(int dirfd, const char *path, struct stat *st)
337
335
{
338
 
#ifdef HAVE_RENAMEAT
 
336
#ifdef HAVE_ATFUNCS
339
337
    if (dirfd == -1)
340
338
        dirfd = AT_FDCWD;
341
339
    return (fstatat(dirfd, path, st, 0));
350
348
/* 
351
349
 * @brief lstat/fsstatat multiplexer
352
350
 *
353
 
 * lstatat mulitplexes lstat and fstatat. If we dont HAVE_RENAMEAT, dirfd is ignored.
 
351
 * lstatat mulitplexes lstat and fstatat. If we dont HAVE_ATFUNCS, dirfd is ignored.
354
352
 *
355
 
 * @param dirfd   (r) Only used if HAVE_RENAMEAT, ignored else, -1 gives AT_FDCWD
 
353
 * @param dirfd   (r) Only used if HAVE_ATFUNCS, ignored else, -1 gives AT_FDCWD
356
354
 * @param path    (r) pathname
357
355
 * @param st      (rw) pointer to struct stat
358
356
 */
359
357
int lstatat(int dirfd, const char *path, struct stat *st)
360
358
{
361
 
#ifdef HAVE_RENAMEAT
 
359
#ifdef HAVE_ATFUNCS
362
360
    if (dirfd == -1)
363
361
        dirfd = AT_FDCWD;
364
362
    return (fstatat(dirfd, path, st, AT_SYMLINK_NOFOLLOW));