/* delete a file - the dirtype specifies the file types to include in the search. The name can contain CIFS wildcards, but rarely does (except with OS/2 clients) */ static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_unlink *unl) { struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; /* see if the front end will allow us to perform this function asynchronously. */ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { return smb_raw_unlink(p->tree, unl); } c_req = smb_raw_unlink_send(p->tree, unl); SIMPLE_ASYNC_TAIL; }
bool nb_unlink(const char *fname, int attr, NTSTATUS status, bool retry) { union smb_unlink io; NTSTATUS ret; io.unlink.in.pattern = fname; io.unlink.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN; if (strchr(fname, '*') == 0) { io.unlink.in.attrib |= FILE_ATTRIBUTE_DIRECTORY; } ret = smb_raw_unlink(c->tree, &io); if (!retry) return check_status("Unlink", status, ret); return true; }
static bool test_osxrename(struct torture_context *tctx, struct smbcli_state *cli) { union smb_rename io; union smb_unlink io_un; NTSTATUS status; bool ret = true; int fnum = -1; const char *fname1 = BASEDIR "\\test1"; const char *FNAME1 = BASEDIR "\\TEST1"; union smb_fileinfo finfo; union smb_open op; torture_comment(tctx, "\nTesting OSX Rename\n"); if (!torture_setup_dir(cli, BASEDIR)) { return false; } op.generic.level = RAW_OPEN_NTCREATEX; op.ntcreatex.in.root_fid.fnum = 0; op.ntcreatex.in.flags = 0; op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; op.ntcreatex.in.create_options = 0; op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; op.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; op.ntcreatex.in.alloc_size = 0; op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = fname1; status = smb_raw_open(cli->tree, tctx, &op); CHECK_STATUS(status, NT_STATUS_OK); fnum = op.ntcreatex.out.file.fnum; io.generic.level = RAW_RENAME_RENAME; io.rename.in.attrib = 0; smbcli_close(cli->tree, fnum); /* Rename by changing case. First check for the * existence of the file with the "newname". * If we find one and both the output and input are same case, * delete it. */ torture_comment(tctx, "Checking os X rename (case changing)\n"); finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.all_info.in.file.path = FNAME1; torture_comment(tctx, "Looking for file %s \n",FNAME1); status = smb_raw_pathinfo(cli->tree, tctx, &finfo); if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) { torture_comment(tctx, "Name of the file found %s \n", finfo.all_info.out.fname.s); if (strcmp(finfo.all_info.out.fname.s, finfo.all_info.in.file.path) == 0) { /* If file is found with the same case delete it */ torture_comment(tctx, "Deleting File %s \n", finfo.all_info.out.fname.s); io_un.unlink.in.pattern = finfo.all_info.out.fname.s; io_un.unlink.in.attrib = 0; status = smb_raw_unlink(cli->tree, &io_un); CHECK_STATUS(status, NT_STATUS_OK); } } io.rename.in.pattern1 = fname1; io.rename.in.pattern2 = FNAME1; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.all_info.in.file.path = fname1; status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); torture_comment(tctx, "File name after rename %s \n",finfo.all_info.out.fname.s); done: smbcli_close(cli->tree, fnum); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); return ret; }