some more debug logging

This commit is contained in:
Ralf Haferkamp 2006-02-15 17:25:45 +00:00
parent 937bc5bbb7
commit 93d5e01390

View file

@ -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;