@@ -3220,31 +3220,26 @@ static const char *open_last_lookups(struct nameidata *nd,
3220
3220
/*
3221
3221
* Handle the last step of open()
3222
3222
*/
3223
- static const char * do_last (struct nameidata * nd ,
3223
+ static int do_open (struct nameidata * nd ,
3224
3224
struct file * file , const struct open_flags * op )
3225
3225
{
3226
3226
int open_flag = op -> open_flag ;
3227
3227
bool do_truncate ;
3228
3228
int acc_mode ;
3229
- const char * link ;
3230
3229
int error ;
3231
3230
3232
- link = open_last_lookups (nd , file , op );
3233
- if (unlikely (link ))
3234
- return link ;
3235
-
3236
3231
if (!(file -> f_mode & FMODE_CREATED ))
3237
3232
audit_inode (nd -> name , nd -> path .dentry , 0 );
3238
3233
if (open_flag & O_CREAT ) {
3239
3234
if (d_is_dir (nd -> path .dentry ))
3240
- return ERR_PTR ( - EISDIR ) ;
3235
+ return - EISDIR ;
3241
3236
error = may_create_in_sticky (nd -> dir_mode , nd -> dir_uid ,
3242
3237
d_backing_inode (nd -> path .dentry ));
3243
3238
if (unlikely (error ))
3244
- return ERR_PTR ( error ) ;
3239
+ return error ;
3245
3240
}
3246
3241
if ((nd -> flags & LOOKUP_DIRECTORY ) && !d_can_lookup (nd -> path .dentry ))
3247
- return ERR_PTR ( - ENOTDIR ) ;
3242
+ return - ENOTDIR ;
3248
3243
3249
3244
do_truncate = false;
3250
3245
acc_mode = op -> acc_mode ;
@@ -3255,7 +3250,7 @@ static const char *do_last(struct nameidata *nd,
3255
3250
} else if (d_is_reg (nd -> path .dentry ) && open_flag & O_TRUNC ) {
3256
3251
error = mnt_want_write (nd -> path .mnt );
3257
3252
if (error )
3258
- return ERR_PTR ( error ) ;
3253
+ return error ;
3259
3254
do_truncate = true;
3260
3255
}
3261
3256
error = may_open (& nd -> path , acc_mode , open_flag );
@@ -3271,7 +3266,7 @@ static const char *do_last(struct nameidata *nd,
3271
3266
}
3272
3267
if (do_truncate )
3273
3268
mnt_drop_write (nd -> path .mnt );
3274
- return ERR_PTR ( error ) ;
3269
+ return error ;
3275
3270
}
3276
3271
3277
3272
struct dentry * vfs_tmpfile (struct dentry * dentry , umode_t mode , int open_flag )
@@ -3374,8 +3369,10 @@ static struct file *path_openat(struct nameidata *nd,
3374
3369
} else {
3375
3370
const char * s = path_init (nd , flags );
3376
3371
while (!(error = link_path_walk (s , nd )) &&
3377
- (s = do_last (nd , file , op )) != NULL )
3372
+ (s = open_last_lookups (nd , file , op )) != NULL )
3378
3373
;
3374
+ if (!error )
3375
+ error = do_open (nd , file , op );
3379
3376
terminate_walk (nd );
3380
3377
}
3381
3378
if (likely (!error )) {
0 commit comments