+ if (chdir(dir) != 0)
+ err(1, "Failed to chdir to %s", dir);
+
+ m->dir = talloc_getcwd(m);
+ if (!m->dir)
+ err(1, "Getting current directory");
+
+ len = strlen(m->dir);
+ while (len && m->dir[len-1] == '/')
+ m->dir[--len] = '\0';
+
+ m->basename = strrchr(m->dir, '/');