diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-10-23 13:40:06 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-10-23 13:40:06 +0000 |
commit | db971a6189e63802b4c7c0ee41bf00e9864f52a7 (patch) | |
tree | b211a3e5ae91db86a2099019e323eaeb2a63cb77 /sys/src/9/port/sdloop.c | |
parent | e54b6c6cbd4d82d70ddb4932aeafb0b028cd71f5 (diff) |
kernel: fix stat bugs
In a few places, we where using a fixed buffer of sizeof(Dir)+100
size for stat. This is not correct and fails if the name returned
in stat is long.
This results in being unable to seek to the end of file with a
long filename.
The kernel should do the same thing as dirfstat() from libc;
handling the conversion and buffer allocation and returning a
freeable Dir* pointer.
For this, a new dirchanstat() function was added.
The fstat syscall was not rewriting the name to the last path
element; fix it.
In addition, gracefully handle the mountfix case, reallocating
the buffer to accomidate the required stat length plus
size of the new name so dirsetname() does not fail.
Diffstat (limited to 'sys/src/9/port/sdloop.c')
-rw-r--r-- | sys/src/9/port/sdloop.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/sys/src/9/port/sdloop.c b/sys/src/9/port/sdloop.c index 49ea6886d..5b3419cef 100644 --- a/sys/src/9/port/sdloop.c +++ b/sys/src/9/port/sdloop.c @@ -47,21 +47,14 @@ SDifc sdloopifc; static void identify(Ctlr *c, SDunit *u) { - int n; uvlong s, osectors; - uchar buf[sizeof(Dir) + 100]; - Dir dir; + Dir *dir; - if(waserror()){ - iprint("sdloop: identify: %s\n", up->errstr); - nexterror(); - } osectors = c->sectors; - n = devtab[c->c->type]->stat(c->c, buf, sizeof buf); - if(convM2D(buf, n, &dir, nil) == 0) - error("internal error: stat error in seek"); - s = dir.length / c->sectsize; - poperror(); + + dir = dirchanstat(c->c); + s = dir->length / c->sectsize; + free(dir); memset(u->inquiry, 0, sizeof u->inquiry); u->inquiry[2] = 2; |