Fossil

Check-in [1b4403c771]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem in the Fuse Filesystem that caused incorrect processing of subdirectories whose names were a prefix of some sibling subdirectory.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1b4403c7711c0b6cbb0ac64381f2283250ef053b
User & Date: drh 2014-06-15 17:53:09.787
Context
2014-06-15
23:54
Treat the --repository (-R) option specially, caching its value in the global state. This is only strictly necessary when TH1 hooks are enabled at compile-time. ... (check-in: 912fce2be8 user: mistachkin tags: trunk)
17:53
Fix a problem in the Fuse Filesystem that caused incorrect processing of subdirectories whose names were a prefix of some sibling subdirectory. ... (check-in: 1b4403c771 user: drh tags: trunk)
17:25
Add a pair of "readme.txt" files under the "test" directory. Used for self-testing Fossil using its own repository. ... (check-in: 8d0623b996 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/fusefs.c.
120
121
122
123
124
125
126

127
128
129
130
131
132
133

/*
** Implementation of stat()
*/
static int fusefs_getattr(const char *zPath, struct stat *stbuf){
  int n, rid;
  ManifestFile *pFile;

  stbuf->st_uid = getuid();
  stbuf->st_gid = getgid();
  n = fusefs_parse_path(zPath);
  if( n==0 ){
    stbuf->st_mode = S_IFDIR | 0555;
    stbuf->st_nlink = 2;
    return 0;







>







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

/*
** Implementation of stat()
*/
static int fusefs_getattr(const char *zPath, struct stat *stbuf){
  int n, rid;
  ManifestFile *pFile;
  char *zDir;
  stbuf->st_uid = getuid();
  stbuf->st_gid = getgid();
  n = fusefs_parse_path(zPath);
  if( n==0 ){
    stbuf->st_mode = S_IFDIR | 0555;
    stbuf->st_nlink = 2;
    return 0;
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165




166
167
168
169
170
171
172
  if( n==2 ){
    stbuf->st_mode = S_IFDIR | 0555;
    stbuf->st_nlink = 2;
    return 0;
  }
  fusefs_load_rid(rid, fusefs.az[1]);
  if( fusefs.pMan==0 ) return -ENOENT;

  pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 1);
  if( pFile==0 ) return -ENOENT;
  stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
  if( strcmp(fusefs.az[2], pFile->zName)==0 ){
    static Stmt q;
    stbuf->st_mode = S_IFREG |
              (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
    stbuf->st_nlink = 1;
    db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
    db_bind_text(&q, "$uuid", pFile->zUuid);
    if( db_step(&q)==SQLITE_ROW ){
      stbuf->st_size = db_column_int(&q, 0);
    }
    db_reset(&q);
    return 0;
  }




  n = (int)strlen(fusefs.az[2]);
  if( strncmp(fusefs.az[2], pFile->zName, n)!=0 ) return -ENOENT;
  if( pFile->zName[n]!='/' ) return -ENOENT;
  stbuf->st_mode = S_IFDIR | 0555;
  stbuf->st_nlink = 2;
  return 0;
}







>
|
|
<
<












>
>
>
>







144
145
146
147
148
149
150
151
152
153


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
  if( n==2 ){
    stbuf->st_mode = S_IFDIR | 0555;
    stbuf->st_nlink = 2;
    return 0;
  }
  fusefs_load_rid(rid, fusefs.az[1]);
  if( fusefs.pMan==0 ) return -ENOENT;
  stbuf->st_mtime = (fusefs.pMan->rDate - 2440587.5)*86400.0;
  pFile = manifest_file_seek(fusefs.pMan, fusefs.az[2], 0);
  if( pFile ){


    static Stmt q;
    stbuf->st_mode = S_IFREG |
              (manifest_file_mperm(pFile)==PERM_EXE ? 0555 : 0444);
    stbuf->st_nlink = 1;
    db_static_prepare(&q, "SELECT size FROM blob WHERE uuid=$uuid");
    db_bind_text(&q, "$uuid", pFile->zUuid);
    if( db_step(&q)==SQLITE_ROW ){
      stbuf->st_size = db_column_int(&q, 0);
    }
    db_reset(&q);
    return 0;
  }
  zDir = mprintf("%s/", fusefs.az[2]);
  pFile = manifest_file_seek(fusefs.pMan, zDir, 1);
  fossil_free(zDir);
  if( pFile==0 ) return -ENOENT;
  n = (int)strlen(fusefs.az[2]);
  if( strncmp(fusefs.az[2], pFile->zName, n)!=0 ) return -ENOENT;
  if( pFile->zName[n]!='/' ) return -ENOENT;
  stbuf->st_mode = S_IFDIR | 0555;
  stbuf->st_nlink = 2;
  return 0;
}
Changes to src/manifest.c.
1258
1259
1260
1261
1262
1263
1264




1265
1266
1267
1268
1269
1270
1271
1272
    }else if( c>0 ){
      upr = i-1;
    }else{
      p->iFile = i;
      return &p->aFile[i];
    }
  }




  return bBest ? &p->aFile[lwr] : 0;
}

/*
** Locate a file named zName in the aFile[] array of the given manifest.
** Return a pointer to the appropriate ManifestFile object.  Return NULL
** if not found.
**







>
>
>
>
|







1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
    }else if( c>0 ){
      upr = i-1;
    }else{
      p->iFile = i;
      return &p->aFile[i];
    }
  }
  if( bBest ){
    i = (int)strlen(zName);
    if( strncmp(zName, p->aFile[lwr].zName, i)==0 ) return &p->aFile[lwr];
  }
  return 0;
}

/*
** Locate a file named zName in the aFile[] array of the given manifest.
** Return a pointer to the appropriate ManifestFile object.  Return NULL
** if not found.
**