@@ -444,6 +444,14 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
444
444
return rpc_run_task (& task_setup_data );
445
445
}
446
446
447
+ #define SILLYNAME_PREFIX ".nfs"
448
+ #define SILLYNAME_PREFIX_LEN ((unsigned)sizeof(SILLYNAME_PREFIX) - 1)
449
+ #define SILLYNAME_FILEID_LEN ((unsigned)sizeof(u64) << 1)
450
+ #define SILLYNAME_COUNTER_LEN ((unsigned)sizeof(unsigned int) << 1)
451
+ #define SILLYNAME_LEN (SILLYNAME_PREFIX_LEN + \
452
+ SILLYNAME_FILEID_LEN + \
453
+ SILLYNAME_COUNTER_LEN)
454
+
447
455
/**
448
456
* nfs_sillyrename - Perform a silly-rename of a dentry
449
457
* @dir: inode of directory that contains dentry
469
477
nfs_sillyrename (struct inode * dir , struct dentry * dentry )
470
478
{
471
479
static unsigned int sillycounter ;
472
- const int fileidsize = sizeof (NFS_FILEID (dentry -> d_inode ))* 2 ;
473
- const int countersize = sizeof (sillycounter )* 2 ;
474
- const int slen = sizeof (".nfs" )+ fileidsize + countersize - 1 ;
475
- char silly [slen + 1 ];
480
+ unsigned char silly [SILLYNAME_LEN + 1 ];
481
+ unsigned long long fileid ;
476
482
struct dentry * sdentry ;
477
483
struct rpc_task * task ;
478
484
int error = - EIO ;
@@ -489,20 +495,20 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
489
495
if (dentry -> d_flags & DCACHE_NFSFS_RENAMED )
490
496
goto out ;
491
497
492
- sprintf (silly , ".nfs%*.*Lx" ,
493
- fileidsize , fileidsize ,
494
- (unsigned long long )NFS_FILEID (dentry -> d_inode ));
498
+ fileid = NFS_FILEID (dentry -> d_inode );
495
499
496
500
/* Return delegation in anticipation of the rename */
497
501
NFS_PROTO (dentry -> d_inode )-> return_delegation (dentry -> d_inode );
498
502
499
503
sdentry = NULL ;
500
504
do {
501
- char * suffix = silly + slen - countersize ;
502
-
505
+ int slen ;
503
506
dput (sdentry );
504
507
sillycounter ++ ;
505
- sprintf (suffix , "%*.*x" , countersize , countersize , sillycounter );
508
+ slen = scnprintf (silly , sizeof (silly ),
509
+ SILLYNAME_PREFIX "%0*llx%0*x" ,
510
+ SILLYNAME_FILEID_LEN , fileid ,
511
+ SILLYNAME_COUNTER_LEN , sillycounter );
506
512
507
513
dfprintk (VFS , "NFS: trying to rename %s to %s\n" ,
508
514
dentry -> d_name .name , silly );
0 commit comments