#include <atalk/bstrlib.h>
#include <atalk/bstradd.h>
#include <atalk/acl.h>
+#include <atalk/globals.h>
#include <atalk/fce_api.h>
#include "directory.h"
#include "volume.h"
#include "fork.h"
#include "file.h"
-#include "globals.h"
#include "filedir.h"
#include "unix.h"
if ( uid != sb.st_uid )
{
seteuid(0);
- if (lchown(upath, sb.st_uid, sb.st_gid) < 0)
+ if (ochown(upath, sb.st_uid, sb.st_gid, vol_syml_opt(vol)) < 0)
{
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error changing owner/gid: %s",
upath, strerror(errno));
ret = AFPERR_ACCESS;
}
- else if ((!S_ISLNK(st->st_mode)) && (chmod(upath,(st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0))
- {
+ else if (ochmod(upath,
+ (st.st_mode & ~default_options.umask) | S_IRGRP | S_IROTH,
+ &sb,
+ vol_syml_opt(vol) | O_NETATALK_ACL) < 0) {
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error adding file read permissions: %s",
upath, strerror(errno));
ret = AFPERR_ACCESS;
}
- else if (lchown(adpath, sb.st_uid, sb.st_gid) < 0)
+ else if (ochown(adpath, sb.st_uid, sb.st_gid, vol_syml_opt(vol)) < 0)
{
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error changing AppleDouble owner/gid: %s",
adpath, strerror(errno));
ret = AFPERR_ACCESS;
}
- else if (chmod(adpath, (st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
+ else if (ochmod(adpath,
+ (st.st_mode & ~default_options.umask) | S_IRGRP| S_IROTH,
+ &st,
+ vol_syml_opt(vol) | O_NETATALK_ACL) < 0)
{
LOG(log_error, logtype_afpd,
"matchfile2dirperms(%s): Error adding AD file read permissions: %s",
if ( !isdir ) {
path.st_valid = 1;
path.st_errno = errno;
- if (of_findname(&path)) {
+ if (of_findname(vol, &path)) {
rc = AFPERR_EXIST; /* was AFPERR_BUSY; */
} else {
rc = renamefile(vol, sdir_fd, oldunixname, upath, newname, adp );
fce_register_delete_dir(cfrombstr(dname));
bdestroy(dname);
}
- } else if (of_findname(s_path)) {
+ } else if (of_findname(vol, s_path)) {
rc = AFPERR_BUSY;
} else {
/* it's a file st_valid should always be true
if (s_path->st_valid && s_path->st_errno == ENOENT) {
rc = AFPERR_NOOBJ;
} else {
- if ((rc = deletefile(vol, -1, upath, 1)) == AFP_OK)
+ if ((rc = deletefile(vol, -1, upath, 1)) == AFP_OK) {
fce_register_delete_file( s_path );
-
+ if (vol->v_tm_used < s_path->st.st_size)
+ vol->v_tm_used = 0;
+ else
+ vol->v_tm_used -= s_path->st.st_size;
+ }
struct dir *cachedfile;
- if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath), s_path->st.st_ctime))) {
+ if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath)))) {
dircache_remove(vol, cachedfile, DIRCACHE | DIDNAME_INDEX | QUEUE_INDEX);
dir_free(cachedfile);
}
}
}
if ( rc == AFP_OK ) {
- curdir->offcnt--;
+ curdir->d_offcnt--;
setvoltime(obj, vol );
}
rc = AFPERR_PARAM;
goto exit;
}
- curdir->offcnt++;
- sdir->offcnt--;
+ curdir->d_offcnt++;
+ sdir->d_offcnt--;
#ifdef DROPKLUDGE
if (vol->v_flags & AFPVOL_DROPBOX) {
/* FIXME did is not always the source id */
if (!isdir && !vol_unix_priv(vol)) {
int admode = ad_mode("", 0777) | vol->v_fperm;
- setfilmode(upath, admode, NULL, vol->v_umask);
- vol->vfs->vfs_setfilmode(vol, upath, admode, NULL);
+ setfilmode(vol, upath, admode, path->st_valid ? &path->st : NULL);
+ vol->vfs->vfs_setfilmode(vol, upath, admode, path->st_valid ? &path->st : NULL);
}
setvoltime(obj, vol );
}