On Sun, Aug 20, 2006, EV wrote:
> If you have the computer info in the path DB then you can ignore
> it for downloading, in the same way as we will surely allow, in
> fdb-based downlading, to strip the some prefix of the paths.
> Therefore, this only adds flexibility and costs almost nothing.
> If the computer info is not stored, then there is no way for
> figuring out where the tunes came from originally.
Okay. I guess it doesn't hurt. The attached patch implements this.
> Don't understand. How do you use the new fdb functionality for
> this purpose?
riocp -U fdb.gz
All you have to do is make a backup of the DB file. It can then be
restored from this backup as shown above.
Currently it only performs the uploads. If people wish, I could
add an option to delete files not contained in the DB file so that
the device is returned to the exact state it was in when the DB
file was last modified.
Keith.
# HG changeset patch
# User Keith Bennett <[EMAIL PROTECTED]>
# Node ID b7e84dceaff4775a37a922ca854f33ae7e560b35
# Parent a30b37fd81dd97aa1a1ffa5f587ef795e6921399
Added hostname to the fdb file.
Added option to only download files which originated
from the current hostname.
More bugfixes.
diff -r a30b37fd81dd -r b7e84dceaff4 src/fdb.c
--- a/src/fdb.c Sun Aug 20 18:09:22 2006
+++ b/src/fdb.c Sun Aug 20 23:23:18 2006
@@ -16,8 +16,6 @@
#include "util.h"
#include "rio_rw.h"
#include "fdb.h"
-
-#define FDB_FILENAME "__libkarma_fdb__.gz"
static int rio = 0;
@@ -47,6 +45,7 @@
if (db) {
db=lk_properties_andOrSearch(EXACT|ORS, db, "type", "taxi");
if (db) {
+ unlink(fname);
lk_rio_read(rio, *db, fname);
free(db);
}
@@ -143,11 +142,11 @@
uint32_t * fdb;
HASH * tmp;
int i=0, first=1;
-
+
fname=lk_path_string(FDB_FILENAME);
fdb_file=gzopen(fname, "w");
if (fdb_file == NULL)
- return NULL;
+ return -1;
fdb=lk_properties_andOrSearch(EXACT|ORS, NULL, "path", "");
if(fdb){
diff -r a30b37fd81dd -r b7e84dceaff4 src/lkarma.h
--- a/src/lkarma.h Sun Aug 20 18:09:22 2006
+++ b/src/lkarma.h Sun Aug 20 23:23:18 2006
@@ -16,6 +16,8 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+#define FDB_FILENAME "__libkarma_fdb__.gz"
/*
* karma
diff -r a30b37fd81dd -r b7e84dceaff4 src/rio_rw.c
--- a/src/rio_rw.c Sun Aug 20 18:09:22 2006
+++ b/src/rio_rw.c Sun Aug 20 23:23:18 2006
@@ -231,12 +231,12 @@
*/
static uint32_t lk_rio_do_write(int fdb, int rio, const char * filename)
{
- int got, fd;
+ int got, fd, len;
uint32_t fid = 0;
uint64_t offs=0;
char *p, tmp[BLOCKSIZE];
const uint64_t siz=BLOCKSIZE;
- char *path, fullpath[PATH_MAX];
+ char *path, fullpath[257+PATH_MAX];
uint32_t *ids;
fd=open(filename, O_RDONLY);
@@ -244,7 +244,7 @@
return -1;
if (fdb) {
- ids = lk_properties_andOrSearch(EXACT|ORS, NULL, "title", "fdb.gz");
+ ids = lk_properties_andOrSearch(EXACT|ORS, NULL, "title",
FDB_FILENAME);
if (ids) {
ids = lk_properties_andOrSearch(EXACT|ANDS, ids, "type", "taxi");
if (ids) {
@@ -283,8 +283,12 @@
close(fd);
if (!fdb) {
- path = realpath(filename, fullpath);
- lk_properties_set_property(fid, "path", path);
+ if (gethostname(fullpath, 255) != 0) fullpath[0] = '\0';
+ len = strlen(fullpath);
+ fullpath[len] = ' ';
+ path = realpath(filename, fullpath+len+1);
+ if (path)
+ lk_properties_set_property(fid, "path", fullpath);
}
p=lk_properties_export(fid);
diff -r a30b37fd81dd -r b7e84dceaff4 tools/riocp.c
--- a/tools/riocp.c Sun Aug 20 18:09:22 2006
+++ b/tools/riocp.c Sun Aug 20 23:23:18 2006
@@ -15,6 +15,7 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
+#include <limits.h>
#ifdef LINUX
#include <ftw.h>
#else
@@ -58,7 +59,7 @@
" [-u props] [-x props] [-l props] "
"[-c charSet] [-e set1 set2 set3]\n"
" [-D dummyName] [-q] [-d] [-r] [-R] [-b] [-w] [-f]\n"
- " [-F] [-U fdb.gz] [files_to_upload ...]\n"
+ " [-F] [-H] [-U fdb.gz] [files_to_upload ...]\n"
"\n");
if(!complete) return;
printf(" \"-s\" AND/OR-search karma DB according to a \"searchString\";\n"
@@ -97,7 +98,10 @@
printf(" \"-b\" get database by scanning *1 files, instead of smalldb\n");
printf(" \"-w\" don't rewrite the smalldb database file\n");
printf(" \"-f\" force the files to be written even if they are dupes\n");
- printf(" \"-F\" Use filenames in ~/.openrio/.../fdb.gz for download\n");
+ printf(" \"-F\" Use filenames in ~/.openrio/.../" FDB_FILENAME
+ " for download\n");
+ printf(" \"-H\" Download files listed in ~/.openrio/.../" FDB_FILENAME
+ "\n that match the current hostname\n");
printf(" \"-U\" Upload files listed in the given fdb.gz file\n");
}
@@ -110,24 +114,38 @@
*k=karma;
}
-void fdb_download(void)
-{
- int karma, i;
+static void fdb_download(int checkhost)
+{
+ int karma, i, len;
uint32_t * fdb;
- char * filename;
+ char * filename, * p;
+ char ourhostname[255], hostname[255], path[PATH_MAX];
currentKarma(0, &karma);
fdb=lk_properties_andOrSearch(EXACT|ORS, NULL, "path", "");
if (!fdb)
return;
+ if (checkhost) {
+ if (gethostname(ourhostname, 255) != 0) ourhostname[0] = '\0';
+ len = strlen(ourhostname) + 1;
+ }
+
for (i=0; fdb[i]; i++) {
filename=lk_properties_get_property(fdb[i], "path");
if (!filename)
continue;
- printf("Downloading fid %i to %s\n", fdb[i], filename);
+ memcpy(hostname, filename, 255);
+ for (p=hostname; *p != '\0'; p++)
+ if (*p == ' ')
+ break;
+ *p = '\0';
+ if (checkhost && memcmp(hostname, ourhostname, len) != 0)
+ continue;
+ memcpy(path, p+1, PATH_MAX);
+ printf("Downloading fid %i to %s\n", fdb[i], path);
fprintf(stderr, "lk_rio_read %s\n",
- CHECK(lk_rio_read(karma, fdb[i], filename)));
+ CHECK(lk_rio_read(karma, fdb[i], path)));
}
free(fdb);
}
@@ -413,6 +431,7 @@
int exact=0;
int useSmalldb=1;
int writeSmalldb=1;
+ int checkHost=0;
int ret=0;
char yesNot='N';
int karma;
@@ -423,7 +442,7 @@
char *device=NULL;
char *fdb=NULL;
- while ((c = getopt(argc, argv, "dhqrRbwfFa:c:e:p:s:S:u:x:l:D:U:")) != -1) {
+ while ((c = getopt(argc, argv, "dhqrRbwfFHa:c:e:p:s:S:u:x:l:D:U:")) != -1)
{
switch(c) {
case 'h': case '?':
usage(1);
@@ -449,6 +468,11 @@
break;
case 'F':
fdbDownload=1;
+ checkHost=0;
+ break;
+ case 'H':
+ fdbDownload=1;
+ checkHost=1;
break;
case 'a':
host=strdup(optarg);
@@ -603,7 +627,7 @@
if(dbChanged) printf("Done!\n");
if(fdbDownload)
- fdb_download();
+ fdb_download(checkHost);
if (searchString != NULL){
utf=utf8_from_codeset(searchString);
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel