@@ -1958,15 +1958,16 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
19581958
19591959/* Return -EBADF if no handle is found and general rc otherwise */
19601960int
1961- cifs_get_writable_file (struct cifsInodeInfo * cifs_inode , bool fsuid_only ,
1961+ cifs_get_writable_file (struct cifsInodeInfo * cifs_inode , int flags ,
19621962 struct cifsFileInfo * * ret_file )
19631963{
19641964 struct cifsFileInfo * open_file , * inv_file = NULL ;
19651965 struct cifs_sb_info * cifs_sb ;
19661966 bool any_available = false;
19671967 int rc = - EBADF ;
19681968 unsigned int refind = 0 ;
1969-
1969+ bool fsuid_only = flags & FIND_WR_FSUID_ONLY ;
1970+ bool with_delete = flags & FIND_WR_WITH_DELETE ;
19701971 * ret_file = NULL ;
19711972
19721973 /*
@@ -1998,6 +1999,8 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only,
19981999 continue ;
19992000 if (fsuid_only && !uid_eq (open_file -> uid , current_fsuid ()))
20002001 continue ;
2002+ if (with_delete && !(open_file -> fid .access & DELETE ))
2003+ continue ;
20012004 if (OPEN_FMODE (open_file -> f_flags ) & FMODE_WRITE ) {
20022005 if (!open_file -> invalidHandle ) {
20032006 /* found a good writable file */
@@ -2045,12 +2048,12 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only,
20452048}
20462049
20472050struct cifsFileInfo *
2048- find_writable_file (struct cifsInodeInfo * cifs_inode , bool fsuid_only )
2051+ find_writable_file (struct cifsInodeInfo * cifs_inode , int flags )
20492052{
20502053 struct cifsFileInfo * cfile ;
20512054 int rc ;
20522055
2053- rc = cifs_get_writable_file (cifs_inode , fsuid_only , & cfile );
2056+ rc = cifs_get_writable_file (cifs_inode , flags , & cfile );
20542057 if (rc )
20552058 cifs_dbg (FYI , "couldn't find writable handle rc=%d" , rc );
20562059
@@ -2059,6 +2062,7 @@ find_writable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only)
20592062
20602063int
20612064cifs_get_writable_path (struct cifs_tcon * tcon , const char * name ,
2065+ int flags ,
20622066 struct cifsFileInfo * * ret_file )
20632067{
20642068 struct list_head * tmp ;
@@ -2085,7 +2089,7 @@ cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
20852089 kfree (full_path );
20862090 cinode = CIFS_I (d_inode (cfile -> dentry ));
20872091 spin_unlock (& tcon -> open_file_lock );
2088- return cifs_get_writable_file (cinode , 0 , ret_file );
2092+ return cifs_get_writable_file (cinode , flags , ret_file );
20892093 }
20902094
20912095 spin_unlock (& tcon -> open_file_lock );
@@ -2162,7 +2166,8 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
21622166 if (mapping -> host -> i_size - offset < (loff_t )to )
21632167 to = (unsigned )(mapping -> host -> i_size - offset );
21642168
2165- rc = cifs_get_writable_file (CIFS_I (mapping -> host ), false, & open_file );
2169+ rc = cifs_get_writable_file (CIFS_I (mapping -> host ), FIND_WR_ANY ,
2170+ & open_file );
21662171 if (!rc ) {
21672172 bytes_written = cifs_write (open_file , open_file -> pid ,
21682173 write_data , to - from , & offset );
@@ -2355,7 +2360,7 @@ static int cifs_writepages(struct address_space *mapping,
23552360 if (cfile )
23562361 cifsFileInfo_put (cfile );
23572362
2358- rc = cifs_get_writable_file (CIFS_I (inode ), false , & cfile );
2363+ rc = cifs_get_writable_file (CIFS_I (inode ), FIND_WR_ANY , & cfile );
23592364
23602365 /* in case of an error store it to return later */
23612366 if (rc )
0 commit comments