Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contribution 😬: Perhaps 'procfs' dependency isn't really needed? #125

Open
nocke opened this issue Feb 6, 2023 · 1 comment
Open

Comments

@nocke
Copy link
Contributor

nocke commented Feb 6, 2023

Perhaps 'procfs' dependency isn't really needed?
( procfs can certainly do a lot, but we only need rather little )

IMHO, this should suffice, to get all the parsing info needed under linux:
(already with heavy filtering as in PR 124)

const getMount = (mountId, _parentID, _deviceNo, root, mountPoint, mountOptions, _fields, _mountSource, superOptions, blob) => (
  {
    mountId,
    // parentID,
    // deviceNo,
    root,
    mountPoint,
    mountOptions: mountOptions.split(','),
    // fields,
    // mountSource,
    superOptions: superOptions.split(','),
    blob
  })

const mounts = fs.readFileSync('/proc/self/mountinfo', 'utf-8')
mounts.split(/\n/)
  .filter(l => l.length > 0) // filter empty line at end
  .map((m) => getMount(...m.split(' ')))
  .filter((m) =>
    !/^\/(snap|run|sys|proc|dev)($|\/)/.test(m.mountPoint) &&
      !['mqueue', 'tmpfs'].includes(m.superOptions) &&
      !m.superOptions.includes('mqueue') &&
      !m.superOptions.includes('tmpfs') &&
      !m.mountOptions.includes('ro')
  )
  .map((l) =>
    info(l))
@sindresorhus
Copy link
Owner

I would prefer to keep the dependency. I don't really want to maintain this code. From experience, there are definitely edge-cases that will present itself later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants