From 93d5e01390d334e2173d33932a76287959a745aa Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Wed, 15 Feb 2006 17:25:45 +0000 Subject: [PATCH] some more debug logging --- servers/slapd/back-ldif/ldif.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/servers/slapd/back-ldif/ldif.c b/servers/slapd/back-ldif/ldif.c index 8293c52fa1..ba40fba235 100644 --- a/servers/slapd/back-ldif/ldif.c +++ b/servers/slapd/back-ldif/ldif.c @@ -175,6 +175,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; @@ -299,8 +301,8 @@ static int r_enum_tree(enumCookie *ck, struct berval *path, fd = open( path->bv_val, O_RDONLY ); if ( fd < 0 ) { Debug( LDAP_DEBUG_ANY, - "=> ldif_enum_tree: failed to open %s\n", - path->bv_val, 0, 0 ); + "=> ldif_enum_tree: failed to open %s: %s\n", + path->bv_val, strerror(errno), 0 ); return LDAP_NO_SUCH_OBJECT; } @@ -769,6 +771,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, @@ -791,11 +794,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 @@ -808,6 +815,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; } @@ -818,6 +830,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; -- 2.39.5