Fossil SCM

Fix a problem in the Fuse Filesystem that caused incorrect processing of subdirectories whose names were a prefix of some sibling subdirectory.

drh 2014-06-15 17:53 trunk
Commit 1b4403c7711c0b6cbb0ac64381f2283250ef053b
2 files changed +7 -3 +5 -1
+7 -3
--- src/fusefs.c
+++ src/fusefs.c
@@ -122,10 +122,11 @@
122122
** Implementation of stat()
123123
*/
124124
static int fusefs_getattr(const char *zPath, struct stat *stbuf){
125125
int n, rid;
126126
ManifestFile *pFile;
127
+ char *zDir;
127128
stbuf->st_uid = getuid();
128129
stbuf->st_gid = getgid();
129130
n = fusefs_parse_path(zPath);
130131
if( n==0 ){
131132
stbuf->st_mode = S_IFDIR | 0555;
@@ -145,14 +146,13 @@
145146
stbuf->st_nlink = 2;
146147
return 0;
147148
}
148149
fusefs_load_rid(rid, fusefs.az[1]);
149150
if( fusefs.pMan==0 ) return -ENOENT;
150
- pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 1);
151
- if( pFile==0 ) return -ENOENT;
152151
stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
153
- if( strcmp(fusefs.az[2], pFile->zName)==0 ){
152
+ pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0);
153
+ if( pFile ){
154154
static Stmt q;
155155
stbuf->st_mode = S_IFREG |
156156
(manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
157157
stbuf->st_nlink = 1;
158158
db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
@@ -161,10 +161,14 @@
161161
stbuf->st_size = db_column_int(&q, 0);
162162
}
163163
db_reset(&q);
164164
return 0;
165165
}
166
+ zDir = mprintf("%s/", fusefs.az[2]);
167
+ pFile = manifest_file_seek(fusefs.pMan, zDir, 1);
168
+ fossil_free(zDir);
169
+ if( pFile==0 ) return -ENOENT;
166170
n = (int)strlen(fusefs.az[2]);
167171
if( strncmp(fusefs.az[2], pFile->zName, n)!=0 ) return -ENOENT;
168172
if( pFile->zName[n]!='/' ) return -ENOENT;
169173
stbuf->st_mode = S_IFDIR | 0555;
170174
stbuf->st_nlink = 2;
171175
--- src/fusefs.c
+++ src/fusefs.c
@@ -122,10 +122,11 @@
122 ** Implementation of stat()
123 */
124 static int fusefs_getattr(const char *zPath, struct stat *stbuf){
125 int n, rid;
126 ManifestFile *pFile;
 
127 stbuf->st_uid = getuid();
128 stbuf->st_gid = getgid();
129 n = fusefs_parse_path(zPath);
130 if( n==0 ){
131 stbuf->st_mode = S_IFDIR | 0555;
@@ -145,14 +146,13 @@
145 stbuf->st_nlink = 2;
146 return 0;
147 }
148 fusefs_load_rid(rid, fusefs.az[1]);
149 if( fusefs.pMan==0 ) return -ENOENT;
150 pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 1);
151 if( pFile==0 ) return -ENOENT;
152 stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
153 if( strcmp(fusefs.az[2], pFile->zName)==0 ){
 
154 static Stmt q;
155 stbuf->st_mode = S_IFREG |
156 (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
157 stbuf->st_nlink = 1;
158 db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
@@ -161,10 +161,14 @@
161 stbuf->st_size = db_column_int(&q, 0);
162 }
163 db_reset(&q);
164 return 0;
165 }
 
 
 
 
166 n = (int)strlen(fusefs.az[2]);
167 if( strncmp(fusefs.az[2], pFile->zName, n)!=0 ) return -ENOENT;
168 if( pFile->zName[n]!='/' ) return -ENOENT;
169 stbuf->st_mode = S_IFDIR | 0555;
170 stbuf->st_nlink = 2;
171
--- src/fusefs.c
+++ src/fusefs.c
@@ -122,10 +122,11 @@
122 ** Implementation of stat()
123 */
124 static int fusefs_getattr(const char *zPath, struct stat *stbuf){
125 int n, rid;
126 ManifestFile *pFile;
127 char *zDir;
128 stbuf->st_uid = getuid();
129 stbuf->st_gid = getgid();
130 n = fusefs_parse_path(zPath);
131 if( n==0 ){
132 stbuf->st_mode = S_IFDIR | 0555;
@@ -145,14 +146,13 @@
146 stbuf->st_nlink = 2;
147 return 0;
148 }
149 fusefs_load_rid(rid, fusefs.az[1]);
150 if( fusefs.pMan==0 ) return -ENOENT;
 
 
151 stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
152 pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0);
153 if( pFile ){
154 static Stmt q;
155 stbuf->st_mode = S_IFREG |
156 (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
157 stbuf->st_nlink = 1;
158 db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
@@ -161,10 +161,14 @@
161 stbuf->st_size = db_column_int(&q, 0);
162 }
163 db_reset(&q);
164 return 0;
165 }
166 zDir = mprintf("%s/", fusefs.az[2]);
167 pFile = manifest_file_seek(fusefs.pMan, zDir, 1);
168 fossil_free(zDir);
169 if( pFile==0 ) return -ENOENT;
170 n = (int)strlen(fusefs.az[2]);
171 if( strncmp(fusefs.az[2], pFile->zName, n)!=0 ) return -ENOENT;
172 if( pFile->zName[n]!='/' ) return -ENOENT;
173 stbuf->st_mode = S_IFDIR | 0555;
174 stbuf->st_nlink = 2;
175
+5 -1
--- src/manifest.c
+++ src/manifest.c
@@ -1260,11 +1260,15 @@
12601260
}else{
12611261
p->iFile = i;
12621262
return &p->aFile[i];
12631263
}
12641264
}
1265
- return bBest ? &p->aFile[lwr] : 0;
1265
+ if( bBest ){
1266
+ i = (int)strlen(zName);
1267
+ if( strncmp(zName, p->aFile[lwr].zName, i)==0 ) return &p->aFile[lwr];
1268
+ }
1269
+ return 0;
12661270
}
12671271
12681272
/*
12691273
** Locate a file named zName in the aFile[] array of the given manifest.
12701274
** Return a pointer to the appropriate ManifestFile object. Return NULL
12711275
--- src/manifest.c
+++ src/manifest.c
@@ -1260,11 +1260,15 @@
1260 }else{
1261 p->iFile = i;
1262 return &p->aFile[i];
1263 }
1264 }
1265 return bBest ? &p->aFile[lwr] : 0;
 
 
 
 
1266 }
1267
1268 /*
1269 ** Locate a file named zName in the aFile[] array of the given manifest.
1270 ** Return a pointer to the appropriate ManifestFile object. Return NULL
1271
--- src/manifest.c
+++ src/manifest.c
@@ -1260,11 +1260,15 @@
1260 }else{
1261 p->iFile = i;
1262 return &p->aFile[i];
1263 }
1264 }
1265 if( bBest ){
1266 i = (int)strlen(zName);
1267 if( strncmp(zName, p->aFile[lwr].zName, i)==0 ) return &p->aFile[lwr];
1268 }
1269 return 0;
1270 }
1271
1272 /*
1273 ** Locate a file named zName in the aFile[] array of the given manifest.
1274 ** Return a pointer to the appropriate ManifestFile object. Return NULL
1275

Keyboard Shortcuts

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