/*
- * $Id: fork.c,v 1.5 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: fork.c,v 1.8 2001-08-27 15:26:16 uhees Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#include <atalk/afp.h>
#include <atalk/adouble.h>
#include <atalk/util.h>
+#ifdef CNID_DB
#include <atalk/cnid.h>
+#endif
#include "fork.h"
#include "file.h"
} else {
aint = ad_getentrylen( ofork->of_ad, ADEID_RFORK );
if ( ad_refresh( ofork->of_ad ) < 0 ) {
- syslog( LOG_ERR, "getforkparams: ad_refresh: %m");
+ syslog( LOG_ERR, "getforkparams: ad_refresh: %s", strerror(errno) );
return( AFPERR_PARAM );
}
/* See afp_closefork() for why this is bad */
memcpy(data, ufinderi, 8 );
if (( em = getextmap( ofork->of_name )) != NULL ) {
memcpy(data, em->em_type, sizeof( em->em_type ));
- memcpy(data + 4, em->em_creator,
+ memcpy(data + 4, em->em_creator,
sizeof( em->em_creator ));
}
}
break;
case FILPBIT_FNUM :
- /*
- * See file.c getfilparams() for why this is done this
- * way.
- */
+ aint = 0;
#if AD_VERSION > AD_VERSION1
- if (isad)
- memcpy(&aint, ad_entry(ofork->of_ad, ADEID_DID), sizeof(aint));
- else
- aint = 0;
-
- if (!(aint = cnid_add(ofork->of_vol->v_db, &st,
- ofork->of_dir->d_did,
- upath, strlen(upath), aint))) {
+ /* look in AD v2 header */
+ if (isad)
+ memcpy(&aint, ad_entry(ofork->of_ad, ADEID_DID), sizeof(aint));
#endif /* AD_VERSION > AD_VERSION1 */
+
+#ifdef CNID_DB
+ aint = cnid_add(ofork->of_vol->v_db, &st,
+ ofork->of_dir->d_did,
+ upath, strlen(upath), aint);
+#endif /* CNID_DB */
+
+ if (aint == 0) {
#ifdef AFS
aint = st.st_ino;
#else /* AFS */
aint = ( st.st_dev << 16 ) | ( st.st_ino & 0x0000ffff );
#endif /* AFS */
-#if AD_VERSION > AD_VERSION1
}
-#endif /* AD_VERSION > AD_VERSION1 */
- memcpy(data, &aint, sizeof( aint ));
+
+ memcpy(data, &aint, sizeof( aint ));
data += sizeof( aint );
break;
goto openfork_err;
break;
default:
- syslog( LOG_ERR, "afp_openfork: ad_open: %m" );
+ syslog( LOG_ERR, "afp_openfork: ad_open: %s", strerror(errno) );
ret = AFPERR_PARAM;
goto openfork_err;
break;
if (!ret && (access & OPENACC_RD)) {
ofork->of_flags |= AFPFORK_ACCRD;
ret = ad_lock(ofork->of_ad, eid, ADLOCK_RD | ADLOCK_FILELOCK,
- AD_FILELOCK_RD, 1, ofrefnum);
+ AD_FILELOCK_RD, 1, ofrefnum);
}
/* can we access the fork? */
break;
default:
*rbuflen = 0;
- syslog( LOG_ERR, "afp_openfork: ad_lock: %m" );
+ syslog( LOG_ERR, "afp_openfork: ad_lock: %s", strerror(errno) );
return( AFPERR_PARAM );
}
}
*rbuflen = 0;
if (( ofork = of_find( ofrefnum )) == NULL ) {
- syslog( LOG_ERR, "afp_setforkparams: of_find: %m" );
+ syslog( LOG_ERR, "afp_setforkparams: of_find: %s", strerror(errno) );
return( AFPERR_PARAM );
}
goto afp_setfork_err;
if (ad_flush( ofork->of_ad, ADFLAGS_HF ) < 0) {
- syslog( LOG_ERR, "afp_setforkparams: ad_flush: %m" );
+ syslog( LOG_ERR, "afp_setforkparams: ad_flush: %s",
+ strerror(errno) );
return( AFPERR_PARAM );
}
} else
ibuf += sizeof(ofrefnum);
if (( ofork = of_find( ofrefnum )) == NULL ) {
- syslog( LOG_ERR, "afp_bytelock: of_find: %m" );
+ syslog( LOG_ERR, "afp_bytelock: of_find: %s", strerror(errno) );
return( AFPERR_PARAM );
}
cc = ad_read(ofork->of_ad, eid, offset, rbuf, *rbuflen);
if ( cc < 0 ) {
- syslog( LOG_ERR, "afp_read: ad_read: %m" );
+ syslog( LOG_ERR, "afp_read: ad_read: %s", strerror(errno) );
*rbuflen = 0;
return( AFPERR_PARAM );
}
ibuf += sizeof( u_short );
if (( ofork = of_find( ofrefnum )) == NULL ) {
- syslog( LOG_ERR, "afp_read: of_find: %m" );
+ syslog( LOG_ERR, "afp_read: of_find: %s", strerror(errno) );
err = AFPERR_PARAM;
goto afp_read_err;
}
if (errno == EINVAL)
goto afp_read_loop;
else {
- syslog(LOG_ERR, "afp_read: ad_readfile: %m");
+ syslog(LOG_ERR, "afp_read: ad_readfile: %s", strerror(errno));
goto afp_read_exit;
}
}
goto afp_read_done;
afp_read_exit:
- syslog(LOG_ERR, "afp_read: %m");
+ syslog(LOG_ERR, "afp_read: %s", strerror(errno));
dsi_readdone(dsi);
ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, reqcount);
obj->exit(1);
memcpy(&ofrefnum, ibuf, sizeof( ofrefnum ));
if (( ofork = of_find( ofrefnum )) == NULL ) {
- syslog( LOG_ERR, "afp_flushfork: of_find: %m" );
+ syslog( LOG_ERR, "afp_flushfork: of_find: %s", strerror(errno) );
return( AFPERR_PARAM );
}
if ( flushfork( ofork ) < 0 ) {
- syslog( LOG_ERR, "afp_flushfork: %m" );
+ syslog( LOG_ERR, "afp_flushfork: %s", strerror(errno) );
}
return( AFP_OK );
if ( ad_dfileno( ofork->of_ad ) != -1 &&
fsync( ad_dfileno( ofork->of_ad )) < 0 ) {
- syslog( LOG_ERR, "flushfork: dfile(%d) %m",
- ad_dfileno(ofork->of_ad) );
+ syslog( LOG_ERR, "flushfork: dfile(%d) %s",
+ ad_dfileno(ofork->of_ad), strerror(errno) );
err = -1;
}