@@ -1273,104 +1273,124 @@ SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
1273
1273
}
1274
1274
1275
1275
int
1276
- CIFSSMBOpen (const unsigned int xid , struct cifs_tcon * tcon ,
1277
- const char * fileName , const int openDisposition ,
1278
- const int access_flags , const int create_options , __u16 * netfid ,
1279
- int * pOplock , FILE_ALL_INFO * pfile_info ,
1280
- const struct nls_table * nls_codepage , int remap )
1276
+ CIFS_open (const unsigned int xid , struct cifs_open_parms * oparms , int * oplock ,
1277
+ FILE_ALL_INFO * buf )
1281
1278
{
1282
1279
int rc = - EACCES ;
1283
- OPEN_REQ * pSMB = NULL ;
1284
- OPEN_RSP * pSMBr = NULL ;
1280
+ OPEN_REQ * req = NULL ;
1281
+ OPEN_RSP * rsp = NULL ;
1285
1282
int bytes_returned ;
1286
1283
int name_len ;
1287
1284
__u16 count ;
1285
+ struct cifs_sb_info * cifs_sb = oparms -> cifs_sb ;
1286
+ struct cifs_tcon * tcon = oparms -> tcon ;
1287
+ int remap = cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR ;
1288
+ const struct nls_table * nls = cifs_sb -> local_nls ;
1289
+ int create_options = oparms -> create_options ;
1290
+ int desired_access = oparms -> desired_access ;
1291
+ int disposition = oparms -> disposition ;
1292
+ const char * path = oparms -> path ;
1288
1293
1289
1294
openRetry :
1290
- rc = smb_init (SMB_COM_NT_CREATE_ANDX , 24 , tcon , (void * * ) & pSMB ,
1291
- (void * * ) & pSMBr );
1295
+ rc = smb_init (SMB_COM_NT_CREATE_ANDX , 24 , tcon , (void * * )& req ,
1296
+ (void * * )& rsp );
1292
1297
if (rc )
1293
1298
return rc ;
1294
1299
1295
- pSMB -> AndXCommand = 0xFF ; /* none */
1300
+ /* no commands go after this */
1301
+ req -> AndXCommand = 0xFF ;
1296
1302
1297
- if (pSMB -> hdr .Flags2 & SMBFLG2_UNICODE ) {
1298
- count = 1 ; /* account for one byte pad to word boundary */
1299
- name_len =
1300
- cifsConvertToUTF16 ((__le16 * ) (pSMB -> fileName + 1 ),
1301
- fileName , PATH_MAX , nls_codepage , remap );
1302
- name_len ++ ; /* trailing null */
1303
+ if (req -> hdr .Flags2 & SMBFLG2_UNICODE ) {
1304
+ /* account for one byte pad to word boundary */
1305
+ count = 1 ;
1306
+ name_len = cifsConvertToUTF16 ((__le16 * )(req -> fileName + 1 ),
1307
+ path , PATH_MAX , nls , remap );
1308
+ /* trailing null */
1309
+ name_len ++ ;
1303
1310
name_len *= 2 ;
1304
- pSMB -> NameLength = cpu_to_le16 (name_len );
1305
- } else { /* BB improve check for buffer overruns BB */
1306
- count = 0 ; /* no pad */
1307
- name_len = strnlen (fileName , PATH_MAX );
1308
- name_len ++ ; /* trailing null */
1309
- pSMB -> NameLength = cpu_to_le16 (name_len );
1310
- strncpy (pSMB -> fileName , fileName , name_len );
1311
+ req -> NameLength = cpu_to_le16 (name_len );
1312
+ } else {
1313
+ /* BB improve check for buffer overruns BB */
1314
+ /* no pad */
1315
+ count = 0 ;
1316
+ name_len = strnlen (path , PATH_MAX );
1317
+ /* trailing null */
1318
+ name_len ++ ;
1319
+ req -> NameLength = cpu_to_le16 (name_len );
1320
+ strncpy (req -> fileName , path , name_len );
1311
1321
}
1312
- if (* pOplock & REQ_OPLOCK )
1313
- pSMB -> OpenFlags = cpu_to_le32 (REQ_OPLOCK );
1314
- else if (* pOplock & REQ_BATCHOPLOCK )
1315
- pSMB -> OpenFlags = cpu_to_le32 (REQ_BATCHOPLOCK );
1316
- pSMB -> DesiredAccess = cpu_to_le32 (access_flags );
1317
- pSMB -> AllocationSize = 0 ;
1318
- /* set file as system file if special file such
1319
- as fifo and server expecting SFU style and
1320
- no Unix extensions */
1322
+
1323
+ if (* oplock & REQ_OPLOCK )
1324
+ req -> OpenFlags = cpu_to_le32 (REQ_OPLOCK );
1325
+ else if (* oplock & REQ_BATCHOPLOCK )
1326
+ req -> OpenFlags = cpu_to_le32 (REQ_BATCHOPLOCK );
1327
+
1328
+ req -> DesiredAccess = cpu_to_le32 (desired_access );
1329
+ req -> AllocationSize = 0 ;
1330
+
1331
+ /*
1332
+ * Set file as system file if special file such as fifo and server
1333
+ * expecting SFU style and no Unix extensions.
1334
+ */
1321
1335
if (create_options & CREATE_OPTION_SPECIAL )
1322
- pSMB -> FileAttributes = cpu_to_le32 (ATTR_SYSTEM );
1336
+ req -> FileAttributes = cpu_to_le32 (ATTR_SYSTEM );
1323
1337
else
1324
- pSMB -> FileAttributes = cpu_to_le32 (ATTR_NORMAL );
1338
+ req -> FileAttributes = cpu_to_le32 (ATTR_NORMAL );
1325
1339
1326
- /* XP does not handle ATTR_POSIX_SEMANTICS */
1327
- /* but it helps speed up case sensitive checks for other
1328
- servers such as Samba */
1340
+ /*
1341
+ * XP does not handle ATTR_POSIX_SEMANTICS but it helps speed up case
1342
+ * sensitive checks for other servers such as Samba.
1343
+ */
1329
1344
if (tcon -> ses -> capabilities & CAP_UNIX )
1330
- pSMB -> FileAttributes |= cpu_to_le32 (ATTR_POSIX_SEMANTICS );
1345
+ req -> FileAttributes |= cpu_to_le32 (ATTR_POSIX_SEMANTICS );
1331
1346
1332
1347
if (create_options & CREATE_OPTION_READONLY )
1333
- pSMB -> FileAttributes |= cpu_to_le32 (ATTR_READONLY );
1348
+ req -> FileAttributes |= cpu_to_le32 (ATTR_READONLY );
1349
+
1350
+ req -> ShareAccess = cpu_to_le32 (FILE_SHARE_ALL );
1351
+ req -> CreateDisposition = cpu_to_le32 (disposition );
1352
+ req -> CreateOptions = cpu_to_le32 (create_options & CREATE_OPTIONS_MASK );
1334
1353
1335
- pSMB -> ShareAccess = cpu_to_le32 (FILE_SHARE_ALL );
1336
- pSMB -> CreateDisposition = cpu_to_le32 (openDisposition );
1337
- pSMB -> CreateOptions = cpu_to_le32 (create_options & CREATE_OPTIONS_MASK );
1338
1354
/* BB Expirement with various impersonation levels and verify */
1339
- pSMB -> ImpersonationLevel = cpu_to_le32 (SECURITY_IMPERSONATION );
1340
- pSMB -> SecurityFlags =
1341
- SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY ;
1355
+ req -> ImpersonationLevel = cpu_to_le32 (SECURITY_IMPERSONATION );
1356
+ req -> SecurityFlags = SECURITY_CONTEXT_TRACKING |SECURITY_EFFECTIVE_ONLY ;
1342
1357
1343
1358
count += name_len ;
1344
- inc_rfc1001_len (pSMB , count );
1359
+ inc_rfc1001_len (req , count );
1345
1360
1346
- pSMB -> ByteCount = cpu_to_le16 (count );
1347
- /* long_op set to 1 to allow for oplock break timeouts */
1348
- rc = SendReceive (xid , tcon -> ses , (struct smb_hdr * ) pSMB ,
1349
- (struct smb_hdr * )pSMBr , & bytes_returned , 0 );
1361
+ req -> ByteCount = cpu_to_le16 (count );
1362
+ rc = SendReceive (xid , tcon -> ses , (struct smb_hdr * )req ,
1363
+ (struct smb_hdr * )rsp , & bytes_returned , 0 );
1350
1364
cifs_stats_inc (& tcon -> stats .cifs_stats .num_opens );
1351
1365
if (rc ) {
1352
1366
cifs_dbg (FYI , "Error in Open = %d\n" , rc );
1353
- } else {
1354
- * pOplock = pSMBr -> OplockLevel ; /* 1 byte no need to le_to_cpu */
1355
- * netfid = pSMBr -> Fid ; /* cifs fid stays in le */
1356
- /* Let caller know file was created so we can set the mode. */
1357
- /* Do we care about the CreateAction in any other cases? */
1358
- if (cpu_to_le32 (FILE_CREATE ) == pSMBr -> CreateAction )
1359
- * pOplock |= CIFS_CREATE_ACTION ;
1360
- if (pfile_info ) {
1361
- memcpy ((char * )pfile_info , (char * )& pSMBr -> CreationTime ,
1362
- 36 /* CreationTime to Attributes */ );
1363
- /* the file_info buf is endian converted by caller */
1364
- pfile_info -> AllocationSize = pSMBr -> AllocationSize ;
1365
- pfile_info -> EndOfFile = pSMBr -> EndOfFile ;
1366
- pfile_info -> NumberOfLinks = cpu_to_le32 (1 );
1367
- pfile_info -> DeletePending = 0 ;
1368
- }
1367
+ cifs_buf_release (req );
1368
+ if (rc == - EAGAIN )
1369
+ goto openRetry ;
1370
+ return rc ;
1369
1371
}
1370
1372
1371
- cifs_buf_release (pSMB );
1372
- if (rc == - EAGAIN )
1373
- goto openRetry ;
1373
+ /* 1 byte no need to le_to_cpu */
1374
+ * oplock = rsp -> OplockLevel ;
1375
+ /* cifs fid stays in le */
1376
+ oparms -> fid -> netfid = rsp -> Fid ;
1377
+
1378
+ /* Let caller know file was created so we can set the mode. */
1379
+ /* Do we care about the CreateAction in any other cases? */
1380
+ if (cpu_to_le32 (FILE_CREATE ) == rsp -> CreateAction )
1381
+ * oplock |= CIFS_CREATE_ACTION ;
1382
+
1383
+ if (buf ) {
1384
+ /* copy from CreationTime to Attributes */
1385
+ memcpy ((char * )buf , (char * )& rsp -> CreationTime , 36 );
1386
+ /* the file_info buf is endian converted by caller */
1387
+ buf -> AllocationSize = rsp -> AllocationSize ;
1388
+ buf -> EndOfFile = rsp -> EndOfFile ;
1389
+ buf -> NumberOfLinks = cpu_to_le32 (1 );
1390
+ buf -> DeletePending = 0 ;
1391
+ }
1392
+
1393
+ cifs_buf_release (req );
1374
1394
return rc ;
1375
1395
}
1376
1396
0 commit comments