-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing accuracy while getting ino (获取ino 精度丢失) #16679
Comments
I think it because the typedef struct {
uint64_t st_dev;
uint64_t st_mode;
uint64_t st_nlink;
uint64_t st_uid;
uint64_t st_gid;
uint64_t st_rdev;
uint64_t st_ino;
uint64_t st_size;
uint64_t st_blksize;
uint64_t st_blocks;
uint64_t st_flags;
uint64_t st_gen;
uv_timespec_t st_atim;
uv_timespec_t st_mtim;
uv_timespec_t st_ctim;
uv_timespec_t st_birthtim;
} uv_stat_t; And when filling to Node.js, it will be changed to void FillStatsArray(double* fields, const uv_stat_t* s) {
fields[0] = s->st_dev;
...
fields[7] = s->st_ino;
fields[8] = s->st_size;
...
} Refs |
How about add some function like |
There is no real solution for this until JS gets BigInt support, which is currently in stage 3. We've had this discussion before, and IMHO we should still wait for BigInt. |
@mscdex but how could @spitWind get it correctly now? |
Or maybe we could provide the raw |
Please clarify: is it just accuracy? As inode numbers are unique identifiers into the disk blocks, I believe any change in the number leads to |
@gireeshpunathil That's it. That's why I propose a safer one or a raw one. |
@XadillaX - thanks! I Agree that it is a bug that needs to be fixed. If there is no data type to support it, we should not record it in the first place, as not having an info is better than recording wrong info. |
I don't really agree with that. It's hard to say how often this is actually a problem in production. This is only the second time anyone has ever brought it up that I've ever seen. |
@spitWind Could you please tell us that the situation you have to get this value in production? |
@mscdex - the problem is that it may not manifest as a problem. Wrong but valid inodes can corrupt files inadvertently, and may not be noticed easily. |
Closing, duplicate of #12115. |
你们可以设置成_int64的,然后获取到原生的buffer比较 buffer就可以确认,,或者字符串 |
貌似得解决下~~ |
怎么超全局(针对机器)hook node里面的module?比如 fs模块 |
两个原因,js 精度。。另外一个是double64.. |
|
Since `ino` is an unsigned 64-bit integer, it may lost accuracy in JavaScript. This situation may cause some strange bugs in filesystem. So a string type `inoString` is added to `fs.Stats`. Fixes: nodejs#16679 Fixes: nodejs#12115 Refs: http://docs.libuv.org/en/v1.x/fs.html#c.uv_stat_t
thank you @XadillaX |
node fs.stat 获取文件 ino 精度丢失
The text was updated successfully, but these errors were encountered: