2

I've mounted a Windows directory with CIFS :

sudo mount -t cifs //SERVER/Bases/some/path ~/mnt/data -o user=windomain/login%password

This works :

cp mnt/data/blabla/file.mdb .
/usr/bin/mdb-export file.mdb tablename

But this doesn't :

/usr/bin/mdb-export mnt/data/blabla/file.mdb tablename

It fails with output

Can't alloc filename

Why ? How can I execute mdb-export on a mounted file without having to copy it locally first ?

6
  • Could you edit your question and add the output of mount please?
    – Braiam
    Aug 30, 2013 at 17:06
  • There's no output from the mount command. And I can list or copy the mounted files. Aug 30, 2013 at 17:30
  • You sure you can't get this output? What's the output of ls mnt/data/blabla/file.mdb? BTW, did you notice that in the one that works you have .MDB (uppercase) and in the one that doesn't you have .mdb (lowercase)?
    – Braiam
    Aug 30, 2013 at 18:10
  • We really need the output from the command when it doesn't work. Not from the mount command, but from the mdb-export command. Aug 30, 2013 at 18:11
  • @Braiam I thougth you were speaking of the mount I had made. Sorry. As for the MDB vs mdb, it's just an error in the question (obviously the paths are changed). Aug 30, 2013 at 18:26

2 Answers 2

2

Not an answer, but too long for a comment.

This is where the error comes from:

mdb->f->filename = (char *) mdb_find_file(filename);
if (!mdb->f->filename) {.
    fprintf(stderr, "Can't alloc filename\n");

So let's see what mdb_find_file does...

Seeing the beginning of the function, this is probably what fails:

while (dir[i]) {
    if (!strlen(dir[i])) continue;
    tmpfname = g_strconcat(dir[i++], "/", file_name, NULL);
    if (!stat(tmpfname, &status)) {
        g_strfreev(dir);
        return tmpfname;
    }
    g_free(tmpfname);
}
g_strfreev(dir);
return NULL;

The function returns NULL, hence the fail later.

It looks like it's telling us that it can't find the filename.

Did you try using the full path? Did you try using the UNC path? Did you try using the smb:// path?

2
  • So... is a bug, or more like a quark in the source code... this are things that I don't like :/
    – Braiam
    Aug 31, 2013 at 1:45
  • I've looked at the code. As I don't have any MDBPATH env variable (I give the full path), the problem seems to be with stat(file_name, &status) which returns non 0. Is that normal for a CIFS mounted file ? Aug 31, 2013 at 7:53
2

A workaround is to change the mount command to add the noserverino,nounix options :

sudo mount -t cifs //SERVER/Bases/some/path ~/mnt/data -o user=windomain/login%password,noserverino,nounix

Florian pointed me to the right direction, that is the mdb_find_file function in the source code of the MDB tools :

static gchar *mdb_find_file(char *file_name)
{
    struct stat status;
    gchar *mdbpath, **dir, *tmpfname;
    unsigned int i = 0;

    /* try the provided file name first */
    if (!stat(file_name, &status)) {
        return g_strdup(file_name);
    }

    /* Now pull apart $MDBPATH and try those */
    mdbpath = (gchar *) getenv("MDBPATH");
    /* no path, can't find file */
    if (!mdbpath || !strlen(mdbpath)) return NULL;

    dir = g_strsplit(mdbpath, ":", 0); 
    while (dir[i]) {
        if (!strlen(dir[i])) continue;
        tmpfname = g_strconcat(dir[i++], "/", file_name, NULL);
        if (!stat(tmpfname, &status)) {
            g_strfreev(dir);
            return tmpfname;
        }
        g_free(tmpfname);
    }
    g_strfreev(dir);
    return NULL;
}

As I don't have any MDBPATH env var, it's obvious that there is an error in the stat call. I googled in that direction and got this :

http://www.linuxquestions.org/questions/programming-9/problem-with-stat-on-cifs-852983/

As I didn't try to recompile the MDB tools to get the error code, I'm not sure it's the same problem but adding the options that this thread suggested solved my problem, there's no more error when calling mdb-export.

3
  • Nice! Glad you could solve this. Aug 31, 2013 at 8:30
  • TBH it's hardly satisfying. I don't really have enough time to experiment right now but there are many questions remaining. I don't even know what's the error code returned by stat... Aug 31, 2013 at 8:39
  • 1
    You can ask another question then @dystroy also, you may like to report a bug in the package
    – Braiam
    Aug 31, 2013 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .