@@ -404,7 +404,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
404404}
405405
406406static int
407- cifs_sfu_type (struct cifs_fattr * fattr , const unsigned char * path ,
407+ cifs_sfu_type (struct cifs_fattr * fattr , const char * path ,
408408 struct cifs_sb_info * cifs_sb , unsigned int xid )
409409{
410410 int rc ;
@@ -416,6 +416,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,
416416 char buf [24 ];
417417 unsigned int bytes_read ;
418418 char * pbuf ;
419+ int buf_type = CIFS_NO_BUFFER ;
419420
420421 pbuf = buf ;
421422
@@ -441,57 +442,59 @@ cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,
441442 cifs_sb -> local_nls ,
442443 cifs_sb -> mnt_cifs_flags &
443444 CIFS_MOUNT_MAP_SPECIAL_CHR );
444- if (rc == 0 ) {
445- int buf_type = CIFS_NO_BUFFER ;
446- /* Read header */
447- io_parms .netfid = netfid ;
448- io_parms .pid = current -> tgid ;
449- io_parms .tcon = tcon ;
450- io_parms .offset = 0 ;
451- io_parms .length = 24 ;
452- rc = CIFSSMBRead (xid , & io_parms , & bytes_read , & pbuf ,
453- & buf_type );
454- if ((rc == 0 ) && (bytes_read >= 8 )) {
455- if (memcmp ("IntxBLK" , pbuf , 8 ) == 0 ) {
456- cifs_dbg (FYI , "Block device\n" );
457- fattr -> cf_mode |= S_IFBLK ;
458- fattr -> cf_dtype = DT_BLK ;
459- if (bytes_read == 24 ) {
460- /* we have enough to decode dev num */
461- __u64 mjr ; /* major */
462- __u64 mnr ; /* minor */
463- mjr = le64_to_cpu (* (__le64 * )(pbuf + 8 ));
464- mnr = le64_to_cpu (* (__le64 * )(pbuf + 16 ));
465- fattr -> cf_rdev = MKDEV (mjr , mnr );
466- }
467- } else if (memcmp ("IntxCHR" , pbuf , 8 ) == 0 ) {
468- cifs_dbg (FYI , "Char device\n" );
469- fattr -> cf_mode |= S_IFCHR ;
470- fattr -> cf_dtype = DT_CHR ;
471- if (bytes_read == 24 ) {
472- /* we have enough to decode dev num */
473- __u64 mjr ; /* major */
474- __u64 mnr ; /* minor */
475- mjr = le64_to_cpu (* (__le64 * )(pbuf + 8 ));
476- mnr = le64_to_cpu (* (__le64 * )(pbuf + 16 ));
477- fattr -> cf_rdev = MKDEV (mjr , mnr );
478- }
479- } else if (memcmp ("IntxLNK" , pbuf , 7 ) == 0 ) {
480- cifs_dbg (FYI , "Symlink\n" );
481- fattr -> cf_mode |= S_IFLNK ;
482- fattr -> cf_dtype = DT_LNK ;
483- } else {
484- fattr -> cf_mode |= S_IFREG ; /* file? */
485- fattr -> cf_dtype = DT_REG ;
486- rc = - EOPNOTSUPP ;
445+ if (rc ) {
446+ cifs_put_tlink (tlink );
447+ return rc ;
448+ }
449+
450+ /* Read header */
451+ io_parms .netfid = netfid ;
452+ io_parms .pid = current -> tgid ;
453+ io_parms .tcon = tcon ;
454+ io_parms .offset = 0 ;
455+ io_parms .length = 24 ;
456+
457+ rc = CIFSSMBRead (xid , & io_parms , & bytes_read , & pbuf , & buf_type );
458+ if ((rc == 0 ) && (bytes_read >= 8 )) {
459+ if (memcmp ("IntxBLK" , pbuf , 8 ) == 0 ) {
460+ cifs_dbg (FYI , "Block device\n" );
461+ fattr -> cf_mode |= S_IFBLK ;
462+ fattr -> cf_dtype = DT_BLK ;
463+ if (bytes_read == 24 ) {
464+ /* we have enough to decode dev num */
465+ __u64 mjr ; /* major */
466+ __u64 mnr ; /* minor */
467+ mjr = le64_to_cpu (* (__le64 * )(pbuf + 8 ));
468+ mnr = le64_to_cpu (* (__le64 * )(pbuf + 16 ));
469+ fattr -> cf_rdev = MKDEV (mjr , mnr );
470+ }
471+ } else if (memcmp ("IntxCHR" , pbuf , 8 ) == 0 ) {
472+ cifs_dbg (FYI , "Char device\n" );
473+ fattr -> cf_mode |= S_IFCHR ;
474+ fattr -> cf_dtype = DT_CHR ;
475+ if (bytes_read == 24 ) {
476+ /* we have enough to decode dev num */
477+ __u64 mjr ; /* major */
478+ __u64 mnr ; /* minor */
479+ mjr = le64_to_cpu (* (__le64 * )(pbuf + 8 ));
480+ mnr = le64_to_cpu (* (__le64 * )(pbuf + 16 ));
481+ fattr -> cf_rdev = MKDEV (mjr , mnr );
487482 }
483+ } else if (memcmp ("IntxLNK" , pbuf , 7 ) == 0 ) {
484+ cifs_dbg (FYI , "Symlink\n" );
485+ fattr -> cf_mode |= S_IFLNK ;
486+ fattr -> cf_dtype = DT_LNK ;
488487 } else {
489- fattr -> cf_mode |= S_IFREG ; /* then it is a file */
488+ fattr -> cf_mode |= S_IFREG ; /* file? */
490489 fattr -> cf_dtype = DT_REG ;
491- rc = - EOPNOTSUPP ; /* or some unknown SFU type */
490+ rc = - EOPNOTSUPP ;
492491 }
493- CIFSSMBClose (xid , tcon , netfid );
492+ } else {
493+ fattr -> cf_mode |= S_IFREG ; /* then it is a file */
494+ fattr -> cf_dtype = DT_REG ;
495+ rc = - EOPNOTSUPP ; /* or some unknown SFU type */
494496 }
497+ CIFSSMBClose (xid , tcon , netfid );
495498 cifs_put_tlink (tlink );
496499 return rc ;
497500}
0 commit comments