-#ifdef CNID_DB
- if (stat(newpath, &st) < 0) /* this shouldn't fail */
- return AFPERR_MISC;
- cnid_update(vol->v_db, id, &st, curdir->d_did, newpath, strlen(newpath));
-#endif /* CNID_DB */
-
- if ( !odir ) {
- newadpath = obj->newtmp;
- strcpy( newadpath, ad_path( newpath, 0 ));
- if ( rename( ad_path( upath, 0 ), newadpath ) < 0 ) {
- if ( errno == ENOENT ) { /* no adouble header file */
- if (( unlink( newadpath ) < 0 ) && ( errno != ENOENT )) {
- return( AFPERR_PARAM );
- }
- goto out;
- }
- return( AFPERR_PARAM );
- }
-
- memset(&ad, 0, sizeof(ad));
- if ( ad_open( newpath, ADFLAGS_HF, O_RDWR|O_CREAT, 0666,
- &ad) < 0 ) {
- return( AFPERR_PARAM );
- }
- } else {
- int isad = 1;
-
- memset(&ad, 0, sizeof(ad));
- if ( ad_open( newpath, vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
- O_RDWR|O_CREAT, 0666, &ad) < 0 ) {
- if (!((errno == ENOENT) && vol_noadouble(vol)))
- return( AFPERR_PARAM );
- isad = 0;
- }
- if ((buf = realloc( odir->d_name, plen + 1 )) == NULL ) {
- syslog( LOG_ERR, "afp_rename: realloc: %s", strerror(errno) );
- if (isad) {
- ad_flush(&ad, ADFLAGS_HF); /* in case of create */
- ad_close(&ad, ADFLAGS_HF);
- }
- return AFPERR_MISC;
- }
- odir->d_name = buf;
- strcpy( odir->d_name, ibuf );
- if (!isad)
- goto out;