X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fdesktop.c;h=9f105e13e13c612757386f70c342626e28fe5e77;hb=4054f4b3c85ecab060dafd46c0d3632cadbb5803;hp=060b68dc20425bfc424a483357680772ce3859d8;hpb=5f5367aa2eedd7e8538566a83d163cc549c9d68f;p=netatalk.git diff --git a/etc/afpd/desktop.c b/etc/afpd/desktop.c index 060b68dc..9f105e13 100644 --- a/etc/afpd/desktop.c +++ b/etc/afpd/desktop.c @@ -1,5 +1,5 @@ /* - * $Id: desktop.c,v 1.42 2009-10-22 13:40:11 franklahm Exp $ + * $Id: desktop.c,v 1.50.2.1 2010-02-01 10:56:08 franklahm Exp $ * * See COPYRIGHT. * @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -506,7 +505,7 @@ int afp_geticon(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t while (*rbuflen > 0) { #ifdef WITH_SENDFILE if (!obj->options.flags & OPTION_DEBUG) { - if (sys_sendfile(dsi->socket, si.sdt_fd, &offset, dsi->datasize) < 0) { + if (dsi_stream_read_file(dsi, si.sdt_fd, offset, dsi->datasize) < 0) { switch (errno) { case ENOSYS: case EINVAL: /* there's no guarantee that all fs support sendfile */ @@ -515,7 +514,10 @@ int afp_geticon(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t goto geticon_exit; } } - goto geticon_done; + else { + dsi_readdone(dsi); + return AFP_OK; + } } #endif buflen = read(si.sdt_fd, rbuf, *rbuflen); @@ -529,12 +531,12 @@ int afp_geticon(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen = buflen; } - + dsi_readdone(dsi); return AFP_OK; geticon_exit: - LOG(log_info, logtype_afpd, "afp_geticon(%s): %s", icon_dtfile(vol, fcreator), strerror(errno)); + LOG(log_error, logtype_afpd, "afp_geticon(%s): %s", icon_dtfile(vol, fcreator), strerror(errno)); dsi_readdone(dsi); obj->exit(EXITERR_SYS); return AFP_OK; @@ -595,27 +597,16 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8) char *m, *u; size_t inplen; size_t outlen; - u_int16_t flags = 0; + u_int16_t flags; if ( *mpath == '\0' ) { - return( "." ); + strcpy(upath, "."); + return upath; } /* set conversion flags */ - if (!(vol->v_flags & AFPVOL_NOHEX)) - flags |= CONV_ESCAPEHEX; - if (!(vol->v_flags & AFPVOL_USEDOTS)) - flags |= CONV_ESCAPEDOTS; - - if ((vol->v_casefold & AFPVOL_MTOUUPPER)) - flags |= CONV_TOUPPER; - else if ((vol->v_casefold & AFPVOL_MTOULOWER)) - flags |= CONV_TOLOWER; - - if ((vol->v_flags & AFPVOL_EILSEQ)) { - flags |= CONV__EILSEQ; - } - + flags = vol->v_mtou_flags; + m = demangle(vol, mpath, did); if (m != mpath) { return m; @@ -633,7 +624,7 @@ char *mtoupath(const struct vol *vol, char *mpath, cnid_t did, int utf8) } #ifdef DEBUG - LOG(log_debug, logtype_afpd, "mtoupath: '%s':'%s'", mpath, upath); + LOG(log_debug9, logtype_afpd, "mtoupath: '%s':'%s'", mpath, upath); #endif /* DEBUG */ return( upath ); } @@ -645,20 +636,13 @@ char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8) { static char mpath[ MAXPATHLEN + 2]; /* for convert_charset dest_len parameter +2 */ char *m, *u; - u_int16_t flags = CONV_IGNORE | CONV_UNESCAPEHEX; + u_int16_t flags; size_t outlen; m = mpath; outlen = strlen(upath); - if ((vol->v_casefold & AFPVOL_UTOMUPPER)) - flags |= CONV_TOUPPER; - else if ((vol->v_casefold & AFPVOL_UTOMLOWER)) - flags |= CONV_TOLOWER; - - if ((vol->v_flags & AFPVOL_EILSEQ)) { - flags |= CONV__EILSEQ; - } + flags = vol->v_utom_flags; u = upath; @@ -668,10 +652,7 @@ char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8) goto utompath_error; } - if (!(flags & CONV_REQMANGLE)) - flags = 0; - else - flags = 1; + flags = !!(flags & CONV_REQMANGLE); if (utf8) flags |= 2; @@ -679,7 +660,7 @@ char *utompath(const struct vol *vol, char *upath, cnid_t id, int utf8) m = mangle(vol, mpath, outlen, upath, id, flags); #ifdef DEBUG - LOG(log_debug, logtype_afpd, "utompath: '%s':'%s':'%2.2X'", upath, m, ntohl(id)); + LOG(log_debug9, logtype_afpd, "utompath: '%s':'%s':'%2.2X'", upath, m, ntohl(id)); #endif /* DEBUG */ return(m); @@ -702,7 +683,7 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf) clen = min( clen, 199 ); upath = path->u_name; - if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) { + if (check_access(upath, OPENACC_WR ) < 0) { return AFPERR_ACCESS; } @@ -713,14 +694,14 @@ static int ad_addcomment(struct vol *vol, struct path *path, char *ibuf) } else adp = of->of_ad; - if (ad_open_metadata( upath , vol_noadouble(vol) | ( (isadir) ? ADFLAGS_DIR :0),O_CREAT, adp) < 0 ) { + if (ad_open_metadata( upath , ( (isadir) ? ADFLAGS_DIR : 0), O_CREAT, adp) < 0 ) { return( AFPERR_ACCESS ); } if (ad_getentryoff(adp, ADEID_COMMENT)) { if ( (ad_get_MD_flags( adp ) & O_CREAT) ) { if ( *path->m_name == '\0' ) { - name = curdir->d_m_name; + name = (char *)curdir->d_m_name->data; } else { name = path->m_name; } @@ -786,7 +767,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, size_t } else adp = of->of_ad; - if ( ad_metadata( upath,( isadir) ? ADFLAGS_DIR : 0, adp) < 0 ) { + if ( ad_metadata( upath, ((isadir) ? ADFLAGS_DIR : 0), adp) < 0 ) { return( AFPERR_NOITEM ); } @@ -852,7 +833,7 @@ static int ad_rmvcomment(struct vol *vol, struct path *path) char *upath; upath = path->u_name; - if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) { + if (check_access(upath, OPENACC_WR ) < 0) { return AFPERR_ACCESS; }