Fixed dd /dev/zero truncation in packages/bare-os-coreutils/src/dd.js
if=/dev/zero with finite count*bs now produces requested size directly (not limited by VFS 64KiB pseudo-file). Raw stdout now uses bareOsEmitRaw, improving pipeline correctness. Fixed pipeline capture path for FIFO-relevant commands echo and cat now emit via bareOsEmitRaw (packages/bare-os-coreutils/src/echo.js, packages/bare-os-coreutils/src/cat.js). Shell pipeline now injects bareOsBinWrite into child contexts when output is captured, so raw writes are captured (packages/bare-os-booter/lib/shell.js). Improved xattr behavior in packages/bare-os-coreutils/src/xattr.js Added -p/--print NAME. -w now logs written attribute name for visible success feedback. Roundtrip behaviors preserved with sidecar metadata format. Improved ACL UX in: packages/bare-os-coreutils/src/getfacl.js Explicit source header for sidecar and mode fallback (non-compact mode). packages/bare-os-coreutils/src/setfacl.js Added -m/--modify ENTRY in addition to stdin blob and -b. Implemented dynamic ulimit output in packages/bare-os-coreutils/src/ulimit.js Reads /proc/bare_os/rlimits.json when available. Supports -a, -n, -Sn, -Hn. Added shuf -e support in packages/bare-os-coreutils/src/shuf.js. Added split byte-suffix parsing (k/K/m/M/g/G) and attached -bSIZE support in packages/bare-os-coreutils/src/split.js.
This commit is contained in:
+40
-4
@@ -100,18 +100,54 @@ const LIMITS = [
|
||||
['virtual memory', '-v', 'unlimited']
|
||||
]
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} ctx
|
||||
*/
|
||||
async function readRuntimeLimits(ctx) {
|
||||
try {
|
||||
const b = await ctx.vfs.readFile('/proc/bare_os/rlimits.json')
|
||||
if (!b) return null
|
||||
const j = JSON.parse(ctx.b4a.toString(b))
|
||||
return j && typeof j === 'object' ? j : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const args = argv.slice(1).filter((a) => a !== '--')
|
||||
const rt = await readRuntimeLimits(ctx)
|
||||
const nofileSoft =
|
||||
String(
|
||||
rt?.softNoFile ??
|
||||
rt?.soft_nofile ??
|
||||
rt?.nofileSoft ??
|
||||
rt?.nofile_soft ??
|
||||
256
|
||||
) || '256'
|
||||
const nofileHard =
|
||||
String(
|
||||
rt?.hardNoFile ??
|
||||
rt?.hard_nofile ??
|
||||
rt?.nofileHard ??
|
||||
rt?.nofile_hard ??
|
||||
nofileSoft
|
||||
) || nofileSoft
|
||||
if (args.length === 0 || (args.length === 1 && args[0] === '-a')) {
|
||||
for (const [label, flag, val] of LIMITS) {
|
||||
ctx.console.log(`${label} (${flag}) ${val}`)
|
||||
const outVal = flag === '-n' ? nofileSoft : val
|
||||
ctx.console.log(`${label} (${flag}) ${outVal}`)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (args.length === 1 && args[0] === '-n') {
|
||||
ctx.console.log('256')
|
||||
if (args.length === 1 && (args[0] === '-n' || args[0] === '-Sn')) {
|
||||
ctx.console.log(nofileSoft)
|
||||
return
|
||||
}
|
||||
ctx.console.error('ulimit: only -a and -n are supported in Bare OS')
|
||||
if (args.length === 1 && args[0] === '-Hn') {
|
||||
ctx.console.log(nofileHard)
|
||||
return
|
||||
}
|
||||
ctx.console.error('ulimit: only -a, -n, -Sn, and -Hn are supported in Bare OS')
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user