ref: 46f57aba13e43e6ec3c84d6123c6bc59546e4b7d
parent: 2654def5079f7e6dff66753c7b6c316a5610a20e
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Nov 7 10:29:50 EST 2020
put superblock into Part
--- a/common.h
+++ b/common.h
@@ -20,6 +20,7 @@
struct ext4_blockdev bdev;
struct ext4_blockdev_iface bdif;
+ struct ext4_sblock *sb;
Qid qid;
Qid qidmask;
Groups groups;
--- a/ext4srv.c
+++ b/ext4srv.c
@@ -161,16 +161,8 @@
char *s, *q;
int r, i;
u32int uid, gid, t, ino;
- struct ext4_sblock *sb;
memset(dir, 0, sizeof(*dir));
- s = smprint("%M/", a->p);
- r = ext4_get_sblock(s, &sb);
- free(s);
- if(r != 0){
- fprint(2, "sblock: %s\n", errno2s(r));
- return -1;
- }
if(path == nil){
path = a->path;
@@ -184,15 +176,15 @@
if((r = ext4_raw_inode_fill(s, &ino, &inode)) != 0)
fprint(2, "inode: %s: %s\n", s, errno2s(r));
- dir->mode = ext4_inode_get_mode(sb, &inode);
+ dir->mode = ext4_inode_get_mode(a->p->sb, &inode);
dir->qid.path = a->p->qidmask.path | ino;
dir->qid.vers = ext4_inode_get_generation(&inode);
- t = ext4_inode_type(sb, &inode);
+ t = ext4_inode_type(a->p->sb, &inode);
if(t & EXT4_INODE_MODE_DIRECTORY){
dir->qid.type |= QTDIR;
dir->mode |= DMDIR;
}else
- dir->length = ext4_inode_get_size(sb, &inode);
+ dir->length = ext4_inode_get_size(a->p->sb, &inode);
if(ext4_inode_get_flags(&inode) & EXT4_INODE_FLAG_APPEND){
dir->qid.type |= QTAPPEND;
dir->mode |= DMAPPEND;
@@ -297,15 +289,9 @@
u32int ino, t;
struct ext4_inode inode;
int r;
- struct ext4_sblock *sb;
a = fid->aux;
- s = smprint("%M/", a->p);
- if((r = ext4_get_sblock(s, &sb)) != 0)
- goto error;
- free(s);
-
s = smprint("%M/%s", a->p, a->path);
s = linkresolve(a, s);
@@ -319,7 +305,7 @@
qid->type = 0;
qid->path = a->p->qidmask.path | ino;
qid->vers = ext4_inode_get_generation(&inode);
- t = ext4_inode_type(sb, &inode);
+ t = ext4_inode_type(a->p->sb, &inode);
if(t & EXT4_INODE_MODE_DIRECTORY){
qid->type |= QTDIR;
a->type = Adir;
--- a/part.c
+++ b/part.c
@@ -252,6 +252,11 @@
if(opts->cachewb)
ext4_cache_write_back(p->mnt, 1);
+ if((r = ext4_get_sblock(p->mnt, &p->sb)) != 0){
+ werrstr("sblock: %s", errno2s(r));
+ goto error;
+ }
+
if((gr = readfile(p, "/etc/group", &sz)) != nil){
gr[sz] = 0;
r = loadgroups(&p->groups, gr);