Would you access a patch to support ZFS? It would have to be like ZFS, a separate module to get the quota, since it doesn't support the same calls as ext4 or xfs.
Discussion
Anonymous
-
2025-05-09
Sorry, that's "accept" not "access"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I guess it depends how much special ZFS is. If it just means hooking up another syscall for ZFS filesystem I guess that would be OK.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2025-12-11
The best approach for ZFS is to use libzfs. Of course it's only present on systems that have ZFS.
Code looks like
zh=zfs_open(libh,filesys,ZFS_TYPE_FILESYSTEM);if(!zh){fprintf(stderr,"can't open file systen %s\n",filesys);return0;}// get the actual quotasif(type==USRQUOTA){currspace=getquota("userused",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);if(!failed)currfiles=getquota("userobjused",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);if(!failed)quotaspace=getquota("userquota",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);if(!failed)quotafiles=getquota("userobjquota",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);}else{currspace=getquota("groupused",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);if(!failed)currfiles=getquota("groupobjused",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);if(!failed)quotaspace=getquota("groupquota",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);if(!failed)quotafiles=getquota("groupobjquota",propbuf,sizeof(propbuf)-1,name,libh,zh,&failed);}zfs_close(zh);libzfs_fini(libh);
getquota is
unsigned long
getquota(char quota, char propbuf, int propbuflen, char user, libzfs_handle_t libh, zfs_handle_t zh, int failed) {
char *attr = NULL;
unsigned long ret;
strcpy(propbuf, "0"); // in case no quota for this user
if (zfs_prop_get_userquota(zh, attr, propbuf, propbuflen-1, 1) == 0)
ret = atol(propbuf);
else
ret = 0L;
free(attr);
return ret;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, that's "accept" not "access"
I guess it depends how much special ZFS is. If it just means hooking up another syscall for ZFS filesystem I guess that would be OK.
The best approach for ZFS is to use libzfs. Of course it's only present on systems that have ZFS.
Code looks like
getquota is
unsigned long
getquota(char quota, char propbuf, int propbuflen, char user, libzfs_handle_t libh, zfs_handle_t zh, int failed) {
char *attr = NULL;
unsigned long ret;
asprintf(&attr, "%s@%s", quota, user);
if (!attr) {
*failed = 1;
return 0L;
}
strcpy(propbuf, "0"); // in case no quota for this user
if (zfs_prop_get_userquota(zh, attr, propbuf, propbuflen-1, 1) == 0)
ret = atol(propbuf);
else
ret = 0L;
free(attr);
return ret;
}