xrsh-buildroot/buildroot-v86/board/v86/rootfs_overlay/root/fs/helloworld.js

40 lines
731 B
JavaScript
Raw Normal View History

#!/bin/js
// Set log file to the home directory
const file1 = "hello world";
// Function to handle getattr command
function getattr(path) {
if (path === '/') {
return "16877 2 1000 1000 4096 8"
} else if (path === '/file1') {
return `33188 1 1000 1000 ${file1.length} 1`
} else {
return ''
}
}
// Main function to handle commands
function main(args) {
console.log(args.join(' '));
switch (args[0]) {
case 'readdir':
return 'file1'
break;
case 'getattr':
return getattr(args[1]);
break;
case 'read':
if (args[1] === '/file1') {
return file1;
}
break;
default:
return ''
}
}
// Run the main function
return main(args.slice(1));