+ break;
+ }
+ /* fallthrough */
+ default :
+ err = AFPERR_BITMAP;
+ /* break while loop */
+ bitmap = 0;
+ break;
+ }
+
+ bitmap = bitmap>>1;
+ bit++;
+ }
+
+ /* second try with adouble open
+ */
+ if ( ad_open_metadata( upath, vol_noadouble(vol), O_CREAT, adp) < 0) {
+ LOG(log_debug, logtype_afpd, "setfilparams: ad_open_metadata error");
+ /*
+ * For some things, we don't need an adouble header:
+ * - change of modification date
+ * - UNIX privs (Bug-ID #2863424)
+ */
+ if ( (f_bitmap & ~(1<<FILPBIT_MDATE | 1<<FILPBIT_UNIXPR))) {
+ LOG(log_debug, logtype_afpd, "setfilparams: need adouble access");
+ return vol_noadouble(vol) ? AFP_OK : AFPERR_ACCESS;
+ }
+ LOG(log_debug, logtype_afpd, "setfilparams: no adouble perms, but only FILPBIT_MDATE and/or FILPBIT_UNIXPR");
+ isad = 0;
+ } else if ((ad_get_HF_flags( adp ) & O_CREAT) ) {
+ ad_setname(adp, path->m_name);
+ }
+
+ bit = 0;
+ bitmap = f_bitmap;
+ while ( bitmap != 0 ) {
+ while (( bitmap & 1 ) == 0 ) {
+ bitmap = bitmap>>1;
+ bit++;
+ }
+
+ switch( bit ) {
+ case FILPBIT_ATTR :
+ ad_getattr(adp, &bshort);
+ if ((bshort & htons(ATTRBIT_INVISIBLE)) !=
+ (ashort & htons(ATTRBIT_INVISIBLE) & htons(ATTRBIT_SETCLR)) )
+ change_parent_mdate = 1;
+ if ( ntohs( ashort ) & ATTRBIT_SETCLR ) {
+ bshort |= htons( ntohs( ashort ) & ~ATTRBIT_SETCLR );
+ } else {
+ bshort &= ~ashort;
+ }
+ ad_setattr(adp, bshort);
+ break;
+ case FILPBIT_CDATE :
+ ad_setdate(adp, AD_DATE_CREATE, cdate);
+ break;
+ case FILPBIT_MDATE :
+ break;
+ case FILPBIT_BDATE :
+ ad_setdate(adp, AD_DATE_BACKUP, bdate);
+ break;
+ case FILPBIT_FINFO :
+ if (default_type( ad_entry( adp, ADEID_FINDERI ))
+ && (
+ ((em = getextmap( path->m_name )) &&
+ !memcmp(finder_buf, em->em_type, sizeof( em->em_type )) &&
+ !memcmp(finder_buf + 4, em->em_creator,sizeof( em->em_creator)))
+ || ((em = getdefextmap()) &&
+ !memcmp(finder_buf, em->em_type, sizeof( em->em_type )) &&
+ !memcmp(finder_buf + 4, em->em_creator,sizeof( em->em_creator)))
+ )) {
+ memcpy(finder_buf, ufinderi, 8 );
+ }
+ memcpy(ad_entry( adp, ADEID_FINDERI ), finder_buf, 32 );
+ break;
+ case FILPBIT_UNIXPR :
+ if (upriv_bit) {
+ setfilunixmode(vol, path, upriv);
+ }
+ break;
+ case FILPBIT_PDINFO :
+ if (afp_version < 30) { /* else it's UTF8 name */