[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r426 - GNUnet/src/applications/fs/module
From: |
grothoff |
Subject: |
[GNUnet-SVN] r426 - GNUnet/src/applications/fs/module |
Date: |
Sat, 12 Mar 2005 11:49:37 -0800 (PST) |
Author: grothoff
Date: 2005-03-12 11:49:34 -0800 (Sat, 12 Mar 2005)
New Revision: 426
Modified:
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/ondemand.c
Log:
Linux has no MAX_PATH
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2005-03-12 18:42:27 UTC (rev
425)
+++ GNUnet/src/applications/fs/module/fs.c 2005-03-12 19:49:34 UTC (rev
426)
@@ -382,11 +382,13 @@
ri = (RequestInitIndex *) req;
fnLen = ntohs(ri->header.size) - sizeof(RequestInitIndex);
+#if CYGWIN
if (fnLen > _MAX_PATH)
return SYSERR;
- fn = (char *) MALLOC(fnLen + 1);
- strncpy(fn, &ri[1], _MAX_PATH);
- fn[_MAX_PATH] = 0;
+#endif
+ fn = MALLOC(fnLen + 1);
+ strncpy(fn, (char*) &ri[1], fnLen+1);
+ fn[fnLen] = 0;
ret = ONDEMAND_initIndex(&ri->fileId,
fn);
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2005-03-12 18:42:27 UTC
(rev 425)
+++ GNUnet/src/applications/fs/module/ondemand.c 2005-03-12 19:49:34 UTC
(rev 426)
@@ -111,50 +111,48 @@
EncName enc;
char * serverDir;
char * serverFN;
- char unavail_key[_MAX_PATH + 1];
+ char unavail_key[256];
serverDir
- = getConfigurationString(
- "FS",
- "INDEX-DIRECTORY");
+ = getConfigurationString("FS",
+ "INDEX-DIRECTORY");
if (!serverDir) {
- serverDir = getConfigurationString(
- "",
- "GNUNETD_HOME");
+ serverDir = getConfigurationString("",
+ "GNUNETD_HOME");
if (!serverDir)
return SYSERR;
-
- serverDir = REALLOC(serverDir, strlen(serverDir) + 14);
+
+ serverDir = REALLOC(serverDir,
+ strlen(serverDir) +
+ strlen("/data/shared/") + 1);
strcat(serverDir, "/data/shared/");
}
serverFN = MALLOC(strlen(serverDir) + 2 + sizeof(EncName));
strcpy(serverFN,
- serverDir);
+ serverDir);
/* Just in case... */
mkdirp(serverDir);
FREE(serverDir);
strcat(serverFN,
- DIR_SEPARATOR_STR);
+ DIR_SEPARATOR_STR);
hash2enc(fileId,
- &enc);
+ &enc);
strcat(serverFN,
- (char*)&enc);
+ (char*)&enc);
if (0 != SYMLINK(fn, serverFN)) {
LOG_FILE_STRERROR(LOG_ERROR, "symlink", fn);
-
FREE(serverFN);
return SYSERR;
}
-
- strcpy(unavail_key, "FIRST_UNAVAILABLE-");
- strcat(unavail_key, (char*)&enc);
- stateUnlinkFromDB(unavail_key);
-
- FREE(serverFN);
-
+ SNPRINTF(unavail_key,
+ 256,
+ "FIRST_UNAVAILABLE-%s",
+ (char*)&enc);
+ stateUnlinkFromDB(unavail_key);
+ FREE(serverFN);
return YES;
}
@@ -265,7 +263,7 @@
fileHandle = OPEN(fn, O_RDONLY, 0);
#endif
if (fileHandle == -1) {
- char unavail_key[_MAX_PATH + 1];
+ char unavail_key[256];
EncName enc;
cron_t *first_unavail;
struct stat linkStat;
@@ -281,24 +279,37 @@
else {
/* For how long has the file been unavailable? */
hash2enc(&odb->fileId,
- &enc);
- strcpy(unavail_key, "FIRST_UNVAILABLE-");
- strcat(unavail_key, (char *) &enc);
- if (stateReadContent(unavail_key, (void *) &first_unavail) == SYSERR) {
+ &enc);
+ SNPRINTF(unavail_key,
+ 256,
+ "FIRST_UNVAILABLE-%s",
+ (char *) &enc);
+ if (stateReadContent(unavail_key,
+ (void *) &first_unavail) == SYSERR) {
unsigned long long now = htonll(cronTime(NULL));
stateWriteContent(unavail_key, sizeof(cron_t), (void *) &now);
- }
- else {
+ } else {
/* Delete it after 3 days */
- if (*first_unavail - cronTime(NULL) > 259200 * cronSECONDS) {
- char ofn[_MAX_PATH + 1];
-
- if (READLINK(fn, ofn, _MAX_PATH) != -1)
- LOG(LOG_ERROR, _("Because the file %s has been unavailable for 3
days"
- " it got removed from your share. Please unindex files before "
- " deleting them as the index now contains invalid references!"),
- ofn);
-
+ if (*first_unavail - cronTime(NULL) > 3 * cronDAYS) {
+ size_t len;
+ char * ofn;
+ int ret;
+
+ len = 256;
+ ofn = MALLOC(len);
+ while ( ((ret = READLINK(fn, ofn, len)) == -1) &&
+ (errno == ENAMETOOLONG) &&
+ (len < 4 * 1024 * 1024) )
+ GROW(ofn, len, len*2);
+
+ if (ret != -1) {
+ LOG(LOG_ERROR,
+ _("Because the file '%s' has been unavailable for 3 days"
+ " it got removed from your share. Please unindex files
before"
+ " deleting them as the index now contains invalid
references!"),
+ ofn);
+ }
+ FREE(ofn);
datastore->del(query, dbv);
stateUnlinkFromDB(unavail_key);
UNLINK(fn);
@@ -446,7 +457,7 @@
unsigned long long delta;
DBlock * block;
EncName enc;
- char unavail_key[_MAX_PATH + 1];
+ char unavail_key[256];
fn = getOnDemandFile(fileId);
LOG(LOG_DEBUG,
@@ -518,8 +529,10 @@
UNLINK(fn);
/* Remove information about unavailability */
- strcpy(unavail_key, "FIRST_UNAVAILABLE-");
- strcat(unavail_key, (char*)&enc);
+ SNPRINTF(unavail_key,
+ 256,
+ "FIRST_UNAVAILABLE-%s",
+ (char*)&enc);
stateUnlinkFromDB(unavail_key);
FREE(fn);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r426 - GNUnet/src/applications/fs/module,
grothoff <=