1
1

Use uint64_t instead of dev_t as well + added comment explaining this

Этот коммит содержится в:
Yorhel 2012-08-27 21:10:07 +02:00
родитель cabb55290d
Коммит 21c056f51d
2 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -43,14 +43,14 @@
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
* everything necessary for output_dir.item() except FF_ERR and FF_EXL. */
static void stat_to_dir(struct dir *d, struct stat *fs) {
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))
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)
d->flags |= FF_HLNKC;
if(dir_scan_smfs && curdev != fs->st_dev)
if(dir_scan_smfs && curdev != d->dev)
d->flags |= FF_OTHFS;
if(!(d->flags & (FF_OTHFS|FF_EXL))) {
@ -254,7 +254,7 @@ int dir_scan_process() {
}
if(!dir_fatalerr) {
curdev = fs.st_dev;
curdev = (uint64_t)fs.st_dev;
d = dir_createstruct(dir_curpath);
if(fail)
d->flags |= FF_ERR;

Просмотреть файл

@ -55,25 +55,27 @@
#define ST_HELP 3
/* 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 */
/* structure representing a file or directory */
struct dir {
struct dir *parent, *next, *prev, *sub, *hlnk;
int64_t size, asize;
uint64_t ino;
uint64_t ino, dev;
int items;
dev_t dev;
unsigned char flags;
char name[3]; /* must be large enough to hold ".." */
};
/* sizeof(total dir) = SDIRSIZE + strlen(name) = sizeof(struct dir) - 3 + strlen(name) + 1 */
#define SDIRSIZE (sizeof(struct dir)-2)
/* Ideally, the name array should be as large as the padding added to the end of
* the struct, but I can't figure out a portable way to calculate this. We can
* be sure that it's at least 3 bytes, though, as the struct is aligned to at
* least 4 bytes and the flags field is a single byte. */
/* A note on the ino and dev fields above: ino is usually represented as ino_t,
* which POSIX specifies to be an unsigned integer. dev is usually represented
* as dev_t, which may be either a signed or unsigned integer, and in practice
* 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 */