]> arthur.barton.de Git - netatalk.git/commitdiff
Remove empty adoubel rfork and use UNIX name in struct adouble
authorFrank Lahm <franklahm@googlemail.com>
Mon, 12 Mar 2012 14:34:40 +0000 (15:34 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 12 Mar 2012 14:34:40 +0000 (15:34 +0100)
etc/afpd/fce_api.c
etc/afpd/fork.c
etc/afpd/fork.h
etc/afpd/ofork.c
include/atalk/adouble.h
libatalk/adouble/ad_attr.c
libatalk/adouble/ad_lock.c

index 69458f08b490419648a9f1f27ff124173843b424..23991febd0b05dcde8c195abcf1751e8cd25230a 100644 (file)
@@ -513,24 +513,15 @@ int fce_register_new_file( struct path *path )
 
 int fce_register_file_modification( struct ofork *ofork )
 {
-    char *u_name = NULL;
-    struct vol *vol;
     int ret = AFP_OK;
 
-    if (ofork == NULL || ofork->of_vol == NULL)
+    if (ofork == NULL)
         return AFPERR_PARAM;
 
     if (!(fce_ev_enabled & (1 << FCE_FILE_MODIFY)))
         return ret;
 
-    vol = ofork->of_vol;
-
-    if (NULL == (u_name = mtoupath(vol, of_name(ofork), ofork->of_did, utf8_encoding(vol->v_obj)))) 
-    {
-        return AFPERR_MISC;
-    }
-    
-    ret = register_fce( u_name, false, FCE_FILE_MODIFY );
+    ret = register_fce(of_name(ofork), false, FCE_FILE_MODIFY );
     
     return ret;    
 }
index f0ccf0031d3058ddf6a51e32f258ddcc5fd5771c..9b41b956a0158ef3367617d0f150186f714a8bbb 100644 (file)
@@ -64,10 +64,10 @@ static int getforkparams(const AFPObj *obj, struct ofork *ofork, uint16_t bitmap
     vol = ofork->of_vol;
     dir = dirlookup(vol, ofork->of_did);
 
-    if (NULL == (path.u_name = mtoupath(vol, of_name(ofork), dir->d_did, utf8_encoding(obj)))) {
+    if (NULL == (path.m_name = utompath(vol, of_name(ofork), dir->d_did, utf8_encoding(obj)))) {
         return( AFPERR_MISC );
     }
-    path.m_name = of_name(ofork);
+    path.u_name = of_name(ofork);
     path.id = 0;
     st = &path.st;
     if ( bitmap & ( (1<<FILPBIT_DFLEN) | (1<<FILPBIT_EXTDFLEN) |
@@ -573,7 +573,15 @@ int afp_setforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf _U_, s
             ad_tmplock(ofork->of_ad, eid, ADLOCK_WR, size, st_size -size, ofork->of_refnum) < 0) {
             goto afp_setfork_err;
         }
-        err = ad_rtruncate(ofork->of_ad, size);
+        if (ofork->of_ad->ad_vers == AD_VERSION_EA) {
+#if HAVE_EAFD
+            err = sys_lremovexattr(of_name(ofork), AD_EA_RESO);
+#else
+            err = unlink(ofork->of_vol->ad_path(of_name(ofork), 0));
+#endif
+        } else {
+            err = ad_rtruncate(ofork->of_ad, size);
+        }
         if (st_size > size)
             ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, size, st_size -size, ofork->of_refnum);
         if (err < 0)
index b8a6d3a9719b17ddacd6bc8ef1c2f3b1a708b661..f586118067919322d084329ee7400e0e4dd72eb6 100644 (file)
@@ -26,7 +26,6 @@ struct ofork {
     uint16_t            of_refnum;
     int                 of_flags;
     struct ofork        **prevp, *next;
-//    struct ofork        *of_d_prev, *of_d_next;
 };
 
 #define OPENFORK_DATA   (0)
@@ -52,7 +51,7 @@ struct ofork {
 extern struct ofork *writtenfork;
 #endif
 
-#define of_name(a) (a)->of_ad->ad_m_name
+#define of_name(a) (a)->of_ad->ad_name
 /* in ofork.c */
 extern struct ofork *of_alloc    (struct vol *, struct dir *,
                                                       char *, uint16_t *, const int,
index 5fc6a1d5752285c08f82ec407711ddb64edbf0da..fc91c03b18fa51f44f48be121d1672a2e6f5ab84 100644 (file)
@@ -98,7 +98,9 @@ int of_rename(const struct vol *vol,
             && s_of->key.dev == of->key.dev
             && s_of->key.inode == of->key.inode ) {
             if (!done) {
-                strlcpy( of_name(of), newpath, of->of_ad->ad_m_namelen);
+                free(of_name(of));
+                if ((of_name(of) = strdup(newpath)) == NULL)
+                    return AFPERR_MISC;
                 done = 1;
             }
             if (newdir != olddir)
@@ -187,19 +189,13 @@ of_alloc(struct vol *vol,
         /* initialize to zero. This is important to ensure that
            ad_open really does reinitialize the structure. */
         ad_init(ad, vol);
-
-        ad->ad_m_namelen = UTF8FILELEN_EARLY +1;
-        /* here's the deal: we allocate enough for the standard mac file length.
-         * in the future, we'll reallocate in fairly large jumps in case
-         * of long unicode names */
-        if (( ad->ad_m_name =(char *)malloc( ad->ad_m_namelen )) == NULL ) {
+        if ((ad->ad_name = strdup(path)) == NULL) {
             LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) );
             free(ad);
             free(of);
             oforks[ of_refnum ] = NULL;
             return NULL;
         }
-        strlcpy( ad->ad_m_name, path, ad->ad_m_namelen);
     } else {
         /* Increase the refcount on this struct adouble. This is
            decremented again in oforc_dealloc. */
@@ -380,7 +376,7 @@ void of_dealloc( struct ofork *of)
     of->of_ad->ad_refcount--;
 
     if ( of->of_ad->ad_refcount <= 0) {
-        free( of->of_ad->ad_m_name );
+        free( of->of_ad->ad_name );
         free( of->of_ad);
     } else {/* someone's still using it. just free this user's locks */
         ad_unlock(of->of_ad, of->of_refnum, of->of_flags & AFPFORK_ERROR ? 0 : 1);
index cfc4302be4d3d5d122ef733ce56492bf66741dca..5b276a5a27a2e8255266eb5bbf810e3c0b19c2b8 100644 (file)
@@ -217,8 +217,7 @@ struct adouble {
     int                 ad_refcount;       /* multiple forks may open one adouble     */
     off_t               ad_rlen;           /* ressource fork len with AFP 3.0         *
                                             * the header parameter size is too small. */
-    char                *ad_m_name;        /* mac name for open fork                  */
-    int                 ad_m_namelen;
+    char                *ad_name;          /* name in server encoding (usually UTF8)  */
     struct adouble_fops *ad_ops;
     uint16_t            ad_open_forks;     /* open forks (by others)                  */
     char                ad_data[AD_DATASZ_MAX];
index bc089ac6bb255c48327a1bd3c919072bb7667356..e5fe323fd7814249cf21b412695a85f02739f3ae 100644 (file)
@@ -91,7 +91,6 @@ int ad_setid (struct adouble *adp, const dev_t dev, const ino_t ino , const uint
 {
     uint32_t tmp;
 
-    LOG(log_maxdebug, logtype_afpd, "ad_setid(\"%s\"): CNID: %" PRIu32 "", adp->ad_m_name, ntohl(id));
     ad_setentrylen( adp, ADEID_PRIVID, sizeof(id));
     tmp = id;
     if (adp->ad_vers == AD_VERSION_EA)
index b28304b9cb409445e02ca2f39cba5678e55915ca..bdae8dc473ad11c99fef7913c11a5503dde1cb7f 100644 (file)
@@ -362,8 +362,7 @@ int ad_lock(struct adouble *ad, uint32_t eid, int locktype, off_t off, off_t len
     int type;  
     int ret = 0, fcntl_lock_err = 0;
 
-    LOG(log_debug, logtype_default, "ad_lock(\"%s\", %s, %s, off: %jd (%s), len: %jd): BEGIN",
-        ad->ad_m_name ? ad->ad_m_name : "???",
+    LOG(log_debug, logtype_default, "ad_lock(%s, %s, off: %jd (%s), len: %jd): BEGIN",
         eid == ADEID_DFORK ? "data" : "reso",
         locktypetostr(locktype),
         (intmax_t)off,
@@ -509,8 +508,7 @@ int ad_tmplock(struct adouble *ad, uint32_t eid, int locktype, off_t off, off_t
     int err;
     int type;  
 
-    LOG(log_debug, logtype_default, "ad_tmplock(\"%s\", %s, %s, off: %jd (%s), len: %jd): BEGIN",
-        ad->ad_m_name ? ad->ad_m_name : "???",
+    LOG(log_debug, logtype_default, "ad_tmplock(%s, %s, off: %jd (%s), len: %jd): BEGIN",
         eid == ADEID_DFORK ? "data" : "reso",
         locktypetostr(locktype),
         (intmax_t)off,
@@ -574,8 +572,7 @@ exit:
 /* --------------------- */
 void ad_unlock(struct adouble *ad, const int fork, int unlckbrl)
 {
-    LOG(log_debug, logtype_default, "ad_unlock(\"%s\", unlckbrl: %d): BEGIN",
-        ad->ad_m_name ? ad->ad_m_name : "???", unlckbrl);
+    LOG(log_debug, logtype_default, "ad_unlock(unlckbrl: %d): BEGIN", unlckbrl);
 
     if (ad_data_fileno(ad) != -1) {
         adf_unlock(ad, &ad->ad_data_fork, fork, unlckbrl);
@@ -584,7 +581,7 @@ void ad_unlock(struct adouble *ad, const int fork, int unlckbrl)
         adf_unlock(ad, &ad->ad_resource_fork, fork, unlckbrl);
     }
 
-    LOG(log_debug, logtype_default, "ad_unlock(\"%s\"): END", ad->ad_m_name ? ad->ad_m_name : "???");
+    LOG(log_debug, logtype_default, "ad_unlock: END");
 }
 
 /*!
@@ -602,8 +599,7 @@ int ad_testlock(struct adouble *ad, int eid, const off_t off)
     int ret = 0;
     off_t lock_offset;
 
-    LOG(log_debug, logtype_default, "ad_testlock(\"%s\", %s, off: %jd (%s): BEGIN",
-        ad->ad_m_name ? ad->ad_m_name : "???",
+    LOG(log_debug, logtype_default, "ad_testlock(%s, off: %jd (%s): BEGIN",
         eid == ADEID_DFORK ? "data" : "reso",
         (intmax_t)off,
         shmdstrfromoff(off));