Fossil SCM

Improve comments on symlink logic

drh 2020-08-21 10:10 sec2020
Commit 39a5df1fde741d084db2b4f900ada78adad62e350258034a3f60e8baaae0b13d
1 file changed +17 -14
+17 -14
--- src/file.c
+++ src/file.c
@@ -47,22 +47,21 @@
4747
** used for files that are under management by a Fossil repository. ExtFILE
4848
** should be used for files that are not under management. SymFILE is for
4949
** a few special cases such as the "fossil test-tarball" command when we never
5050
** want to follow symlinks.
5151
**
52
-** If RepoFILE is used and if the allow-symlinks setting is true and if
53
-** the object is a symbolic link, then the object is treated like an ordinary
54
-** file whose content is name of the object to which the symbolic link
55
-** points.
56
-**
57
-** If ExtFILE is used or allow-symlinks is false, then operations on a
58
-** symbolic link are the same as operations on the object to which the
59
-** symbolic link points.
60
-**
61
-** SymFILE is like RepoFILE except that it always uses the target filename of
62
-** a symbolic link as the content, instead of the content of the object
63
-** that the symlink points to. SymFILE acts as if allow-symlinks is always ON.
52
+** ExtFILE Symbolic links always refer to the object to which the
53
+** link points. Symlinks are never recognized as symlinks but
54
+** instead always appear to the the target object.
55
+**
56
+** SymFILE Symbolic links always appear to be files whose name is
57
+** the target pathname of the symbolic link.
58
+**
59
+** RepoFILE Like symfile is allow-symlinks is true, or like
60
+** ExtFile if allow-symlinks is false. In other words,
61
+** symbolic links are only recognized as something different
62
+** from files or directories if allow-symlinks is true.
6463
*/
6564
#define ExtFILE 0 /* Always follow symlinks */
6665
#define RepoFILE 1 /* Follow symlinks if and only if allow-symlinks is OFF */
6766
#define SymFILE 2 /* Never follow symlinks */
6867
@@ -134,13 +133,16 @@
134133
int eFType /* Look at symlink itself if RepoFILE and enabled. */
135134
){
136135
int rc;
137136
void *zMbcs = fossil_utf8_to_path(zFilename, 0);
138137
#if !defined(_WIN32)
139
- if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){
138
+ if( (eFType=RepoFILE && db_allow_symlinks())
139
+ || eFType==SymFILE ){
140
+ /* Symlinks look like files whose content is the name of the target */
140141
rc = lstat(zMbcs, buf);
141142
}else{
143
+ /* Symlinks look like the object to which they point */
142144
rc = stat(zMbcs, buf);
143145
}
144146
#else
145147
rc = win32_stat(zMbcs, buf, eFType);
146148
#endif
@@ -316,11 +318,12 @@
316318
317319
/*
318320
** Return TRUE if the named file is a symlink and symlinks are allowed.
319321
** Return false for all other cases.
320322
**
321
-** This routines RepoFILE - that zFilename is always a file under management.
323
+** This routines assumes RepoFILE - that zFilename is always a file
324
+** under management.
322325
**
323326
** On Windows, always return False.
324327
*/
325328
int file_islink(const char *zFilename){
326329
return file_perm(zFilename, RepoFILE)==PERM_LNK;
327330
--- src/file.c
+++ src/file.c
@@ -47,22 +47,21 @@
47 ** used for files that are under management by a Fossil repository. ExtFILE
48 ** should be used for files that are not under management. SymFILE is for
49 ** a few special cases such as the "fossil test-tarball" command when we never
50 ** want to follow symlinks.
51 **
52 ** If RepoFILE is used and if the allow-symlinks setting is true and if
53 ** the object is a symbolic link, then the object is treated like an ordinary
54 ** file whose content is name of the object to which the symbolic link
55 ** points.
56 **
57 ** If ExtFILE is used or allow-symlinks is false, then operations on a
58 ** symbolic link are the same as operations on the object to which the
59 ** symbolic link points.
60 **
61 ** SymFILE is like RepoFILE except that it always uses the target filename of
62 ** a symbolic link as the content, instead of the content of the object
63 ** that the symlink points to. SymFILE acts as if allow-symlinks is always ON.
64 */
65 #define ExtFILE 0 /* Always follow symlinks */
66 #define RepoFILE 1 /* Follow symlinks if and only if allow-symlinks is OFF */
67 #define SymFILE 2 /* Never follow symlinks */
68
@@ -134,13 +133,16 @@
134 int eFType /* Look at symlink itself if RepoFILE and enabled. */
135 ){
136 int rc;
137 void *zMbcs = fossil_utf8_to_path(zFilename, 0);
138 #if !defined(_WIN32)
139 if( eFType>=RepoFILE && (eFType==SymFILE || db_allow_symlinks()) ){
 
 
140 rc = lstat(zMbcs, buf);
141 }else{
 
142 rc = stat(zMbcs, buf);
143 }
144 #else
145 rc = win32_stat(zMbcs, buf, eFType);
146 #endif
@@ -316,11 +318,12 @@
316
317 /*
318 ** Return TRUE if the named file is a symlink and symlinks are allowed.
319 ** Return false for all other cases.
320 **
321 ** This routines RepoFILE - that zFilename is always a file under management.
 
322 **
323 ** On Windows, always return False.
324 */
325 int file_islink(const char *zFilename){
326 return file_perm(zFilename, RepoFILE)==PERM_LNK;
327
--- src/file.c
+++ src/file.c
@@ -47,22 +47,21 @@
47 ** used for files that are under management by a Fossil repository. ExtFILE
48 ** should be used for files that are not under management. SymFILE is for
49 ** a few special cases such as the "fossil test-tarball" command when we never
50 ** want to follow symlinks.
51 **
52 ** ExtFILE Symbolic links always refer to the object to which the
53 ** link points. Symlinks are never recognized as symlinks but
54 ** instead always appear to the the target object.
55 **
56 ** SymFILE Symbolic links always appear to be files whose name is
57 ** the target pathname of the symbolic link.
58 **
59 ** RepoFILE Like symfile is allow-symlinks is true, or like
60 ** ExtFile if allow-symlinks is false. In other words,
61 ** symbolic links are only recognized as something different
62 ** from files or directories if allow-symlinks is true.
 
63 */
64 #define ExtFILE 0 /* Always follow symlinks */
65 #define RepoFILE 1 /* Follow symlinks if and only if allow-symlinks is OFF */
66 #define SymFILE 2 /* Never follow symlinks */
67
@@ -134,13 +133,16 @@
133 int eFType /* Look at symlink itself if RepoFILE and enabled. */
134 ){
135 int rc;
136 void *zMbcs = fossil_utf8_to_path(zFilename, 0);
137 #if !defined(_WIN32)
138 if( (eFType=RepoFILE && db_allow_symlinks())
139 || eFType==SymFILE ){
140 /* Symlinks look like files whose content is the name of the target */
141 rc = lstat(zMbcs, buf);
142 }else{
143 /* Symlinks look like the object to which they point */
144 rc = stat(zMbcs, buf);
145 }
146 #else
147 rc = win32_stat(zMbcs, buf, eFType);
148 #endif
@@ -316,11 +318,12 @@
318
319 /*
320 ** Return TRUE if the named file is a symlink and symlinks are allowed.
321 ** Return false for all other cases.
322 **
323 ** This routines assumes RepoFILE - that zFilename is always a file
324 ** under management.
325 **
326 ** On Windows, always return False.
327 */
328 int file_islink(const char *zFilename){
329 return file_perm(zFilename, RepoFILE)==PERM_LNK;
330

Keyboard Shortcuts

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