Skip to content

Instantly share code, notes, and snippets.

@ronilaukkarinen
Created August 26, 2022 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronilaukkarinen/5914414a1267179ef2672767bd1bbc1f to your computer and use it in GitHub Desktop.
Save ronilaukkarinen/5914414a1267179ef2672767bd1bbc1f to your computer and use it in GitHub Desktop.
Backup of flood discussion: Support systems that use quota instead of df #421

Flood uses df -T in server/util/diskUsageUtil.ts where it defines the disks in use. However, I have a box that has a jail and df is useless as it shows all other filesystems we don't use in our jail. Users have to use quota to get their own data usage on their space.

As quota uses different format than df it's not enough to just change the command. We also need more arguments to get all data in the same line:

$ quota -w --show-mntpoint
Disk quotas for user rolle (uid 1020): 
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
/dev/sdb1 /home2 1059357988  3905945600 3905945600          266012       0       0  

I got flood working with quota by modifying the linux option like so:

  linux: (timeout) =>
    spawnAsync(
      'quota',
      ['-w', '--show-mntpoint'],
      {
        timeout: timeout,
      },
      MAX_BUFFER_SIZE,
    ).then((stdout) =>
      stdout
        .trim()
        .split('\n')
        .slice(1)
        .map((disk) => disk.split(/\s+/))
        .filter((disk) => filterMountPoint(disk[6]))
        .filter((disk) => !['devtmpfs', 'squashfs', 'tmpfs', 'overlay'].includes(disk[1]))
        .map(([_dev, target, blocks, quota, limit, quota2, limit2, grace]) => {
          return {
            size: Number.parseInt(quota, 10) * 1024,
            used: Number.parseInt(blocks, 10) * 1024,
            avail: (Number.parseInt(quota, 10) * 1024) - (Number.parseInt(blocks, 10) * 1024),
            target,
          };
        }),
    ),

This works.

I'm not very experienced with ts/js but this could be an option in Flood. Just an idea and working concept I'd like to share. Thoughts?

@ronilaukkarinen
Copy link
Author

Originally here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment