다음을 통해 공유


3.3.5.9 Receiving an SMB_COM_DELETE Request

Upon receipt of an SMB_COM_DELETE Request (section 2.2.4.7.1), the server MUST attempt to delete all files that match both the FileName and SearchAttributes fields from the request. The final component of the FileName field can contain wildcard characters, allowing multiple files to be deleted.

The precise effect of the SMB_COM_DELETE command is server implementation-dependent. The following criteria SHOULD be observed:

  • If Server.Connection.OpLockSupport is TRUE, and another client has been granted a batch OpLock on the file, then the server MUST send an OpLock break notification request via SMB_COM_LOCKING_ANDX Request (section 2.2.4.32.1) to the client that owns the batch OpLock, as specified in section 3.3.4.2. The server MUST have the OPLOCK_RELEASE flag set on the TypeOfLock. The server MUST set the NewOpLockLevel field to 0x00. The SMB_COM_DELETE command request being processed MUST block until the OpLock is either acknowledged by the client or the OpLock Break Acknowledgement Timer has expired.<253>

  • The user initiating the request MUST have write permission in the target file's parent directory for the operation to succeed.

If a wildcard pathname matches more than one file, the server SHOULD search for and delete all files matching the search criteria. The server SHOULD delete matching files sequentially and, if an error occurs, immediately return an error response with the Status field set to indicate the error. In this case, some files that match the search criteria and can be deleted will not be deleted.<254>

The SearchAttributes field specifies the types of files that are to be deleted:

  • If SearchAttributes is 0x0000 (SMB_FILE_ATTRIBUTE_NORMAL), the server MUST match only normal files.

  • If the SMB_FILE_ATTRIBUTE_HIDDEN or SMB_FILE_ATTRIBUTE_SYSTEM are specified, the delete operation MUST include the type or types specified in addition to normal files.

  • Read-only files MUST NOT be deleted.

  • All other search attributes are ignored by the server.

    • This command cannot delete directories or volumes.

    • The archive bit is not considered when selecting files.

The following conditions MUST generate an error response (see the error code list in section 2.2.4.7.2 for additional error conditions):

  • Within the share indicated by the TID, no files are found that match both the SearchAttributes and the pathname specified by FileName (STATUS_NO_SUCH_FILE (ERRDOS/ERRbadfile)).

  • The TID is invalid (STATUS_SMB_BAD_TID (ERRSRV/ERRinvtid)).

  • The user represented by the UID does not have permission to delete any of the selected files (STATUS_ACCESS_DENIED (ERRDOS/ERRnoaccess)) and the server MUST increase Server.Statistics.sts0_permerrors by 1.

  • The pathname specified by FileName is an invalid path (STATUS_OBJECT_PATH_SYNTAX_BAD (ERRDOS/ERRbadpath)).

Another process has the file open in a sharing mode that does not permit the file to be deleted.<255>

If any of the above conditions is true, or any other error is generated that prevents completion of the operation, the server MUST return an error response message to the client. Otherwise, the server MUST format an SMB_COM_DELETE response message as defined in section 2.2.4.7 and MUST set SMB_Header.Status to indicate success.<256>

The response MUST be sent to the client as described in section 3.3.4.1.