Menu

#21 zfs

open
nobody
None
5
2025-12-11
2025-05-09
Anonymous
No

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

    Anonymous - 2025-05-09

    Sorry, that's "accept" not "access"

     
  • Jan Kara

    Jan Kara - 2025-07-01

    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.

     
  • 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);
          return 0;
        }
    
        // get the actual quotas
    
        if (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;

    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;
    }

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB