- 'T', 'E', 'X', 'T', 'U', 'N', 'I', 'X',
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-int getfilparams(vol, bitmap, path, dir, st, buf, buflen )
- struct vol *vol;
- u_int16_t bitmap;
- char *path;
- struct dir *dir;
- struct stat *st;
- char *buf;
- int *buflen;
+ 'T', 'E', 'X', 'T', 'U', 'N', 'I', 'X',
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ };
+
+int getfilparams(struct vol *vol,
+ u_int16_t bitmap,
+ char *path, struct dir *dir, struct stat *st,
+ char *buf, int *buflen )
- while (( bitmap & 1 ) == 0 ) {
- bitmap = bitmap>>1;
- bit++;
- }
-
- switch ( bit ) {
- case FILPBIT_ATTR :
- if ( isad ) {
- ad_getattr(adp, &ashort);
- } else if (*upath == '.') {
- ashort = htons(ATTRBIT_INVISIBLE);
- } else
- ashort = 0;
- memcpy(data, &ashort, sizeof( ashort ));
- data += sizeof( u_short );
- break;
-
- case FILPBIT_PDID :
- memcpy(data, &dir->d_did, sizeof( u_int32_t ));
- data += sizeof( u_int32_t );
- break;
-
- case FILPBIT_CDATE :
- if (!isad || (ad_getdate(adp, AD_DATE_CREATE, &aint) < 0))
- aint = AD_DATE_FROM_UNIX(st->st_mtime);
- memcpy(data, &aint, sizeof( aint ));
- data += sizeof( aint );
- break;
-
- case FILPBIT_MDATE :
- if ( isad && (ad_getdate(adp, AD_DATE_MODIFY, &aint) == 0)) {
- if ((st->st_mtime > AD_DATE_TO_UNIX(aint)) &&
- (hst.st_mtime < st->st_mtime)) {
- aint = AD_DATE_FROM_UNIX(st->st_mtime);
- }
- } else {
- aint = AD_DATE_FROM_UNIX(st->st_mtime);
- }
- memcpy(data, &aint, sizeof( int ));
- data += sizeof( int );
- break;
-
- case FILPBIT_BDATE :
- if (!isad || (ad_getdate(adp, AD_DATE_BACKUP, &aint) < 0))
- aint = AD_DATE_START;
- memcpy(data, &aint, sizeof( int ));
- data += sizeof( int );
- break;
-
- case FILPBIT_FINFO :
- if (isad)
- memcpy(data, ad_entry(adp, ADEID_FINDERI), 32);
- else {
- memcpy(data, ufinderi, 32);
- if (*upath == '.') { /* make it invisible */
- ashort = htons(FINDERINFO_INVISIBLE);
- memcpy(data + FINDERINFO_FRFLAGOFF, &ashort, sizeof(ashort));
- }
- }
-
- if ((!isad || (memcmp(ad_entry(adp, ADEID_FINDERI),
- ufinderi, 8 ) == 0)) &&
- (em = getextmap( path ))) {
- memcpy(data, em->em_type, sizeof( em->em_type ));
- memcpy(data + 4, em->em_creator, sizeof(em->em_creator));
- }
- data += 32;
- break;
-
- case FILPBIT_LNAME :
- nameoff = data;
- data += sizeof( u_int16_t );
- break;
-
- case FILPBIT_SNAME :
- memset(data, 0, sizeof(u_int16_t));
- data += sizeof( u_int16_t );
- break;
-
- case FILPBIT_FNUM :
- aint = 0;
-#ifdef CNID_DB
- /* find out if we have a fixed did already */
- aint = cnid_lookup(vol->v_db, st, dir->d_did, upath,
- strlen(upath));
-#endif /* CNID_DB */
-
- /* look in AD v2 header */
- if (aint == 0)
- {
+ while (( bitmap & 1 ) == 0 ) {
+ bitmap = bitmap>>1;
+ bit++;
+ }
+
+ switch ( bit ) {
+ case FILPBIT_ATTR :
+ if ( isad ) {
+ ad_getattr(adp, &ashort);
+ } else if (*upath == '.') {
+ ashort = htons(ATTRBIT_INVISIBLE);
+ } else
+ ashort = 0;
+ memcpy(data, &ashort, sizeof( ashort ));
+ data += sizeof( u_short );
+ break;
+
+ case FILPBIT_PDID :
+ memcpy(data, &dir->d_did, sizeof( u_int32_t ));
+ data += sizeof( u_int32_t );
+ break;
+
+ case FILPBIT_CDATE :
+ if (!isad || (ad_getdate(adp, AD_DATE_CREATE, &aint) < 0))
+ aint = AD_DATE_FROM_UNIX(st->st_mtime);
+ memcpy(data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+ break;
+
+ case FILPBIT_MDATE :
+ if ( isad && (ad_getdate(adp, AD_DATE_MODIFY, &aint) == 0)) {
+ if ((st->st_mtime > AD_DATE_TO_UNIX(aint)) &&
+ (hst.st_mtime < st->st_mtime)) {
+ aint = AD_DATE_FROM_UNIX(st->st_mtime);
+ }
+ } else {
+ aint = AD_DATE_FROM_UNIX(st->st_mtime);
+ }
+ memcpy(data, &aint, sizeof( int ));
+ data += sizeof( int );
+ break;
+
+ case FILPBIT_BDATE :
+ if (!isad || (ad_getdate(adp, AD_DATE_BACKUP, &aint) < 0))
+ aint = AD_DATE_START;
+ memcpy(data, &aint, sizeof( int ));
+ data += sizeof( int );
+ break;
+
+ case FILPBIT_FINFO :
+ if (isad)
+ memcpy(data, ad_entry(adp, ADEID_FINDERI), 32);
+ else {
+ memcpy(data, ufinderi, 32);
+ if (*upath == '.') { /* make it invisible */
+ ashort = htons(FINDERINFO_INVISIBLE);
+ memcpy(data + FINDERINFO_FRFLAGOFF, &ashort, sizeof(ashort));
+ }
+ }
+
+ if ((!isad || (memcmp(ad_entry(adp, ADEID_FINDERI),
+ ufinderi, 8 ) == 0)) &&
+ (em = getextmap( path ))) {
+ memcpy(data, em->em_type, sizeof( em->em_type ));
+ memcpy(data + 4, em->em_creator, sizeof(em->em_creator));
+ }
+ data += 32;
+ break;
+
+ case FILPBIT_LNAME :
+ nameoff = data;
+ data += sizeof( u_int16_t );
+ break;
+
+ case FILPBIT_SNAME :
+ memset(data, 0, sizeof(u_int16_t));
+ data += sizeof( u_int16_t );
+ break;
+
+ case FILPBIT_FNUM :
+ aint = 0;
- }
-
- if (aint == 0) {
- /*
- * What a fucking mess. First thing: DID and FNUMs are
- * in the same space for purposes of enumerate (and several
- * other wierd places). While we consider this Apple's bug,
- * this is the work-around: In order to maintain constant and
- * unique DIDs and FNUMs, we monotonically generate the DIDs
- * during the session, and derive the FNUMs from the filesystem.
- * Since the DIDs are small, we insure that the FNUMs are fairly
- * large by setting thier high bits to the device number.
- *
- * AFS already does something very similar to this for the
- * inode number, so we don't repeat the procedure.
- *
- * new algorithm:
- * due to complaints over did's being non-persistent,
- * here's the current hack to provide semi-persistent
- * did's:
- * 1) we reserve the first bit for file ids.
- * 2) the next 7 bits are for the device.
- * 3) the remaining 24 bits are for the inode.
- *
- * both the inode and device information are actually hashes
- * that are then truncated to the requisite bit length.
- *
- * it should be okay to use lstat to deal with symlinks.
- */
+
+ if (aint == 0) {
+ /*
+ * What a fucking mess. First thing: DID and FNUMs are
+ * in the same space for purposes of enumerate (and several
+ * other wierd places). While we consider this Apple's bug,
+ * this is the work-around: In order to maintain constant and
+ * unique DIDs and FNUMs, we monotonically generate the DIDs
+ * during the session, and derive the FNUMs from the filesystem.
+ * Since the DIDs are small, we insure that the FNUMs are fairly
+ * large by setting thier high bits to the device number.
+ *
+ * AFS already does something very similar to this for the
+ * inode number, so we don't repeat the procedure.
+ *
+ * new algorithm:
+ * due to complaints over did's being non-persistent,
+ * here's the current hack to provide semi-persistent
+ * did's:
+ * 1) we reserve the first bit for file ids.
+ * 2) the next 7 bits are for the device.
+ * 3) the remaining 24 bits are for the inode.
+ *
+ * both the inode and device information are actually hashes
+ * that are then truncated to the requisite bit length.
+ *
+ * it should be okay to use lstat to deal with symlinks.
+ */
- }
-
- memcpy(data, &aint, sizeof( aint ));
- data += sizeof( aint );
- break;
-
- case FILPBIT_DFLEN :
- aint = htonl( st->st_size );
- memcpy(data, &aint, sizeof( aint ));
- data += sizeof( aint );
- break;
-
- case FILPBIT_RFLEN :
- if ( isad ) {
- aint = htonl( ad_getentrylen( adp, ADEID_RFORK ));
- } else {
- aint = 0;
- }
- memcpy(data, &aint, sizeof( aint ));
- data += sizeof( aint );
- break;
-
- /* Current client needs ProDOS info block for this file.
- Use simple heuristic and let the Mac "type" string tell
- us what the PD file code should be. Everything gets a
- subtype of 0x0000 unless the original value was hashed
- to "pXYZ" when we created it. See IA, Ver 2.
- <shirsch@ibm.net> */
- case FILPBIT_PDINFO :
- if ( isad ) {
- memcpy(fdType, ad_entry( adp, ADEID_FINDERI ), 4 );
-
- if ( memcmp( fdType, "TEXT", 4 ) == 0 ) {
- achar = '\x04';
- ashort = 0x0000;
- }
- else if ( memcmp( fdType, "PSYS", 4 ) == 0 ) {
- achar = '\xff';
- ashort = 0x0000;
- }
- else if ( memcmp( fdType, "PS16", 4 ) == 0 ) {
- achar = '\xb3';
- ashort = 0x0000;
- }
- else if ( memcmp( fdType, "BINA", 4 ) == 0 ) {
- achar = '\x00';
- ashort = 0x0000;
- }
- else if ( fdType[0] == 'p' ) {
- achar = fdType[1];
- ashort = (fdType[2] * 256) + fdType[3];
- }
- else {
- achar = '\x00';
- ashort = 0x0000;
- }
- }
- else {
- achar = '\x00';
- ashort = 0x0000;
- }
-
- *data++ = achar;
- *data++ = 0;
- memcpy(data, &ashort, sizeof( ashort ));
- data += sizeof( ashort );
- memset(data, 0, sizeof( ashort ));
- data += sizeof( ashort );
- break;
-
- default :
- if ( isad ) {
- ad_close( adp, ADFLAGS_HF );
- }
- return( AFPERR_BITMAP );
- }
- bitmap = bitmap>>1;
- bit++;
+ }
+
+ memcpy(data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+ break;
+
+ case FILPBIT_DFLEN :
+ aint = htonl( st->st_size );
+ memcpy(data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+ break;
+
+ case FILPBIT_RFLEN :
+ if ( isad ) {
+ aint = htonl( ad_getentrylen( adp, ADEID_RFORK ));
+ } else {
+ aint = 0;
+ }
+ memcpy(data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+ break;
+
+ /* Current client needs ProDOS info block for this file.
+ Use simple heuristic and let the Mac "type" string tell
+ us what the PD file code should be. Everything gets a
+ subtype of 0x0000 unless the original value was hashed
+ to "pXYZ" when we created it. See IA, Ver 2.
+ <shirsch@ibm.net> */
+ case FILPBIT_PDINFO :
+ if ( isad ) {
+ memcpy(fdType, ad_entry( adp, ADEID_FINDERI ), 4 );
+
+ if ( memcmp( fdType, "TEXT", 4 ) == 0 ) {
+ achar = '\x04';
+ ashort = 0x0000;
+ }
+ else if ( memcmp( fdType, "PSYS", 4 ) == 0 ) {
+ achar = '\xff';
+ ashort = 0x0000;
+ }
+ else if ( memcmp( fdType, "PS16", 4 ) == 0 ) {
+ achar = '\xb3';
+ ashort = 0x0000;
+ }
+ else if ( memcmp( fdType, "BINA", 4 ) == 0 ) {
+ achar = '\x00';
+ ashort = 0x0000;
+ }
+ else if ( fdType[0] == 'p' ) {
+ achar = fdType[1];
+ ashort = (fdType[2] * 256) + fdType[3];
+ }
+ else {
+ achar = '\x00';
+ ashort = 0x0000;
+ }
+ }
+ else {
+ achar = '\x00';
+ ashort = 0x0000;
+ }
+
+ *data++ = achar;
+ *data++ = 0;
+ memcpy(data, &ashort, sizeof( ashort ));
+ data += sizeof( ashort );
+ memset(data, 0, sizeof( ashort ));
+ data += sizeof( ashort );
+ break;
+
+ default :
+ if ( isad ) {
+ ad_close( adp, ADFLAGS_HF );
+ }
+ return( AFPERR_BITMAP );
+ }
+ bitmap = bitmap>>1;
+ bit++;
- while (( bitmap & 1 ) == 0 ) {
- bitmap = bitmap>>1;
- bit++;
- }
-
- switch( bit ) {
- case FILPBIT_ATTR :
- memcpy(&ashort, buf, sizeof( ashort ));
- ad_getattr(adp, &bshort);
- if ( ntohs( ashort ) & ATTRBIT_SETCLR ) {
- bshort |= htons( ntohs( ashort ) & ~ATTRBIT_SETCLR );
- } else {
- bshort &= ~ashort;
- }
- ad_setattr(adp, bshort);
- buf += sizeof( ashort );
- break;
-
- case FILPBIT_CDATE :
- memcpy(&aint, buf, sizeof(aint));
- ad_setdate(adp, AD_DATE_CREATE, aint);
- buf += sizeof( aint );
- break;
-
- case FILPBIT_MDATE :
- memcpy(&aint, buf, sizeof( aint ));
- if (isad)
- ad_setdate(adp, AD_DATE_MODIFY, aint);
- ut.actime = ut.modtime = AD_DATE_TO_UNIX(aint);
- utime(upath, &ut);
- buf += sizeof( aint );
- break;
-
- case FILPBIT_BDATE :
- memcpy(&aint, buf, sizeof(aint));
- ad_setdate(adp, AD_DATE_BACKUP, aint);
- buf += sizeof( aint );
- break;
-
- case FILPBIT_FINFO :
- if ((memcmp( ad_entry( adp, ADEID_FINDERI ), ufinderi, 8 ) == 0)
- && (em = getextmap( path )) &&
- (memcmp(buf, em->em_type, sizeof( em->em_type )) == 0) &&
- (memcmp(buf + 4, em->em_creator,
- sizeof( em->em_creator )) == 0)) {
- memcpy(buf, ufinderi, 8 );
- }
- memcpy(ad_entry( adp, ADEID_FINDERI ), buf, 32 );
- buf += 32;
- break;
-
- /* Client needs to set the ProDOS file info for this file.
- Use defined strings for the simple cases, and convert
- all else into pXYY per Inside Appletalk. Always set
- the creator as "pdos". <shirsch@ibm.net> */
- case FILPBIT_PDINFO :
- achar = *buf;
- buf += 2;
- memcpy(&ashort, buf, sizeof( ashort ));
- ashort = ntohs( ashort );
- buf += 2;
-
- switch ( (unsigned int) achar )
- {
- case 0x04 :
- fdType = ( u_char *) "TEXT";
- break;
-
- case 0xff :
- fdType = ( u_char *) "PSYS";
- break;
-
- case 0xb3 :
- fdType = ( u_char *) "PS16";
- break;
-
- case 0x00 :
- fdType = ( u_char *) "BINA";
- break;
-
- default :
- xyy[0] = ( u_char ) 'p';
- xyy[1] = achar;
- xyy[2] = ( u_char ) ( ashort >> 8 ) & 0xff;
- xyy[3] = ( u_char ) ashort & 0xff;
- fdType = xyy;
- break;
- }
-
- memcpy(ad_entry( adp, ADEID_FINDERI ), fdType, 4 );
- memcpy(ad_entry( adp, ADEID_FINDERI ) + 4, "pdos", 4 );
- break;
-
-
- default :
- err = AFPERR_BITMAP;
- goto setfilparam_done;
- }
-
- bitmap = bitmap>>1;
- bit++;
+ while (( bitmap & 1 ) == 0 ) {
+ bitmap = bitmap>>1;
+ bit++;
+ }
+
+ switch( bit ) {
+ case FILPBIT_ATTR :
+ memcpy(&ashort, buf, sizeof( ashort ));
+ ad_getattr(adp, &bshort);
+ if ( ntohs( ashort ) & ATTRBIT_SETCLR ) {
+ bshort |= htons( ntohs( ashort ) & ~ATTRBIT_SETCLR );
+ } else {
+ bshort &= ~ashort;
+ }
+ ad_setattr(adp, bshort);
+ buf += sizeof( ashort );
+ break;
+
+ case FILPBIT_CDATE :
+ memcpy(&aint, buf, sizeof(aint));
+ ad_setdate(adp, AD_DATE_CREATE, aint);
+ buf += sizeof( aint );
+ break;
+
+ case FILPBIT_MDATE :
+ memcpy(&aint, buf, sizeof( aint ));
+ if (isad)
+ ad_setdate(adp, AD_DATE_MODIFY, aint);
+ ut.actime = ut.modtime = AD_DATE_TO_UNIX(aint);
+ utime(upath, &ut);
+ buf += sizeof( aint );
+ break;
+
+ case FILPBIT_BDATE :
+ memcpy(&aint, buf, sizeof(aint));
+ ad_setdate(adp, AD_DATE_BACKUP, aint);
+ buf += sizeof( aint );
+ break;
+
+ case FILPBIT_FINFO :
+ if ((memcmp( ad_entry( adp, ADEID_FINDERI ), ufinderi, 8 ) == 0)
+ && (em = getextmap( path )) &&
+ (memcmp(buf, em->em_type, sizeof( em->em_type )) == 0) &&
+ (memcmp(buf + 4, em->em_creator,
+ sizeof( em->em_creator )) == 0)) {
+ memcpy(buf, ufinderi, 8 );
+ }
+ memcpy(ad_entry( adp, ADEID_FINDERI ), buf, 32 );
+ buf += 32;
+ break;
+
+ /* Client needs to set the ProDOS file info for this file.
+ Use defined strings for the simple cases, and convert
+ all else into pXYY per Inside Appletalk. Always set
+ the creator as "pdos". <shirsch@ibm.net> */
+ case FILPBIT_PDINFO :
+ achar = *buf;
+ buf += 2;
+ memcpy(&ashort, buf, sizeof( ashort ));
+ ashort = ntohs( ashort );
+ buf += 2;
+
+ switch ( (unsigned int) achar )
+ {
+ case 0x04 :
+ fdType = ( u_char *) "TEXT";
+ break;
+
+ case 0xff :
+ fdType = ( u_char *) "PSYS";
+ break;
+
+ case 0xb3 :
+ fdType = ( u_char *) "PS16";
+ break;
+
+ case 0x00 :
+ fdType = ( u_char *) "BINA";
+ break;
+
+ default :
+ xyy[0] = ( u_char ) 'p';
+ xyy[1] = achar;
+ xyy[2] = ( u_char ) ( ashort >> 8 ) & 0xff;
+ xyy[3] = ( u_char ) ashort & 0xff;
+ fdType = xyy;
+ break;
+ }
+
+ memcpy(ad_entry( adp, ADEID_FINDERI ), fdType, 4 );
+ memcpy(ad_entry( adp, ADEID_FINDERI ) + 4, "pdos", 4 );
+ break;
+
+
+ default :
+ err = AFPERR_BITMAP;
+ goto setfilparam_done;
+ }
+
+ bitmap = bitmap>>1;
+ bit++;
- switch ( errno ) {
- case ENOENT :
- /* check for a source appledouble header. if it exists, make
- * a dest appledouble directory and do the rename again. */
- memset(&ad, 0, sizeof(ad));
- if (rc || stat(adsrc, &st) ||
- (ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad) < 0))
- return AFP_OK;
- rc++;
- ad_close(&ad, ADFLAGS_HF);
- goto rename_retry;
- case EPERM:
- case EACCES :
- return( AFPERR_ACCESS );
- case EROFS:
- return AFPERR_VLOCK;
- default :
- return( AFPERR_PARAM );
- }
+ switch ( errno ) {
+ case ENOENT :
+ /* check for a source appledouble header. if it exists, make
+ * a dest appledouble directory and do the rename again. */
+ memset(&ad, 0, sizeof(ad));
+ if (rc || stat(adsrc, &st) ||
+ (ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad) < 0))
+ return AFP_OK;
+ rc++;
+ ad_close(&ad, ADFLAGS_HF);
+ goto rename_retry;
+ case EPERM:
+ case EACCES :
+ return( AFPERR_ACCESS );
+ case EROFS:
+ return AFPERR_VLOCK;
+ default :
+ return( AFPERR_PARAM );
+ }
- if (newname) {
- if ((sfd = open( ad_path( src, ADFLAGS_HF ), O_RDONLY, 0 )) < 0 ) {
- switch ( errno ) {
- case ENOENT :
- break; /* just copy the data fork */
- case EACCES :
- return( AFPERR_ACCESS );
- default :
- return( AFPERR_PARAM );
- }
- } else {
- if (( dfd = open( ad_path( dst, ADFLAGS_HF ), O_WRONLY|O_CREAT,
- ad_mode( ad_path( dst, ADFLAGS_HF ), 0666 ))) < 0 ) {
- close( sfd );
- switch ( errno ) {
- case ENOENT :
- return( AFPERR_NOOBJ );
- case EACCES :
- return( AFPERR_ACCESS );
- case EROFS:
- return AFPERR_VLOCK;
- default :
- return( AFPERR_PARAM );
- }
- }
-
- /* copy the file */
+ if (newname) {
+ if ((sfd = open( ad_path( src, ADFLAGS_HF ), O_RDONLY, 0 )) < 0 ) {
+ switch ( errno ) {
+ case ENOENT :
+ break; /* just copy the data fork */
+ case EACCES :
+ return( AFPERR_ACCESS );
+ default :
+ return( AFPERR_PARAM );
+ }
+ } else {
+ if (( dfd = open( ad_path( dst, ADFLAGS_HF ), O_WRONLY|O_CREAT,
+ ad_mode( ad_path( dst, ADFLAGS_HF ), 0666 ))) < 0 ) {
+ close( sfd );
+ switch ( errno ) {
+ case ENOENT :
+ return( AFPERR_NOOBJ );
+ case EACCES :
+ return( AFPERR_ACCESS );
+ case EROFS:
+ return AFPERR_VLOCK;
+ default :
+ return( AFPERR_PARAM );
+ }
+ }
+
+ /* copy the file */
- memset(&ad, 0, sizeof(ad));
- if ( ad_open( dst, noadouble | ADFLAGS_HF, O_RDWR|O_CREAT,
- 0666, &ad) < 0 ) {
- switch ( errno ) {
- case ENOENT :
- return noadouble ? AFP_OK : AFPERR_NOOBJ;
- case EACCES :
- return( AFPERR_ACCESS );
- case EROFS:
- return AFPERR_VLOCK;
- default :
- return( AFPERR_PARAM );
- }
- }
-
- len = strlen( newname );
- ad_setentrylen( &ad, ADEID_NAME, len );
- memcpy(ad_entry( &ad, ADEID_NAME ), newname, len );
- ad_flush( &ad, ADFLAGS_HF );
- ad_close( &ad, ADFLAGS_HF );
+ memset(&ad, 0, sizeof(ad));
+ if ( ad_open( dst, noadouble | ADFLAGS_HF, O_RDWR|O_CREAT,
+ 0666, &ad) < 0 ) {
+ switch ( errno ) {
+ case ENOENT :
+ return noadouble ? AFP_OK : AFPERR_NOOBJ;
+ case EACCES :
+ return( AFPERR_ACCESS );
+ case EROFS:
+ return AFPERR_VLOCK;
+ default :
+ return( AFPERR_PARAM );
+ }
+ }
+
+ len = strlen( newname );
+ ad_setentrylen( &ad, ADEID_NAME, len );
+ memcpy(ad_entry( &ad, ADEID_NAME ), newname, len );
+ ad_flush( &ad, ADFLAGS_HF );
+ ad_close( &ad, ADFLAGS_HF );
- /*
- * If can't open read/write then try again read-only. If it's open
- * read-only, we must do a read lock instead of a write lock.
- */
- /* try to open both at once */
- adflags = ADFLAGS_DF|ADFLAGS_HF;
- memset(&ad, 0, sizeof(ad));
- if ( ad_open( file, adflags, openmode, 0, &ad ) < 0 ) {
- switch (errno) {
- case ENOENT:
- adflags = ADFLAGS_DF;
- /* that failed. now try to open just the data fork */
- memset(&ad, 0, sizeof(ad));
- if ( ad_open( file, adflags, openmode, 0, &ad ) < 0 ) {
- switch (errno) {
- case ENOENT:
- return AFPERR_NOOBJ;
- case EACCES:
- if(openmode == O_RDWR) {
- openmode = O_RDONLY;
- locktype = ADLOCK_RD;
- continue;
- } else {
- return AFPERR_ACCESS;
- }
- case EROFS:
- return AFPERR_VLOCK;
- default:
- return AFPERR_PARAM;
- }
- }
- break;
-
- case EACCES:
- if(openmode == O_RDWR) {
- openmode = O_RDONLY;
- locktype = ADLOCK_RD;
- continue;
- } else {
- return AFPERR_ACCESS;
- }
- case EROFS:
- return AFPERR_VLOCK;
- default:
- return( AFPERR_PARAM );
- }
- }
- break; /* from the while */
+ /*
+ * If can't open read/write then try again read-only. If it's open
+ * read-only, we must do a read lock instead of a write lock.
+ */
+ /* try to open both at once */
+ adflags = ADFLAGS_DF|ADFLAGS_HF;
+ memset(&ad, 0, sizeof(ad));
+ if ( ad_open( file, adflags, openmode, 0, &ad ) < 0 ) {
+ switch (errno) {
+ case ENOENT:
+ adflags = ADFLAGS_DF;
+ /* that failed. now try to open just the data fork */
+ memset(&ad, 0, sizeof(ad));
+ if ( ad_open( file, adflags, openmode, 0, &ad ) < 0 ) {
+ switch (errno) {
+ case ENOENT:
+ return AFPERR_NOOBJ;
+ case EACCES:
+ if(openmode == O_RDWR) {
+ openmode = O_RDONLY;
+ locktype = ADLOCK_RD;
+ continue;
+ } else {
+ return AFPERR_ACCESS;
+ }
+ case EROFS:
+ return AFPERR_VLOCK;
+ default:
+ return AFPERR_PARAM;
+ }
+ }
+ break;
+
+ case EACCES:
+ if(openmode == O_RDWR) {
+ openmode = O_RDONLY;
+ locktype = ADLOCK_RD;
+ continue;
+ } else {
+ return AFPERR_ACCESS;
+ }
+ case EROFS:
+ return AFPERR_VLOCK;
+ default:
+ return( AFPERR_PARAM );
+ }
+ }
+ break; /* from the while */