Use uint64_t instead of dev_t as well + added comment explaining this
Этот коммит содержится в:
родитель
cabb55290d
Коммит
21c056f51d
@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
int dir_scan_smfs; /* Stay on the same filesystem */
|
int dir_scan_smfs; /* Stay on the same filesystem */
|
||||||
|
|
||||||
static dev_t curdev; /* current device we're scanning on */
|
static uint64_t curdev; /* current device we're scanning on */
|
||||||
|
|
||||||
|
|
||||||
/* Populates the struct dir item with information from the stat struct. Sets
|
/* Populates the struct dir item with information from the stat struct. Sets
|
||||||
* everything necessary for output_dir.item() except FF_ERR and FF_EXL. */
|
* everything necessary for output_dir.item() except FF_ERR and FF_EXL. */
|
||||||
static void stat_to_dir(struct dir *d, struct stat *fs) {
|
static void stat_to_dir(struct dir *d, struct stat *fs) {
|
||||||
d->ino = (uint64_t)fs->st_ino;
|
d->ino = (uint64_t)fs->st_ino;
|
||||||
d->dev = fs->st_dev;
|
d->dev = (uint64_t)fs->st_dev;
|
||||||
|
|
||||||
if(S_ISREG(fs->st_mode))
|
if(S_ISREG(fs->st_mode))
|
||||||
d->flags |= FF_FILE;
|
d->flags |= FF_FILE;
|
||||||
@ -60,7 +60,7 @@ static void stat_to_dir(struct dir *d, struct stat *fs) {
|
|||||||
if(!S_ISDIR(fs->st_mode) && fs->st_nlink > 1)
|
if(!S_ISDIR(fs->st_mode) && fs->st_nlink > 1)
|
||||||
d->flags |= FF_HLNKC;
|
d->flags |= FF_HLNKC;
|
||||||
|
|
||||||
if(dir_scan_smfs && curdev != fs->st_dev)
|
if(dir_scan_smfs && curdev != d->dev)
|
||||||
d->flags |= FF_OTHFS;
|
d->flags |= FF_OTHFS;
|
||||||
|
|
||||||
if(!(d->flags & (FF_OTHFS|FF_EXL))) {
|
if(!(d->flags & (FF_OTHFS|FF_EXL))) {
|
||||||
@ -254,7 +254,7 @@ int dir_scan_process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!dir_fatalerr) {
|
if(!dir_fatalerr) {
|
||||||
curdev = fs.st_dev;
|
curdev = (uint64_t)fs.st_dev;
|
||||||
d = dir_createstruct(dir_curpath);
|
d = dir_createstruct(dir_curpath);
|
||||||
if(fail)
|
if(fail)
|
||||||
d->flags |= FF_ERR;
|
d->flags |= FF_ERR;
|
||||||
|
20
src/global.h
20
src/global.h
@ -55,25 +55,27 @@
|
|||||||
#define ST_HELP 3
|
#define ST_HELP 3
|
||||||
|
|
||||||
|
|
||||||
/* structure representing a file or directory
|
/* structure representing a file or directory */
|
||||||
* XXX: probably a good idea to get rid of the custom _t types and use
|
|
||||||
* fixed-size integers instead, which are much more predictable */
|
|
||||||
struct dir {
|
struct dir {
|
||||||
struct dir *parent, *next, *prev, *sub, *hlnk;
|
struct dir *parent, *next, *prev, *sub, *hlnk;
|
||||||
int64_t size, asize;
|
int64_t size, asize;
|
||||||
uint64_t ino;
|
uint64_t ino, dev;
|
||||||
int items;
|
int items;
|
||||||
dev_t dev;
|
|
||||||
unsigned char flags;
|
unsigned char flags;
|
||||||
char name[3]; /* must be large enough to hold ".." */
|
char name[3]; /* must be large enough to hold ".." */
|
||||||
};
|
};
|
||||||
/* sizeof(total dir) = SDIRSIZE + strlen(name) = sizeof(struct dir) - 3 + strlen(name) + 1 */
|
/* sizeof(total dir) = SDIRSIZE + strlen(name) = sizeof(struct dir) - 3 + strlen(name) + 1 */
|
||||||
#define SDIRSIZE (sizeof(struct dir)-2)
|
#define SDIRSIZE (sizeof(struct dir)-2)
|
||||||
|
|
||||||
/* Ideally, the name array should be as large as the padding added to the end of
|
/* A note on the ino and dev fields above: ino is usually represented as ino_t,
|
||||||
* the struct, but I can't figure out a portable way to calculate this. We can
|
* which POSIX specifies to be an unsigned integer. dev is usually represented
|
||||||
* be sure that it's at least 3 bytes, though, as the struct is aligned to at
|
* as dev_t, which may be either a signed or unsigned integer, and in practice
|
||||||
* least 4 bytes and the flags field is a single byte. */
|
* both are used. dev represents an index / identifier of a device or
|
||||||
|
* filesystem, and I'm unsure whether a negative value has any meaning in that
|
||||||
|
* context. Hence my choice of using an unsigned integer. Negative values, if
|
||||||
|
* we encounter them, will just get typecasted into a positive value. No
|
||||||
|
* information is lost in this conversion, and the semantics remain the same.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* program state */
|
/* program state */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user