From 87542e1310cfa90e5af0b00d77def969c7b38aef Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 11 May 2012 13:31:36 +0200 Subject: s3: Make SMB_QUERY_FILE_UNIX_BASIC's devno work for files According to susv3, st_rdev is valid exactly for char and block devices. Normal files have st_dev set. --- source3/smbd/trans2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 5cfbc3128b..590ee5bf7c 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -3959,6 +3959,7 @@ static char *store_file_unix_basic(connection_struct *conn, const SMB_STRUCT_STAT *psbuf) { uint64_t file_index = get_FileIndex(conn, psbuf); + dev_t devno; DEBUG(10,("store_file_unix_basic: SMB_QUERY_FILE_UNIX_BASIC\n")); DEBUG(4,("store_file_unix_basic: st_mode=%o\n",(int)psbuf->st_ex_mode)); @@ -3985,11 +3986,17 @@ static char *store_file_unix_basic(connection_struct *conn, SIVAL(pdata,0,unix_filetype(psbuf->st_ex_mode)); pdata += 4; - SIVAL(pdata,0,unix_dev_major(psbuf->st_ex_rdev)); /* Major device number if type is device */ + if (S_ISBLK(psbuf->st_ex_mode) || S_ISCHR(psbuf->st_ex_mode)) { + devno = psbuf->st_ex_rdev; + } else { + devno = psbuf->st_ex_dev; + } + + SIVAL(pdata,0,unix_dev_major(devno)); /* Major device number if type is device */ SIVAL(pdata,4,0); pdata += 8; - SIVAL(pdata,0,unix_dev_minor(psbuf->st_ex_rdev)); /* Minor device number if type is device */ + SIVAL(pdata,0,unix_dev_minor(devno)); /* Minor device number if type is device */ SIVAL(pdata,4,0); pdata += 8; -- cgit