Fossil SCM

In db_open_local() check writability of local-db itself in stead of the directory it is in. This should enable fossil checkouts on NFS-mounts, which sometimes lie about writability of directories.

jan.nijtmans 2013-03-06 10:16 trunk
Commit beb91c916348be092a87ed20ddc12f5c16fb6525
1 file changed +9 -9
+9 -9
--- src/db.c
+++ src/db.c
@@ -221,11 +221,11 @@
221221
** rolls back rather than commit. It is the responsibility of the
222222
** hooks themselves to issue any error messages.
223223
*/
224224
void db_commit_hook(int (*x)(void), int sequence){
225225
int i;
226
- assert( db.nCommitHook < sizeof(db.aHook)/sizeof(db.aHook[1]) );
226
+ assert( db.nCommitHook < count(db.aHook) );
227227
for(i=0; i<db.nCommitHook; i++){
228228
assert( x!=db.aHook[i].xHook );
229229
if( db.aHook[i].sequence>sequence ){
230230
int s = sequence;
231231
int (*xS)(void) = x;
@@ -920,32 +920,32 @@
920920
** that contains a valid repository database.
921921
**
922922
** For legacy, also look for ".fos". The use of ".fos" is deprecated
923923
** since "fos" has negative connotations in Hungarian, we are told.
924924
**
925
-** If no valid _FOSSIL_ or .fos file is found, we move up one level and
925
+** If no valid _FOSSIL_ or .fslckout file is found, we move up one level and
926926
** try again. Once the file is found, the g.zLocalRoot variable is set
927927
** to the root of the repository tree and this routine returns 1. If
928928
** no database is found, then this routine return 0.
929929
**
930930
** This routine always opens the user database regardless of whether or
931
-** not the repository database is found. If the _FOSSIL_ or .fos file
931
+** not the repository database is found. If the _FOSSIL_ or .fslckout file
932932
** is found, it is attached to the open database connection too.
933933
*/
934934
int db_open_local(void){
935935
int i, n;
936936
char zPwd[2000];
937
- static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
937
+ static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
938938
939939
if( g.localOpen) return 1;
940940
file_getcwd(zPwd, sizeof(zPwd)-20);
941941
n = strlen(zPwd);
942942
if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
943943
while( n>0 ){
944
- if( file_access(zPwd, W_OK) ) break;
945
- for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
946
- sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
944
+ for(i=0; i<count(aDbName); i++){
945
+ sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
946
+ if( file_access(zPwd, W_OK) ) continue;
947947
if( isValidLocalDb(zPwd) ){
948948
/* Found a valid checkout database file */
949949
zPwd[n] = 0;
950950
while( n>1 && zPwd[n-1]=='/' ){
951951
n--;
@@ -1628,19 +1628,19 @@
16281628
** Return true if the string zVal represents "true" (or "false").
16291629
*/
16301630
int is_truth(const char *zVal){
16311631
static const char *const azOn[] = { "on", "yes", "true", "1" };
16321632
int i;
1633
- for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
1633
+ for(i=0; i<count(azOn); i++){
16341634
if( fossil_stricmp(zVal,azOn[i])==0 ) return 1;
16351635
}
16361636
return 0;
16371637
}
16381638
int is_false(const char *zVal){
16391639
static const char *const azOff[] = { "off", "no", "false", "0" };
16401640
int i;
1641
- for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
1641
+ for(i=0; i<count(azOff); i++){
16421642
if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
16431643
}
16441644
return 0;
16451645
}
16461646
16471647
--- src/db.c
+++ src/db.c
@@ -221,11 +221,11 @@
221 ** rolls back rather than commit. It is the responsibility of the
222 ** hooks themselves to issue any error messages.
223 */
224 void db_commit_hook(int (*x)(void), int sequence){
225 int i;
226 assert( db.nCommitHook < sizeof(db.aHook)/sizeof(db.aHook[1]) );
227 for(i=0; i<db.nCommitHook; i++){
228 assert( x!=db.aHook[i].xHook );
229 if( db.aHook[i].sequence>sequence ){
230 int s = sequence;
231 int (*xS)(void) = x;
@@ -920,32 +920,32 @@
920 ** that contains a valid repository database.
921 **
922 ** For legacy, also look for ".fos". The use of ".fos" is deprecated
923 ** since "fos" has negative connotations in Hungarian, we are told.
924 **
925 ** If no valid _FOSSIL_ or .fos file is found, we move up one level and
926 ** try again. Once the file is found, the g.zLocalRoot variable is set
927 ** to the root of the repository tree and this routine returns 1. If
928 ** no database is found, then this routine return 0.
929 **
930 ** This routine always opens the user database regardless of whether or
931 ** not the repository database is found. If the _FOSSIL_ or .fos file
932 ** is found, it is attached to the open database connection too.
933 */
934 int db_open_local(void){
935 int i, n;
936 char zPwd[2000];
937 static const char *const aDbName[] = { "/_FOSSIL_", "/.fslckout", "/.fos" };
938
939 if( g.localOpen) return 1;
940 file_getcwd(zPwd, sizeof(zPwd)-20);
941 n = strlen(zPwd);
942 if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
943 while( n>0 ){
944 if( file_access(zPwd, W_OK) ) break;
945 for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
946 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
947 if( isValidLocalDb(zPwd) ){
948 /* Found a valid checkout database file */
949 zPwd[n] = 0;
950 while( n>1 && zPwd[n-1]=='/' ){
951 n--;
@@ -1628,19 +1628,19 @@
1628 ** Return true if the string zVal represents "true" (or "false").
1629 */
1630 int is_truth(const char *zVal){
1631 static const char *const azOn[] = { "on", "yes", "true", "1" };
1632 int i;
1633 for(i=0; i<sizeof(azOn)/sizeof(azOn[0]); i++){
1634 if( fossil_stricmp(zVal,azOn[i])==0 ) return 1;
1635 }
1636 return 0;
1637 }
1638 int is_false(const char *zVal){
1639 static const char *const azOff[] = { "off", "no", "false", "0" };
1640 int i;
1641 for(i=0; i<sizeof(azOff)/sizeof(azOff[0]); i++){
1642 if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
1643 }
1644 return 0;
1645 }
1646
1647
--- src/db.c
+++ src/db.c
@@ -221,11 +221,11 @@
221 ** rolls back rather than commit. It is the responsibility of the
222 ** hooks themselves to issue any error messages.
223 */
224 void db_commit_hook(int (*x)(void), int sequence){
225 int i;
226 assert( db.nCommitHook < count(db.aHook) );
227 for(i=0; i<db.nCommitHook; i++){
228 assert( x!=db.aHook[i].xHook );
229 if( db.aHook[i].sequence>sequence ){
230 int s = sequence;
231 int (*xS)(void) = x;
@@ -920,32 +920,32 @@
920 ** that contains a valid repository database.
921 **
922 ** For legacy, also look for ".fos". The use of ".fos" is deprecated
923 ** since "fos" has negative connotations in Hungarian, we are told.
924 **
925 ** If no valid _FOSSIL_ or .fslckout file is found, we move up one level and
926 ** try again. Once the file is found, the g.zLocalRoot variable is set
927 ** to the root of the repository tree and this routine returns 1. If
928 ** no database is found, then this routine return 0.
929 **
930 ** This routine always opens the user database regardless of whether or
931 ** not the repository database is found. If the _FOSSIL_ or .fslckout file
932 ** is found, it is attached to the open database connection too.
933 */
934 int db_open_local(void){
935 int i, n;
936 char zPwd[2000];
937 static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
938
939 if( g.localOpen) return 1;
940 file_getcwd(zPwd, sizeof(zPwd)-20);
941 n = strlen(zPwd);
942 if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
943 while( n>0 ){
944 for(i=0; i<count(aDbName); i++){
945 sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
946 if( file_access(zPwd, W_OK) ) continue;
947 if( isValidLocalDb(zPwd) ){
948 /* Found a valid checkout database file */
949 zPwd[n] = 0;
950 while( n>1 && zPwd[n-1]=='/' ){
951 n--;
@@ -1628,19 +1628,19 @@
1628 ** Return true if the string zVal represents "true" (or "false").
1629 */
1630 int is_truth(const char *zVal){
1631 static const char *const azOn[] = { "on", "yes", "true", "1" };
1632 int i;
1633 for(i=0; i<count(azOn); i++){
1634 if( fossil_stricmp(zVal,azOn[i])==0 ) return 1;
1635 }
1636 return 0;
1637 }
1638 int is_false(const char *zVal){
1639 static const char *const azOff[] = { "off", "no", "false", "0" };
1640 int i;
1641 for(i=0; i<count(azOff); i++){
1642 if( fossil_stricmp(zVal,azOff[i])==0 ) return 1;
1643 }
1644 return 0;
1645 }
1646
1647

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button