139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
unsigned long long inode;
union {
struct {
int childcount;
} dir;
struct {
int executable;
off_t size;
} file;
struct {
off_t size;
char source[256];
} symlink;
} typeinfo;
|
>
>
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
unsigned long long inode;
union {
struct {
int childcount;
} dir;
struct {
int executable;
int suid;
int worldaccessible;
off_t size;
} file;
struct {
off_t size;
char source[256];
} symlink;
} typeinfo;
|
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
|
return;
}
/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
Tcl_Interp *interp;
Tcl_Obj *attrs_dict, *attr_value;
const char *attr_value_str;
Tcl_WideInt attr_value_wide;
int attr_value_int;
static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL, *attr_key_packaged = NULL;
int cache_ret;
int tcl_ret;
int retval;
uid_t fsuid;
|
|
|
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
|
return;
}
/* Get information about a path, and optionally list children */
static int appfs_get_path_info(const char *path, struct appfs_pathinfo *pathinfo) {
Tcl_Interp *interp;
Tcl_Obj *attrs_dict, *attr_value;
const char *attr_value_str, *attr_value_str_i;
Tcl_WideInt attr_value_wide;
int attr_value_int;
static __thread Tcl_Obj *attr_key_type = NULL, *attr_key_perms = NULL, *attr_key_size = NULL, *attr_key_time = NULL, *attr_key_source = NULL, *attr_key_childcount = NULL, *attr_key_packaged = NULL;
int cache_ret;
int tcl_ret;
int retval;
uid_t fsuid;
|
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
|
}
break;
case 'f': /* file */
pathinfo->type = APPFS_PATHTYPE_FILE;
pathinfo->typeinfo.file.size = 0;
pathinfo->typeinfo.file.executable = 0;
Tcl_DictObjGet(interp, attrs_dict, attr_key_size, &attr_value);
if (attr_value != NULL) {
tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
if (tcl_ret == TCL_OK) {
pathinfo->typeinfo.file.size = attr_value_wide;
}
}
Tcl_DictObjGet(interp, attrs_dict, attr_key_perms, &attr_value);
if (attr_value != NULL) {
attr_value_str = Tcl_GetString(attr_value);
if (attr_value_str[0] == 'x') {
pathinfo->typeinfo.file.executable = 1;
}
}
break;
case 's': /* symlink */
pathinfo->type = APPFS_PATHTYPE_SYMLINK;
pathinfo->typeinfo.symlink.size = 0;
pathinfo->typeinfo.symlink.source[0] = '\0';
|
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
|
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
|
}
break;
case 'f': /* file */
pathinfo->type = APPFS_PATHTYPE_FILE;
pathinfo->typeinfo.file.size = 0;
pathinfo->typeinfo.file.executable = 0;
pathinfo->typeinfo.file.suid = 0;
pathinfo->typeinfo.file.worldaccessible = 0;
Tcl_DictObjGet(interp, attrs_dict, attr_key_size, &attr_value);
if (attr_value != NULL) {
tcl_ret = Tcl_GetWideIntFromObj(NULL, attr_value, &attr_value_wide);
if (tcl_ret == TCL_OK) {
pathinfo->typeinfo.file.size = attr_value_wide;
}
}
Tcl_DictObjGet(interp, attrs_dict, attr_key_perms, &attr_value);
if (attr_value != NULL) {
attr_value_str = Tcl_GetString(attr_value);
for (attr_value_str_i = &attr_value_str[0]; *attr_value_str_i != '\0'; attr_value_str_i++) {
switch (*attr_value_str_i) {
case 'x':
pathinfo->typeinfo.file.executable = 1;
break;
case 'U':
pathinfo->typeinfo.file.suid = 1;
break;
case '-':
pathinfo->typeinfo.file.worldaccessible = 1;
break;
}
}
}
break;
case 's': /* symlink */
pathinfo->type = APPFS_PATHTYPE_SYMLINK;
pathinfo->typeinfo.symlink.size = 0;
pathinfo->typeinfo.symlink.source[0] = '\0';
|
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
|
break;
case APPFS_PATHTYPE_FILE:
if (pathinfo.typeinfo.file.executable) {
stbuf->st_mode = S_IFREG | 0555;
} else {
stbuf->st_mode = S_IFREG | 0444;
}
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.file.size;
break;
case APPFS_PATHTYPE_SYMLINK:
stbuf->st_mode = S_IFLNK | 0555;
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.symlink.size;
break;
case APPFS_PATHTYPE_SOCKET:
|
>
>
>
>
>
>
>
>
>
|
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
|
break;
case APPFS_PATHTYPE_FILE:
if (pathinfo.typeinfo.file.executable) {
stbuf->st_mode = S_IFREG | 0555;
} else {
stbuf->st_mode = S_IFREG | 0444;
}
if (pathinfo.typeinfo.file.suid) {
stbuf->st_mode = S_IFREG | 04000;
}
if (pathinfo.typeinfo.file.worldaccessible) {
stbuf->st_mode &= ~077;
}
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.file.size;
break;
case APPFS_PATHTYPE_SYMLINK:
stbuf->st_mode = S_IFLNK | 0555;
stbuf->st_nlink = 1;
stbuf->st_size = pathinfo.typeinfo.symlink.size;
break;
case APPFS_PATHTYPE_SOCKET:
|