return AFPERR_BADTYPE;
}
- LOG(log_debug, logtype_afpd, "afp_openfork(\"%s\", %s)",
- fullpathname(s_path->u_name), (fork & OPENFORK_RSCS) ? "RSRC" : "DATA");
-
/* stat() data fork st is set because it's not a dir */
switch ( s_path->st_errno ) {
case 0:
} else {
eid = ADEID_RFORK;
adflags = ADFLAGS_RF | ADFLAGS_HF;
+ if (!(access & OPENACC_WR))
+ adflags |= ADFLAGS_NORF;
}
path = s_path->m_name;
return( AFPERR_NFILE );
}
+ LOG(log_debug, logtype_afpd, "afp_openfork(\"%s\", %s, %s)",
+ fullpathname(s_path->u_name),
+ (fork & OPENFORK_RSCS) ? "data" : "reso",
+ !(access & OPENACC_WR) ? "O_RDONLY" : "O_RDWR");
+
ret = AFPERR_NOOBJ;
if (access & OPENACC_WR) {
/* try opening in read-write mode */
} else {
/* try opening in read-only mode */
ret = AFPERR_NOOBJ;
- /* we need w access for setting deny mode fcntl excl lock */
if (ad_open(ofork->of_ad, upath, adflags | ADFLAGS_RDONLY | ADFLAGS_SETSHRMD) < 0) {
switch ( errno ) {
case EROFS:
}
if ((ret = getforkparams(ofork, bitmap, rbuf + 2 * sizeof(int16_t), &buflen)) != AFP_OK) {
- ad_close( ofork->of_ad, adflags );
+ ad_close( ofork->of_ad, adflags | ADFLAGS_SETSHRMD);
goto openfork_err;
}
if (ad_meta_fileno(ofork->of_ad) != -1) { /* META */
ad_getattr(ofork->of_ad, &bshort);
if ((bshort & htons(ATTRBIT_NOWRITE)) && (access & OPENACC_WR)) {
- ad_close( ofork->of_ad, adflags );
+ ad_close( ofork->of_ad, adflags | ADFLAGS_SETSHRMD);
of_dealloc( ofork );
ofrefnum = 0;
memcpy(rbuf, &ofrefnum, sizeof(ofrefnum));
*/
/* don't try to lock non-existent rforks. */
- if ((eid == ADEID_DFORK) || (ad_reso_fileno(ofork->of_ad) != -1)) {
-
+ if ((eid == ADEID_DFORK)
+ || (ad_reso_fileno(ofork->of_ad) != -1)
+ || (ofork->of_ad->ad_vers == AD_VERSION_EA)) {
ret = fork_setmode(ofork->of_ad, eid, access, ofrefnum);
/* can we access the fork? */
if (ret < 0) {
+ ofork->of_flags |= AFPFORK_ERROR;
ret = errno;
- ad_close( ofork->of_ad, adflags );
+ ad_close( ofork->of_ad, adflags | ADFLAGS_SETSHRMD);
of_dealloc( ofork );
switch (ret) {
case EAGAIN: /* return data anyway */
ibuf += sizeof(ofrefnum);
if (NULL == ( ofork = of_find( ofrefnum )) ) {
- LOG(log_error, logtype_afpd, "afp_bytelock: of_find(%d) could not locate fork", ofrefnum );
+ LOG(log_error, logtype_afpd, "byte_lock: of_find(%d) could not locate fork", ofrefnum );
return( AFPERR_PARAM );
}
offset = get_off_t(&ibuf, is64);
length = get_off_t(&ibuf, is64);
- /* FIXME AD_FILELOCK test is surely wrong */
if (length == -1)
length = BYTELOCK_MAX;
else if (!length || is_neg(is64, length)) {