This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "vfs_posix.h"
+#include "system/dir.h"
/*
unlink a stream
*/
-static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs, struct pvfs_filename *name,
+static NTSTATUS pvfs_unlink_stream(struct pvfs_state *pvfs,
+ struct ntvfs_request *req,
+ struct pvfs_filename *name,
uint16_t attrib)
{
NTSTATUS status;
+ struct odb_lock *lck;
if (!name->stream_exists) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
return status;
}
- status = pvfs_can_delete(pvfs, name);
+ status = pvfs_can_delete(pvfs, req, name, &lck);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
/*
unlink one file
*/
-static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
+static NTSTATUS pvfs_unlink_one(struct pvfs_state *pvfs,
+ struct ntvfs_request *req,
const char *unix_path,
const char *fname, uint32_t attrib)
{
struct pvfs_filename *name;
NTSTATUS status;
+ struct odb_lock *lck;
/* get a pvfs_filename object */
- status = pvfs_resolve_partial(pvfs, mem_ctx,
+ status = pvfs_resolve_partial(pvfs, req,
unix_path, fname, &name);
if (!NT_STATUS_IS_OK(status)) {
return status;
return status;
}
- status = pvfs_can_delete(pvfs, name);
+ status = pvfs_can_delete(pvfs, req, name, &lck);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(name);
return status;
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
- status = pvfs_xattr_unlink_hook(pvfs, name->full_name);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ if (name->st.st_nlink == 1) {
+ status = pvfs_xattr_unlink_hook(pvfs, name->full_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
}
/* finally try the actual unlink */
status = pvfs_map_errno(pvfs, errno);
}
+ if (NT_STATUS_IS_OK(status)) {
+ notify_trigger(pvfs->notify_context,
+ NOTIFY_ACTION_REMOVED,
+ FILE_NOTIFY_CHANGE_FILE_NAME,
+ name->full_name);
+ }
+
talloc_free(name);
return status;
The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
*/
NTSTATUS pvfs_unlink(struct ntvfs_module_context *ntvfs,
- struct smbsrv_request *req, struct smb_unlink *unl)
+ struct ntvfs_request *req,
+ union smb_unlink *unl)
{
struct pvfs_state *pvfs = ntvfs->private_data;
struct pvfs_dir *dir;
uint32_t total_deleted=0;
struct pvfs_filename *name;
const char *fname;
- uint_t ofs;
+ off_t ofs;
/* resolve the cifs name to a posix name */
- status = pvfs_resolve_name(pvfs, req, unl->in.pattern,
+ status = pvfs_resolve_name(pvfs, req, unl->unlink.in.pattern,
PVFS_RESOLVE_WILDCARD | PVFS_RESOLVE_STREAMS, &name);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
if (name->stream_name) {
- return pvfs_unlink_stream(pvfs, name, unl->in.attrib);
+ return pvfs_unlink_stream(pvfs, req, name, unl->unlink.in.attrib);
}
/* get list of matching files */
while ((fname = pvfs_list_next(dir, &ofs))) {
/* this seems to be a special case */
- if ((unl->in.attrib & FILE_ATTRIBUTE_DIRECTORY) &&
- (strcmp(fname, ".") == 0 ||
- strcmp(fname, "..") == 0)) {
+ if ((unl->unlink.in.attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+ (ISDOT(fname) || ISDOTDOT(fname))) {
return NT_STATUS_OBJECT_NAME_INVALID;
}
- status = pvfs_unlink_one(pvfs, req, pvfs_list_unix_path(dir), fname, unl->in.attrib);
+ status = pvfs_unlink_one(pvfs, req, pvfs_list_unix_path(dir), fname, unl->unlink.in.attrib);
if (NT_STATUS_IS_OK(status)) {
total_deleted++;
}