Listing 4. demo_opendir Function

static DIR *demo_opendir(vfs_handle_struct *handle,
                         const char *fname,
                         const char *mask,
                         uint32 attr)
{
    DIR *res;
    struct demo_struct *ctx;

    SMB_VFS_HANDLE_GET_DATA(handle,
                            ctx,
                            struct demo_struct,
                            return NULL);

    if (ctx->audit_path && strstr(fname, ctx->audit_path)) {
            struct cmd_struct *cmd;
            DEBUG(10, ("Found %s in the path %s\n",
                    ctx->audit_path, fname));

            cmd = create_cmd(ctx, LOG_LOG, fname);
            if (!cmd || !send_cmd(cmd)) {
                    DEBUG(1, ("Error logging. Continuing!\n"));
            }
    }

    /* Allow the next module to handle the OPENDIR as we are done */
    res = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
    return res;
}