This patch makes libkarma work much better with fake test mounts that are
missing the smalldb or the fids0/ and var/ directories. I didn't get a
chance to see if this fixes the reported problems in Banshee.
(I hand-edited the patch, hope it still works).
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1174919566 14400
# Node ID 6ba9081a7f24f1dcc35792a9921b890b9b107858
# Parent 6eeaf9b5fe73faadb5958f012cc06b44c01e71e3
This patch adds more graceful handling for empty disks: create directories as
needed, don't check for smalldb in connect - only do that when doing mount
search. Also kill a couple of warnings and fix 'make install' when links
already exist.
diff -r 6eeaf9b5fe73 -r 6ba9081a7f24 src/Makefile
--- a/src/Makefile Mon Mar 26 08:42:32 2007 -0400
+++ b/src/Makefile Mon Mar 26 10:32:46 2007 -0400
@@ -42,10 +42,11 @@ install: shared-lib-stamp static-lib-sta
../install-sh -m 0755 -d $(DEST)/include/libkarma
../install-sh -m 0644 -t $(DEST)/lib/ $(LIBDIR)/$(TARGET).a
../install-sh -m 0755 -t $(PREFIX)/lib/ $(LIBDIR)/$(OUT_VERSION)
+ $(RM) $(PREFIX)/lib/$(OUT_MAJOR)
+ $(RM) $(PREFIX)/lib/$(OUT_BASE)
$(LN_S) $(OUT_VERSION) $(PREFIX)/lib/$(OUT_MAJOR)
$(LN_S) $(OUT_VERSION) $(PREFIX)/lib/$(OUT_BASE)
../install-sh -m 0644 -t $(DEST)/include/libkarma/ $(INST_HEADERS)
- ldconfig
uninstall:
$(RM) $(PREFIX)/lib/$(TARGET).a $(PREFIX)/lib/$(OUT_MAJOR)
$(PREFIX)/lib/$(OUT_BASE) $(PREFIX)/lib/$(OUT_VERSION)
diff -r 6eeaf9b5fe73 -r 6ba9081a7f24 src/karmaUsb.c
--- a/src/karmaUsb.c Mon Mar 26 08:42:32 2007 -0400
+++ b/src/karmaUsb.c Mon Mar 26 10:32:46 2007 -0400
@@ -82,9 +82,6 @@ int lk_karmaUsb_connect(char *path)
strcpy(usbMountPoint, path);
if(path[len - 1] != '/')
strcat(usbMountPoint, "/");
- ret = lk_is_karma_mountpoint(usbMountPoint);
- if (ret)
- return ret;
lk_karmaUsb_get_device_settings(0);
@@ -453,9 +450,14 @@ static int32_t read_properties(char **pr
strncpy(path1, usbMountPoint, 1023 - strlen("/fids0/_00000/100"));
strcat(path1, "/fids0/");
dp0 = opendir(path1);
- if(dp0 == NULL) {
- lk_errors_set(E_NODIR);
- return -1;
+ if(!dp0) {
+ mk_path(path1);
+ dp0 = opendir(path1);
+
+ if (!dp0) {
+ lk_errors_set(E_NODIR);
+ return -1;
+ }
}
while((de0 = readdir(dp0)) != NULL) {
if(strncmp(de0->d_name, "_0", 2) != 0)
@@ -828,21 +830,22 @@ int32_t lk_karmaUsb_write_file_chunk(int
char *path = NULL;
path = lk_karmaUsb_fidToPath(rio, file_id);
+
/*
if(offset==0)
fprintf(stderr, "--> %s %x %d\n", path, file_id, file_id);
*/
if((fd = open(path, O_WRONLY | O_CREAT, PERMS)) == EEXIST)
fd = open(path, O_WRONLY | O_TRUNC, PERMS);
- else if(fd == -1 && errno == ENOENT) {
- res = strlen(path);
- path[res - 4] = '\0';
- ret = mkdir(path, 0755);
- path[res - 4] = '/';
- if(!ret)
- if((fd = open(path, O_WRONLY | O_CREAT, PERMS)) == EEXIST)
- fd = open(path, O_WRONLY | O_TRUNC, PERMS);
- }
+
+ /* make sure the directory is there and try again */
+ if (fd == -1) {
+ mk_path(path);
+
+ if((fd = open(path, O_WRONLY | O_CREAT, PERMS)) == EEXIST)
+ fd = open(path, O_WRONLY | O_TRUNC, PERMS);
+ }
+
free(path);
/* fprintf(stderr, "---> %s\n", strerror(errno)); */
if(fd == -1) {
@@ -974,10 +977,8 @@ void lk_karmaUsb_load_database_smalldb(i
aux = read_properties_smalldb(&properties);
if(properties)
count = lk_properties_import(properties);
- else {
- lk_errors_set(E_FAILEDREQ);
- return;
- }
+ /* else just assume a new blank DB */
+
lk_fdb_load(1);
/* fprintf(stderr, "smalldb: %d Files\n", count); */
if(properties)
diff -r 6eeaf9b5fe73 -r 6ba9081a7f24 src/playlist.h
--- a/src/playlist.h Mon Mar 26 08:42:32 2007 -0400
+++ b/src/playlist.h Mon Mar 26 10:32:46 2007 -0400
@@ -18,7 +18,6 @@ unsigned int lk_playlist_unescape_inplac
unsigned int lk_playlist_unescape_inplace(char * str);
unsigned int lk_playlist_unescape (char * str, char ** data);
-playlist * lk_playlist_read (char * name);
int lk_playlist_delete (playlist * pl, int karma);
int lk_playlist_remove (playlist * pl, unsigned int n);
int lk_playlist_insert (playlist * pl, unsigned int n,
diff -r 6eeaf9b5fe73 -r 6ba9081a7f24 src/properties.c
--- a/src/properties.c Mon Mar 26 08:42:32 2007 -0400
+++ b/src/properties.c Mon Mar 26 10:32:46 2007 -0400
@@ -726,6 +726,10 @@ int lk_properties_write_smalldb(char *us
sprintf(tmp, "%s%s", usbMountPoint, RK_SMALLDB);
fp = fopen(tmp, "w+");
if (!fp) {
+ mk_path(tmp);
+ fp = fopen(tmp, "w+");
+ }
+ if (!fp) {
perror(tmp);
goto err;
}
diff -r 6eeaf9b5fe73 -r 6ba9081a7f24 tools/Makefile
--- a/tools/Makefile Mon Mar 26 08:42:32 2007 -0400
+++ b/tools/Makefile Mon Mar 26 10:32:46 2007 -0400
@@ -18,7 +18,7 @@ SRCS=pathedit.c
SRCS=pathedit.c
CC=gcc
-CFLAGS+=-Wall -pedantic
+CFLAGS+=-Wall -pedantic -g
LDFLAGS+=-ltag_c -lz -L $(LIBDIR)
OBJS=$(SRCS:.c=.o)
--
Bob Copeland %% www.bobcopeland.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel