]> git.sur5r.net Git - openldap/commitdiff
sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Wed, 15 Feb 2006 22:32:26 +0000 (22:32 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 15 Feb 2006 22:32:26 +0000 (22:32 +0000)
servers/slapd/back-ldif/ldif.c

index cdedc858683910decfe8eb909c23357b30a172d3..568aae2f978d2919ce1e698d113c6eb470dd4cd4 100644 (file)
@@ -174,6 +174,8 @@ static int spew_entry(Entry * e, struct berval * path) {
                        rs = LDAP_NO_SUCH_OBJECT;
                else
                        rs = LDAP_UNWILLING_TO_PERFORM;
+               Debug( LDAP_DEBUG_ANY, "could not open \"%s\": %s\n",
+                       path->bv_val, strerror( errno ), 0 );
        }
        else {
                struct berval rdn;
@@ -296,9 +298,9 @@ static int r_enum_tree(enumCookie *ck, struct berval *path,
 
        fd = open( path->bv_val, O_RDONLY );
        if ( fd < 0 ) {
-               Debug( LDAP_DEBUG_TRACE,
-                       "=> ldif_enum_tree: failed to open %s\n",
-                       path->bv_val, 0, 0 );
+               Debug( LDAP_DEBUG_ANY,
+                       "=> ldif_enum_tree: failed to open %s: %s\n",
+                       path->bv_val, strerror(errno), 0 );
                return LDAP_NO_SUCH_OBJECT;
        }
 
@@ -767,6 +769,7 @@ static int ldif_back_add(Operation *op, SlapReply *rs) {
        int statres;
        char textbuf[SLAP_TEXT_BUFLEN];
 
+       Debug( LDAP_DEBUG_TRACE, "ldif_back_add: \"%s\"\n", dn.bv_val, 0, 0);
        slap_add_opattrs( op, &rs->sr_text, textbuf, sizeof( textbuf ), 1 );
 
        rs->sr_err = entry_schema_check(op, e, NULL, 0,
@@ -789,11 +792,15 @@ static int ldif_back_add(Operation *op, SlapReply *rs) {
                        base.bv_val[base.bv_len] = '\0';
                        if(statres == -1 && errno == ENOENT) {
                                rs->sr_err = LDAP_NO_SUCH_OBJECT; /* parent doesn't exist */
+                               rs->sr_text = "Parent does not exist";
                        }
                        else if(statres != -1) { /* create parent */
                                int mkdirres = mkdir(base.bv_val, 0750);
                                if(mkdirres == -1) {
                                        rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                                       rs->sr_text = "Could not create parent folder";
+                                       Debug( LDAP_DEBUG_ANY, "could not create folder \"%s\": %s\n",
+                                               base.bv_val, strerror( errno ), 0 );
                                }
                        }
                        else
@@ -806,6 +813,11 @@ static int ldif_back_add(Operation *op, SlapReply *rs) {
                                rs->sr_err = (int) spew_entry(e, &leaf_path);
                                ldap_pvt_thread_mutex_unlock(&entry2str_mutex);
                        }
+                       else if ( statres == -1 ) {
+                               rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+                               Debug( LDAP_DEBUG_ANY, "could not stat file \"%s\": %s\n",
+                                       leaf_path.bv_val, strerror( errno ), 0 );
+                       }
                        else /* it already exists */
                                rs->sr_err = LDAP_ALREADY_EXISTS;
                }
@@ -816,6 +828,8 @@ static int ldif_back_add(Operation *op, SlapReply *rs) {
        ldap_pvt_thread_mutex_unlock(&ni->li_mutex);
 
 send_res:
+       Debug( LDAP_DEBUG_TRACE, 
+                       "ldif_back_add: err: %d text: %s\n", rs->sr_err, rs->sr_text, 0);
        send_ldap_result(op, rs);
        slap_graduate_commit_csn( op );
        return 0;