@@ -492,13 +492,13 @@ static int apaRemove(s32 device, const char *id, const char *fpwd)
492492}
493493
494494// Unofficial helper for renaming APA partitions.
495- static int apaRename (s32 device , const apa_params_t * oldParams , const apa_params_t * newParams )
495+ static int apaRename (s32 device , const char * oldId , const char * newId )
496496{
497497 apa_cache_t * clink ;
498498 int i , rv ;
499499
500500 // look to see if can make(newname) or not...
501- if ((clink = apaFindPartition (device , newParams -> id , & rv )) != NULL ) {
501+ if ((clink = apaFindPartition (device , newId , & rv )) != NULL ) {
502502 apaCacheFree (clink );
503503 SignalSema (fioSema );
504504 return - EEXIST ; // File exists
@@ -507,35 +507,31 @@ static int apaRename(s32 device, const apa_params_t *oldParams, const apa_params
507507 // look to see if open(oldname)
508508 for (i = 0 ; i < apaMaxOpen ; i ++ ) {
509509 if (hddFileSlots [i ].f != NULL ) {
510- if (memcmp (hddFileSlots [i ].id , oldParams -> id , APA_IDMAX ) == 0 ) {
510+ if (memcmp (hddFileSlots [i ].id , oldId , APA_IDMAX ) == 0 ) {
511511 SignalSema (fioSema );
512512 return - EBUSY ;
513513 }
514514 }
515515 }
516516
517517 // Do not allow system partitions (__*) to be renamed.
518- if (oldParams -> id [0 ] == '_' && oldParams -> id [1 ] == '_' )
518+ #ifndef APA_ALLOW_REMOVE_PARTITION_WITH_LEADING_UNDERSCORE
519+ if (oldId [0 ] == '_' && oldId [1 ] == '_' )
519520 return - EACCES ;
521+ #endif
520522
521523 // find :)
522- if ((clink = apaFindPartition (device , oldParams -> id , & rv )) == NULL ) {
524+ if ((clink = apaFindPartition (device , oldId , & rv )) == NULL ) {
523525 SignalSema (fioSema );
524526 return rv ;
525527 }
526528
527- // Check for access rights.
528- if (apaPassCmp (clink -> header -> fpwd , oldParams -> fpwd ) != 0 ) {
529- apaCacheFree (clink );
530- return - EACCES ;
531- }
532-
533529 // do the renaming :) note: subs have no names!!
534- memcpy (clink -> header -> id , newParams -> id , APA_IDMAX );
530+ memcpy (clink -> header -> id , newId , APA_IDMAX );
535531
536- // Update passwords
537- memcpy ( clink -> header -> rpwd , newParams -> rpwd , APA_PASSMAX );
538- memcpy ( clink -> header -> fpwd , newParams -> fpwd , APA_PASSMAX );
532+ // touch creation time
533+ apaGetTime ( & clink -> header -> created );
534+ clink -> header -> checksum = apaCheckSum ( clink -> header , 1 );
539535
540536 clink -> flags |= APA_CACHE_FLAG_DIRTY ;
541537
@@ -761,23 +757,13 @@ int hddDread(iomanX_iop_file_t *f, iox_dirent_t *dirent)
761757}
762758
763759/* Originally, SONY provided no function for renaming partitions.
764- Syntax: rename <Old ID>,<fpwd> <New ID>,<fpwd>
765-
766- The full-access password (fpwd) is required.
767- System partitions (__*) cannot be renamed. */
760+ Syntax: rename <Old ID> <New ID>*/
768761int hddReName (iomanX_iop_file_t * f , const char * oldname , const char * newname )
769762{
770- apa_params_t oldParams ;
771- apa_params_t newParams ;
772763 int rv ;
773764
774- if ((rv = fioGetInput (oldname , & oldParams )) < 0 )
775- return rv ;
776- if ((rv = fioGetInput (newname , & newParams )) < 0 )
777- return rv ;
778-
779765 WaitSema (fioSema );
780- rv = apaRename (f -> unit , & oldParams , & newParams );
766+ rv = apaRename (f -> unit , oldname , newname );
781767 SignalSema (fioSema );
782768
783769 return rv ;
0 commit comments