- if (access & OPENACC_WR) {
- /* try opening in read-write mode */
- if (ad_open(ofork->of_ad, upath, adflags, O_RDWR, O_RDWR) < 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) {
- 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)
- goto openfork_err;
- ofork->of_flags |= AFPFORK_OPEN;
- }
- 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;
+
+ /* First ad_open(), opens data or ressource fork */
+ if (ad_open(ofork->of_ad, upath, adflags, 0666) < 0) {
+ switch (errno) {
+ case EROFS:
+ ret = AFPERR_VLOCK;
+ case EACCES:
+ goto openfork_err;
+ case ENOENT:
+ goto openfork_err;
+ case EMFILE :
+ case ENFILE :
+ ret = AFPERR_NFILE;
+ goto openfork_err;
+ case EISDIR :
+ ret = AFPERR_BADTYPE;
+ goto openfork_err;
+ default:
+ LOG(log_error, logtype_afpd, "afp_openfork(%s): ad_open: %s", s_path->m_name, strerror(errno) );
+ ret = AFPERR_PARAM;
+ goto openfork_err;