return( AFPERR_BITMAP );
}
- if ( ad_reso_fileno( ofork->of_ad ) == -1 ) { /* META ? */
+ if (! AD_META_OPEN(ofork->of_ad)) {
adp = NULL;
} else {
adp = ofork->of_ad;
return ret;
}
}
- if ( access == (OPENACC_WR | OPENACC_RD | OPENACC_DWR | OPENACC_DRD)) {
- return ad_excl_lock(adp, eid);
- }
+
return 0;
}
struct stat *st;
uint16_t bshort;
struct path *s_path;
+ struct stat xxx;
ibuf++;
fork = *ibuf++;
return AFPERR_BADTYPE;
}
- LOG(log_debug, logtype_afpd,
- "afp_openfork(\"%s\", %s)",
- fullpathname(s_path->u_name),
- (fork & OPENFORK_RSCS) ? "OPENFORK_RSCS" : "OPENFORK_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 */
- if (ad_open(ofork->of_ad, upath, adflags, O_RDWR, O_RDWR) < 0) {
+ if (ad_open(ofork->of_ad, upath,
+ adflags | ADFLAGS_RDWR | ADFLAGS_SETSHRMD) < 0) {
switch ( errno ) {
case EROFS:
ret = AFPERR_VLOCK;
case EACCES:
goto openfork_err;
- break;
case ENOENT:
if (fork == OPENFORK_DATA) {
/* try to open only the data fork */
- if (ad_open(ofork->of_ad, upath, ADFLAGS_DF, O_RDWR) < 0) {
+ if (ad_open(ofork->of_ad, upath,
+ ADFLAGS_DF | ADFLAGS_RDWR | ADFLAGS_SETSHRMD) < 0) {
goto openfork_err;
}
adflags = ADFLAGS_DF;
} else {
/* here's the deal. we only try to create the resource
* fork if the user wants to open it for write acess. */
- if (ad_open(ofork->of_ad, upath, adflags, O_RDWR | O_CREAT, 0666, O_RDWR | O_CREAT, 0666) < 0)
+ if (ad_open(ofork->of_ad, upath,
+ adflags | ADFLAGS_RDWR | ADFLAGS_SETSHRMD | ADFLAGS_CREATE, 0666) < 0)
goto openfork_err;
- ofork->of_flags |= AFPFORK_OPEN;
+ ofork->of_flags |= AFPFORK_META;
}
break;
case EMFILE :
case ENFILE :
ret = AFPERR_NFILE;
goto openfork_err;
- break;
case EISDIR :
ret = AFPERR_BADTYPE;
goto openfork_err;
- break;
default:
LOG(log_error, logtype_afpd, "afp_openfork(%s): ad_open: %s", s_path->m_name, strerror(errno) );
ret = AFPERR_PARAM;
goto openfork_err;
- break;
}
}
else {
/* the ressource fork is open too */
- ofork->of_flags |= AFPFORK_OPEN;
+ ofork->of_flags |= AFPFORK_META;
}
} else {
/* try opening in read-only mode */
ret = AFPERR_NOOBJ;
- if (ad_open(ofork->of_ad, upath, adflags, O_RDONLY, O_RDONLY) < 0) {
+ if (ad_open(ofork->of_ad, upath, adflags | ADFLAGS_RDONLY | ADFLAGS_SETSHRMD) < 0) {
switch ( errno ) {
case EROFS:
ret = AFPERR_VLOCK;
+ goto openfork_err;
case EACCES:
goto openfork_err;
- break;
case ENOENT:
/* see if client asked for a read only data fork */
if (fork == OPENFORK_DATA) {
- if (ad_open(ofork->of_ad, upath, ADFLAGS_DF, O_RDONLY) < 0) {
+ if (ad_open(ofork->of_ad, upath, ADFLAGS_DF | ADFLAGS_RDONLY | ADFLAGS_SETSHRMD) < 0) {
goto openfork_err;
}
adflags = ADFLAGS_DF;
}
- /* else we don't set AFPFORK_OPEN because there's no ressource fork file
- * We need to check AFPFORK_OPEN in afp_closefork(). eg fork open read-only
+ /* else we don't set AFPFORK_META because there's no ressource fork file
+ * We need to check AFPFORK_META in afp_closefork(). eg fork open read-only
* then create in open read-write.
* FIXME , it doesn't play well with byte locking example:
* ressource fork open read only
case ENFILE :
ret = AFPERR_NFILE;
goto openfork_err;
- break;
case EISDIR :
ret = AFPERR_BADTYPE;
goto openfork_err;
- break;
default:
LOG(log_error, logtype_afpd, "afp_openfork(\"%s\"): %s",
fullpathname(s_path->m_name), strerror(errno) );
goto openfork_err;
- break;
}
- }
- else {
- /* the ressource fork is open too */
- ofork->of_flags |= AFPFORK_OPEN;
+ } else {
+ ofork->of_flags |= AFPFORK_META;
}
}
*/
/* don't try to lock non-existent rforks. */
- if ((eid == ADEID_DFORK) || (ad_meta_fileno(ofork->of_ad) != -1)) { /* META */
-
+ 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) {
if (err < 0)
goto afp_setfork_err;
} else if (bitmap == (1<<FILPBIT_RFLEN) || bitmap == (1<<FILPBIT_EXTRFLEN)) {
- ad_refresh( ofork->of_ad );
+ ad_refresh(NULL, ofork->of_ad );
st_size = ad_size(ofork->of_ad, eid);
err = -2;
reqcount = get_off_t(&ibuf, is64);
LOG(log_debug, logtype_afpd,
- "afp_read(\"%s\", off: %" PRIu64 ", size: %" PRIu64 ", fork: %s)",
- cfrombstr(ofork->of_ad->ad_fullpath), offset, reqcount,
- (ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
+ "afp_read(off: %" PRIu64 ", size: %" PRIu64 ", fork: %s)", offset, reqcount,
+ (ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
if (is64) {
nlmask = nlchar = 0;
return( AFPERR_PARAM );
}
- LOG(log_debug, logtype_afpd,
- "afp_flushfork(\"%s\", fork: %s)",
- cfrombstr(ofork->of_ad->ad_fullpath),
+ LOG(log_debug, logtype_afpd, "afp_flushfork(fork: %s)",
(ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
if ( flushfork( ofork ) < 0 ) {
return( AFPERR_PARAM );
}
- LOG(log_debug, logtype_afpd,
- "afp_syncfork(\"%s\", fork: %s)",
- cfrombstr(ofork->of_ad->ad_fullpath),
+ LOG(log_debug, logtype_afpd, "afp_syncfork(fork: %s)",
(ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
if ( flushfork( ofork ) < 0 ) {
(ofork->of_flags & AFPFORK_RSRC)) {
/* read in the rfork length */
- ad_refresh(ofork->of_ad);
+ ad_refresh(NULL, ofork->of_ad);
/* set the date if we're dirty */
if ((ofork->of_flags & AFPFORK_DIRTY) && !gettimeofday(&tv, NULL)) {
return( AFPERR_PARAM );
}
- LOG(log_debug, logtype_afpd,
- "afp_closefork(\"%s\", fork: %s)",
- cfrombstr(ofork->of_ad->ad_fullpath),
+ LOG(log_debug, logtype_afpd, "afp_closefork(fork: %s)",
(ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
if ( of_closefork( ofork ) < 0 ) {
}
}
+ LOG(log_debug, logtype_afpd, "write_file(off: %ju, size: %zu)",
+ (uintmax_t)offset, rbuflen);
+
if (( cc = ad_write(ofork->of_ad, eid, offset, 0,
rbuf, rbuflen)) < 0 ) {
switch ( errno ) {
goto afp_write_err;
}
- LOG(log_debug, logtype_afpd,
- "afp_write(\"%s\", off: %" PRIu64 ", size: %" PRIu64 ", fork: %s)",
- cfrombstr(ofork->of_ad->ad_fullpath), offset, reqcount,
- (ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
+ LOG(log_debug, logtype_afpd, "afp_write(off: %" PRIu64 ", size: %" PRIu64 ", fork: %s)",
+ offset, reqcount, (ofork->of_flags & AFPFORK_DATA) ? "d" : "r");
if ((ofork->of_flags & AFPFORK_ACCWR) == 0) {
err = AFPERR_ACCESS;
case AFPPROTO_DSI:
{
DSI *dsi = obj->handle;
-
/* find out what we have already and write it out. */
cc = dsi_writeinit(dsi, rbuf, *rbuflen);
+
if (!cc || (cc = write_file(ofork, eid, offset, rbuf, cc, xlate)) < 0) {
dsi_writeflush(dsi);
*rbuflen = 0;
ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, reqcount, ofork->of_refnum);
return cc;
}
+
offset += cc;
#if 0 /*def HAVE_SENDFILE_WRITE*/
return( AFPERR_PARAM );
}
- if ( ad_meta_fileno( ofork->of_ad ) != -1 ) { /* META */
- if ( ad_refresh( ofork->of_ad ) < 0 ) {
+ if (AD_META_OPEN(ofork->of_ad)) {
+ if ( ad_refresh(NULL, ofork->of_ad ) < 0 ) {
LOG(log_error, logtype_afpd, "getforkparams(%s): ad_refresh: %s", of_name(ofork), strerror(errno) );
return( AFPERR_PARAM );
}
}
- if (AFP_OK != ( ret = getforkparams( ofork, bitmap,
- rbuf + sizeof( u_short ), &buflen ))) {
+ if (AFP_OK != (ret = getforkparams(ofork, bitmap, rbuf + sizeof( u_short ), &buflen ))) {
return( ret );
}