2024-12-11 18:23:05 +01:00
|
|
|
#!/bin/js
|
|
|
|
|
|
|
|
// Set log file to the home directory
|
|
|
|
const file1 = "hello world";
|
|
|
|
|
|
|
|
// Function to handle getattr command
|
|
|
|
function getattr(path) {
|
|
|
|
if (path === '/') {
|
2025-01-09 12:14:26 +01:00
|
|
|
return "16877 2 0 0 4096 8"
|
2024-12-11 18:23:05 +01:00
|
|
|
} else if (path === '/file1') {
|
2025-01-09 12:14:26 +01:00
|
|
|
return `33188 1 0 0 ${file1.length} 1`
|
2024-12-11 18:23:05 +01:00
|
|
|
} 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));
|