Fossil SCM
Enable large-file support for stat() on linux. Fix the "stat" webpage to handle repositories larger than 2GB. Ticket [b1934313bcfb3a90d4027b]
Commit
31fdc347aceb975e9ebcd7687250326f3b52d5ec
Parent
293238031fb092c…
2 files changed
+10
+4
-3
+10
| --- src/config.h | ||
| +++ src/config.h | ||
| @@ -15,10 +15,20 @@ | ||
| 15 | 15 | ** |
| 16 | 16 | ******************************************************************************* |
| 17 | 17 | ** |
| 18 | 18 | ** A common header file used by all modules. |
| 19 | 19 | */ |
| 20 | + | |
| 21 | +/* The following macros are necessary for large-file support under | |
| 22 | +** some linux distributions, and possibly other unixes as well. | |
| 23 | +*/ | |
| 24 | +#define _LARGE_FILE 1 | |
| 25 | +#ifndef _FILE_OFFSET_BITS | |
| 26 | +# define _FILE_OFFSET_BITS 64 | |
| 27 | +#endif | |
| 28 | +#define _LARGEFILE_SOURCE 1 | |
| 29 | + | |
| 20 | 30 | |
| 21 | 31 | /* |
| 22 | 32 | ** System header files used by all modules |
| 23 | 33 | */ |
| 24 | 34 | #include <unistd.h> |
| 25 | 35 |
| --- src/config.h | |
| +++ src/config.h | |
| @@ -15,10 +15,20 @@ | |
| 15 | ** |
| 16 | ******************************************************************************* |
| 17 | ** |
| 18 | ** A common header file used by all modules. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | ** System header files used by all modules |
| 23 | */ |
| 24 | #include <unistd.h> |
| 25 |
| --- src/config.h | |
| +++ src/config.h | |
| @@ -15,10 +15,20 @@ | |
| 15 | ** |
| 16 | ******************************************************************************* |
| 17 | ** |
| 18 | ** A common header file used by all modules. |
| 19 | */ |
| 20 | |
| 21 | /* The following macros are necessary for large-file support under |
| 22 | ** some linux distributions, and possibly other unixes as well. |
| 23 | */ |
| 24 | #define _LARGE_FILE 1 |
| 25 | #ifndef _FILE_OFFSET_BITS |
| 26 | # define _FILE_OFFSET_BITS 64 |
| 27 | #endif |
| 28 | #define _LARGEFILE_SOURCE 1 |
| 29 | |
| 30 | |
| 31 | /* |
| 32 | ** System header files used by all modules |
| 33 | */ |
| 34 | #include <unistd.h> |
| 35 |
+4
-3
| --- src/stat.c | ||
| +++ src/stat.c | ||
| @@ -26,22 +26,23 @@ | ||
| 26 | 26 | ** WEBPAGE: stat |
| 27 | 27 | ** |
| 28 | 28 | ** Show statistics and global information about the repository. |
| 29 | 29 | */ |
| 30 | 30 | void stat_page(void){ |
| 31 | - i64 t; | |
| 32 | - int n, m, fsize; | |
| 31 | + i64 t, fsize; | |
| 32 | + int n, m; | |
| 33 | 33 | int szMax, szAvg; |
| 34 | 34 | char zBuf[100]; |
| 35 | 35 | |
| 36 | 36 | login_check_credentials(); |
| 37 | 37 | if( !g.okRead ){ login_needed(); return; } |
| 38 | 38 | style_header("Repository Statistics"); |
| 39 | 39 | @ <table class="label-value"> |
| 40 | 40 | @ <tr><th>Repository Size:</th><td> |
| 41 | 41 | fsize = file_size(g.zRepositoryName); |
| 42 | - @ %d(fsize) bytes | |
| 42 | + sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize); | |
| 43 | + @ %s(zBuf) bytes | |
| 43 | 44 | @ </td></tr> |
| 44 | 45 | @ <tr><th>Number Of Artifacts:</th><td> |
| 45 | 46 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 46 | 47 | m = db_int(0, "SELECT count(*) FROM delta"); |
| 47 | 48 | @ %d(n) (stored as %d(n-m) full text and %d(m) delta blobs) |
| 48 | 49 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -26,22 +26,23 @@ | |
| 26 | ** WEBPAGE: stat |
| 27 | ** |
| 28 | ** Show statistics and global information about the repository. |
| 29 | */ |
| 30 | void stat_page(void){ |
| 31 | i64 t; |
| 32 | int n, m, fsize; |
| 33 | int szMax, szAvg; |
| 34 | char zBuf[100]; |
| 35 | |
| 36 | login_check_credentials(); |
| 37 | if( !g.okRead ){ login_needed(); return; } |
| 38 | style_header("Repository Statistics"); |
| 39 | @ <table class="label-value"> |
| 40 | @ <tr><th>Repository Size:</th><td> |
| 41 | fsize = file_size(g.zRepositoryName); |
| 42 | @ %d(fsize) bytes |
| 43 | @ </td></tr> |
| 44 | @ <tr><th>Number Of Artifacts:</th><td> |
| 45 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 46 | m = db_int(0, "SELECT count(*) FROM delta"); |
| 47 | @ %d(n) (stored as %d(n-m) full text and %d(m) delta blobs) |
| 48 |
| --- src/stat.c | |
| +++ src/stat.c | |
| @@ -26,22 +26,23 @@ | |
| 26 | ** WEBPAGE: stat |
| 27 | ** |
| 28 | ** Show statistics and global information about the repository. |
| 29 | */ |
| 30 | void stat_page(void){ |
| 31 | i64 t, fsize; |
| 32 | int n, m; |
| 33 | int szMax, szAvg; |
| 34 | char zBuf[100]; |
| 35 | |
| 36 | login_check_credentials(); |
| 37 | if( !g.okRead ){ login_needed(); return; } |
| 38 | style_header("Repository Statistics"); |
| 39 | @ <table class="label-value"> |
| 40 | @ <tr><th>Repository Size:</th><td> |
| 41 | fsize = file_size(g.zRepositoryName); |
| 42 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize); |
| 43 | @ %s(zBuf) bytes |
| 44 | @ </td></tr> |
| 45 | @ <tr><th>Number Of Artifacts:</th><td> |
| 46 | n = db_int(0, "SELECT count(*) FROM blob"); |
| 47 | m = db_int(0, "SELECT count(*) FROM delta"); |
| 48 | @ %d(n) (stored as %d(n-m) full text and %d(m) delta blobs) |
| 49 |