aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rwxr-xr-xemcc5
-rw-r--r--src/intertyper.js6
-rw-r--r--src/library.js418
-rw-r--r--src/library_egl.js9
-rw-r--r--src/library_glut.js2
-rw-r--r--src/library_openal.js14
-rw-r--r--src/library_path.js17
-rw-r--r--src/library_sdl.js4
-rw-r--r--src/preamble.js9
-rw-r--r--src/settings.js16
-rw-r--r--src/shell.js53
-rw-r--r--system/include/libc/sys/signal.h4
-rw-r--r--system/include/net/if.h21
-rw-r--r--system/include/net/netinet/in.h67
-rw-r--r--system/include/netdb.h36
-rw-r--r--system/include/sys/ioctl.h58
-rw-r--r--system/include/sys/select.h2
-rw-r--r--system/include/sys/socket.h211
-rw-r--r--system/lib/libc/musl/src/stdlib/ecvt.c19
-rw-r--r--system/lib/libc/musl/src/stdlib/fcvt.c25
-rw-r--r--system/lib/libc/musl/src/stdlib/gcvt.c8
-rw-r--r--system/lib/libcextra.symbols3
-rwxr-xr-xtests/runner.py142
-rw-r--r--tools/asm_module.py2
-rw-r--r--tools/js-optimizer.js9
-rw-r--r--tools/shared.py5
27 files changed, 819 insertions, 347 deletions
diff --git a/AUTHORS b/AUTHORS
index d3cdd156..5161f7ad 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -92,4 +92,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Michael Lelli <toadking@toadking.com>
* Yu Kobayashi <yukoba@accelart.jp>
* Pin Zhang <zhangpin04@gmail.com>
+* Nick Bray <ncbray@chromium.org> (copyright owned by Google, Inc.)
diff --git a/emcc b/emcc
index 8f71883d..a5b30b97 100755
--- a/emcc
+++ b/emcc
@@ -1285,6 +1285,11 @@ try:
'wctob.c',
'wctomb.c',
]],
+ ['stdlib', [
+ 'ecvt.c',
+ 'fcvt.c',
+ 'gcvt.c',
+ ]],
['string', [
'wcpcpy.c',
'wcpncpy.c',
diff --git a/src/intertyper.js b/src/intertyper.js
index abfbdacb..dd6e5522 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -700,6 +700,12 @@ function intertyper(data, sidePass, baseLineNums) {
item.intertype = 'value';
if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1);
item.ident = tokensLeft[0].text.substr(1, tokensLeft[0].text.length-2) || ';'; // use ; for empty inline assembly
+ var i = 0;
+ splitTokenList(tokensLeft[3].item.tokens).map(function(element) {
+ var ident = toNiceIdent(element[1].text);
+ var type = element[0].text;
+ item.ident = item.ident.replace(new RegExp('\\$' + i++, 'g'), ident);
+ });
return { forward: null, ret: [item], item: item };
}
if (item.ident.substr(-2) == '()') {
diff --git a/src/library.js b/src/library.js
index e8333b32..a6a38cfe 100644
--- a/src/library.js
+++ b/src/library.js
@@ -56,38 +56,38 @@ LibraryManager.library = {
// to modify the filesystem freely before run() is called.
ignorePermissions: true,
- ErrnoError: function (errno) {
- function ErrnoError(errno) {
- this.errno = errno;
- for (var key in ERRNO_CODES) {
- if (ERRNO_CODES[key] === errno) {
- this.code = key;
- break;
- }
+ ErrnoError: function(errno) {
+ this.errno = errno;
+ for (var key in ERRNO_CODES) {
+ if (ERRNO_CODES[key] === errno) {
+ this.code = key;
+ break;
}
- this.message = ERRNO_MESSAGES[errno];
- };
- ErrnoError.prototype = Object.create(Error.prototype);
- ErrnoError.prototype.contructor = ErrnoError;
- return new ErrnoError(errno);
+ }
+ this.message = ERRNO_MESSAGES[errno];
+ },
+
+ handleFSError: function(e) {
+ if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + new Error().stack;
+ return ___setErrNo(e.errno);
},
//
// nodes
//
- hashName: function (parentid, name) {
+ hashName: function(parentid, name) {
var hash = 0;
for (var i = 0; i < name.length; i++) {
hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
}
return (parentid + hash) % FS.name_table.length;
},
- hashAddNode: function (node) {
+ hashAddNode: function(node) {
var hash = FS.hashName(node.parent.id, node.name);
node.name_next = FS.name_table[hash];
FS.name_table[hash] = node;
},
- hashRemoveNode: function (node) {
+ hashRemoveNode: function(node) {
var hash = FS.hashName(node.parent.id, node.name);
if (FS.name_table[hash] === node) {
FS.name_table[hash] = node.name_next;
@@ -102,7 +102,7 @@ LibraryManager.library = {
}
}
},
- lookupNode: function (parent, name) {
+ lookupNode: function(parent, name) {
var err = FS.mayLookup(parent);
if (err) {
throw new FS.ErrnoError(err);
@@ -116,7 +116,7 @@ LibraryManager.library = {
// if we failed to find it in the cache, call into the VFS
return VFS.lookup(parent, name);
},
- createNode: function (parent, name, mode, rdev) {
+ createNode: function(parent, name, mode, rdev) {
var node = {
id: FS.nextInode++,
name: name,
@@ -136,12 +136,12 @@ LibraryManager.library = {
var readMode = {{{ cDefine('S_IRUGO') }}} | {{{ cDefine('S_IXUGO') }}};
var writeMode = {{{ cDefine('S_IWUGO') }}};
Object.defineProperty(node, 'read', {
- get: function () { return (node.mode & readMode) === readMode; },
- set: function (val) { val ? node.mode |= readMode : node.mode &= ~readMode; }
+ get: function() { return (node.mode & readMode) === readMode; },
+ set: function(val) { val ? node.mode |= readMode : node.mode &= ~readMode; }
});
Object.defineProperty(node, 'write', {
- get: function () { return (node.mode & writeMode) === writeMode; },
- set: function (val) { val ? node.mode |= writeMode : node.mode &= ~writeMode; }
+ get: function() { return (node.mode & writeMode) === writeMode; },
+ set: function(val) { val ? node.mode |= writeMode : node.mode &= ~writeMode; }
});
// TODO add:
// isFolder
@@ -149,38 +149,41 @@ LibraryManager.library = {
FS.hashAddNode(node);
return node;
},
- destroyNode: function (node) {
+ destroyNode: function(node) {
FS.hashRemoveNode(node);
},
- isRoot: function (node) {
+ isRoot: function(node) {
return node === node.parent;
},
- isMountpoint: function (node) {
+ isMountpoint: function(node) {
return node.mounted;
},
- isFile: function (mode) {
+ isFile: function(mode) {
return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFREG') }}};
},
- isDir: function (mode) {
+ isDir: function(mode) {
return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFDIR') }}};
},
- isLink: function (mode) {
+ isLink: function(mode) {
return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFLNK') }}};
},
- isChrdev: function (mode) {
+ isChrdev: function(mode) {
return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFCHR') }}};
},
- isBlkdev: function (mode) {
+ isBlkdev: function(mode) {
return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFBLK') }}};
},
- isFIFO: function (mode) {
+ isFIFO: function(mode) {
return (mode & {{{ cDefine('S_IFMT') }}}) === {{{ cDefine('S_IFIFO') }}};
},
//
// paths
//
- lookupPath: function (path, opts) {
+ cwd: function() {
+ return FS.currentPath;
+ },
+ lookupPath: function(path, opts) {
path = PATH.resolve(FS.currentPath, path);
opts = opts || { recurse_count: 0 };
@@ -189,7 +192,7 @@ LibraryManager.library = {
}
// split the path
- var parts = PATH.normalizeArray(path.split('/').filter(function (p) {
+ var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
return !!p;
}), false);
@@ -233,7 +236,7 @@ LibraryManager.library = {
return { path: current_path, node: current };
},
- getPath: function (node) {
+ getPath: function(node) {
var path;
while (true) {
if (FS.isRoot(node)) {
@@ -265,7 +268,7 @@ LibraryManager.library = {
'"xa+"': {{{ cDefine('O_APPEND') }}} | {{{ cDefine('O_CREAT') }}} | {{{ cDefine('O_RDWR') }}} | {{{ cDefine('O_EXCL') }}}
},
// convert the 'r', 'r+', etc. to it's corresponding set of O_* flags
- modeStringToFlags: function (str) {
+ modeStringToFlags: function(str) {
var flags = FS.flagModes[str];
if (typeof flags === 'undefined') {
throw new Error('Unknown file open mode: ' + str);
@@ -273,7 +276,7 @@ LibraryManager.library = {
return flags;
},
// convert O_* bitmask to a string for nodePermissions
- flagsToPermissionString: function (flag) {
+ flagsToPermissionString: function(flag) {
var accmode = flag & {{{ cDefine('O_ACCMODE') }}};
var perms = ['r', 'w', 'rw'][accmode];
if ((flag & {{{ cDefine('O_TRUNC') }}})) {
@@ -281,7 +284,7 @@ LibraryManager.library = {
}
return perms;
},
- nodePermissions: function (node, perms) {
+ nodePermissions: function(node, perms) {
if (FS.ignorePermissions) {
return 0;
}
@@ -295,10 +298,10 @@ LibraryManager.library = {
}
return 0;
},
- mayLookup: function (dir) {
+ mayLookup: function(dir) {
return FS.nodePermissions(dir, 'x');
},
- mayMknod: function (mode) {
+ mayMknod: function(mode) {
switch (mode & {{{ cDefine('S_IFMT') }}}) {
case {{{ cDefine('S_IFREG') }}}:
case {{{ cDefine('S_IFCHR') }}}:
@@ -310,7 +313,7 @@ LibraryManager.library = {
return ERRNO_CODES.EINVAL;
}
},
- mayCreate: function (dir, name) {
+ mayCreate: function(dir, name) {
try {
var node = FS.lookupNode(dir, name);
return ERRNO_CODES.EEXIST;
@@ -318,7 +321,7 @@ LibraryManager.library = {
}
return FS.nodePermissions(dir, 'wx');
},
- mayDelete: function (dir, name, isdir) {
+ mayDelete: function(dir, name, isdir) {
var node;
try {
node = FS.lookupNode(dir, name);
@@ -343,7 +346,7 @@ LibraryManager.library = {
}
return 0;
},
- mayOpen: function (node, flags) {
+ mayOpen: function(node, flags) {
if (!node) {
return ERRNO_CODES.ENOENT;
}
@@ -368,7 +371,7 @@ LibraryManager.library = {
// however, once opened, the stream's operations are overridden with
// the operations of the device its underlying node maps back to.
chrdev_stream_ops: {
- open: function (stream) {
+ open: function(stream) {
var device = FS.getDevice(stream.node.rdev);
// override node's stream ops with the device's
stream.stream_ops = device.stream_ops;
@@ -377,23 +380,23 @@ LibraryManager.library = {
stream.stream_ops.open(stream);
}
},
- llseek: function () {
+ llseek: function() {
throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
}
},
- major: function (dev) {
+ major: function(dev) {
return ((dev) >> 8);
},
- minor: function (dev) {
+ minor: function(dev) {
return ((dev) & 0xff);
},
- makedev: function (ma, mi) {
+ makedev: function(ma, mi) {
return ((ma) << 8 | (mi));
},
- registerDevice: function (dev, ops) {
+ registerDevice: function(dev, ops) {
FS.devices[dev] = { stream_ops: ops };
},
- getDevice: function (dev) {
+ getDevice: function(dev) {
return FS.devices[dev];
},
@@ -401,7 +404,7 @@ LibraryManager.library = {
// streams
//
MAX_OPEN_FDS: 4096,
- nextfd: function (fd_start, fd_end) {
+ nextfd: function(fd_start, fd_end) {
fd_start = fd_start || 1;
fd_end = fd_end || FS.MAX_OPEN_FDS;
for (var fd = fd_start; fd <= fd_end; fd++) {
@@ -411,46 +414,46 @@ LibraryManager.library = {
}
throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
},
- getStream: function (fd) {
+ getStream: function(fd) {
return FS.streams[fd];
},
- createStream: function (stream, fd_start, fd_end) {
+ createStream: function(stream, fd_start, fd_end) {
var fd = FS.nextfd(fd_start, fd_end);
stream.fd = fd;
// compatibility
Object.defineProperty(stream, 'object', {
- get: function () { return stream.node; },
- set: function (val) { stream.node = val; }
+ get: function() { return stream.node; },
+ set: function(val) { stream.node = val; }
});
Object.defineProperty(stream, 'isRead', {
- get: function () { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; }
+ get: function() { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_WRONLY') }}}; }
});
Object.defineProperty(stream, 'isWrite', {
- get: function () { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; }
+ get: function() { return (stream.flags & {{{ cDefine('O_ACCMODE') }}}) !== {{{ cDefine('O_RDONLY') }}}; }
});
Object.defineProperty(stream, 'isAppend', {
- get: function () { return (stream.flags & {{{ cDefine('O_APPEND') }}}); }
+ get: function() { return (stream.flags & {{{ cDefine('O_APPEND') }}}); }
});
FS.streams[fd] = stream;
return stream;
},
- closeStream: function (fd) {
+ closeStream: function(fd) {
FS.streams[fd] = null;
},
//
// general
//
- createDefaultDirectories: function () {
+ createDefaultDirectories: function() {
VFS.mkdir('/tmp', 0777);
},
- createDefaultDevices: function () {
+ createDefaultDevices: function() {
// create /dev
VFS.mkdir('/dev', 0777);
// setup /dev/null
FS.registerDevice(FS.makedev(1, 3), {
- read: function () { return 0; },
- write: function () { return 0; }
+ read: function() { return 0; },
+ write: function() { return 0; }
});
VFS.mkdev('/dev/null', 0666, FS.makedev(1, 3));
// setup /dev/tty and /dev/tty1
@@ -465,7 +468,7 @@ LibraryManager.library = {
VFS.mkdir('/dev/shm', 0777);
VFS.mkdir('/dev/shm/tmp', 0777);
},
- createStandardStreams: function () {
+ createStandardStreams: function() {
// TODO deprecate the old functionality of a single
// input / output callback and that utilizes FS.createDevice
// and instead require a unique set of stream ops
@@ -503,14 +506,14 @@ LibraryManager.library = {
{{{ makeSetValue(makeGlobalUse('_stderr'), 0, 'stderr.fd', 'void*') }}};
assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')');
},
- staticInit: function () {
+ staticInit: function() {
FS.root = FS.createNode(null, '/', {{{ cDefine('S_IFDIR') }}} | 0777, 0);
VFS.mount(MEMFS, {}, '/');
FS.createDefaultDirectories();
FS.createDefaultDevices();
},
- init: function (input, output, error) {
+ init: function(input, output, error) {
assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
FS.init.initialized = true;
@@ -521,7 +524,7 @@ LibraryManager.library = {
FS.createStandardStreams();
},
- quit: function () {
+ quit: function() {
FS.init.initialized = false;
for (var i = 0; i < FS.streams.length; i++) {
var stream = FS.streams[i];
@@ -535,24 +538,24 @@ LibraryManager.library = {
//
// compatibility
//
- getMode: function (canRead, canWrite) {
+ getMode: function(canRead, canWrite) {
var mode = 0;
if (canRead) mode |= {{{ cDefine('S_IRUGO') }}} | {{{ cDefine('S_IXUGO') }}};
if (canWrite) mode |= {{{ cDefine('S_IWUGO') }}};
return mode;
},
- joinPath: function (parts, forceRelative) {
+ joinPath: function(parts, forceRelative) {
var path = PATH.join.apply(null, parts);
if (forceRelative && path[0] == '/') path = path.substr(1);
return path;
},
- absolutePath: function (relative, base) {
+ absolutePath: function(relative, base) {
return PATH.resolve(base, relative);
},
- standardizePath: function (path) {
+ standardizePath: function(path) {
return PATH.normalize(path);
},
- findObject: function (path, dontResolveLastLink) {
+ findObject: function(path, dontResolveLastLink) {
var ret = FS.analyzePath(path, dontResolveLastLink);
if (ret.exists) {
return ret.object;
@@ -561,7 +564,7 @@ LibraryManager.library = {
return null;
}
},
- analyzePath: function (path, dontResolveLastLink) {
+ analyzePath: function(path, dontResolveLastLink) {
// operate from within the context of the symlink's target
try {
var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
@@ -589,12 +592,12 @@ LibraryManager.library = {
};
return ret;
},
- createFolder: function (parent, name, canRead, canWrite) {
+ createFolder: function(parent, name, canRead, canWrite) {
var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);
var mode = FS.getMode(canRead, canWrite);
return VFS.mkdir(path, mode);
},
- createPath: function (parent, path, canRead, canWrite) {
+ createPath: function(parent, path, canRead, canWrite) {
parent = typeof parent === 'string' ? parent : FS.getPath(parent);
var parts = path.split('/').reverse();
while (parts.length) {
@@ -610,12 +613,12 @@ LibraryManager.library = {
}
return current;
},
- createFile: function (parent, name, properties, canRead, canWrite) {
+ createFile: function(parent, name, properties, canRead, canWrite) {
var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);
var mode = FS.getMode(canRead, canWrite);
return VFS.create(path, mode);
},
- createDataFile: function (parent, name, data, canRead, canWrite) {
+ createDataFile: function(parent, name, data, canRead, canWrite) {
var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);
var mode = FS.getMode(canRead, canWrite);
var node = VFS.create(path, mode);
@@ -634,7 +637,7 @@ LibraryManager.library = {
}
return node;
},
- createDevice: function (parent, name, input, output) {
+ createDevice: function(parent, name, input, output) {
var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);
var mode = input && output ? 0777 : (input ? 0333 : 0555);
if (!FS.createDevice.major) FS.createDevice.major = 64;
@@ -642,16 +645,16 @@ LibraryManager.library = {
// Create a fake device that a set of stream ops to emulate
// the old behavior.
FS.registerDevice(dev, {
- open: function (stream) {
+ open: function(stream) {
stream.seekable = false;
},
- close: function (stream) {
+ close: function(stream) {
// flush any pending line data
- if (output.buffer && output.buffer.length) {
+ if (output && output.buffer && output.buffer.length) {
output({{{ charCode('\n') }}});
}
},
- read: function (stream, buffer, offset, length, pos /* ignored */) {
+ read: function(stream, buffer, offset, length, pos /* ignored */) {
var bytesRead = 0;
for (var i = 0; i < length; i++) {
var result;
@@ -672,7 +675,7 @@ LibraryManager.library = {
}
return bytesRead;
},
- write: function (stream, buffer, offset, length, pos) {
+ write: function(stream, buffer, offset, length, pos) {
for (var i = 0; i < length; i++) {
try {
output(buffer[offset+i]);
@@ -688,7 +691,7 @@ LibraryManager.library = {
});
return VFS.mkdev(path, mode, dev);
},
- createLink: function (parent, name, target, canRead, canWrite) {
+ createLink: function(parent, name, target, canRead, canWrite) {
var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);
return VFS.symlink(target, path);
},
@@ -830,9 +833,9 @@ LibraryManager.library = {
// override each stream op with one that tries to force load the lazy file first
var stream_ops = {};
var keys = Object.keys(node.stream_ops);
- keys.forEach(function (key) {
+ keys.forEach(function(key) {
var fn = node.stream_ops[key];
- stream_ops[key] = function () {
+ stream_ops[key] = function() {
if (!FS.forceLoadFile(node)) {
throw new FS.ErrnoError(ERRNO_CODES.EIO);
}
@@ -840,7 +843,7 @@ LibraryManager.library = {
};
});
// use a custom read function
- stream_ops.read = function (stream, buffer, offset, length, position) {
+ stream_ops.read = function(stream, buffer, offset, length, position) {
var contents = stream.node.contents;
var size = Math.min(contents.length - position, length);
if (contents.slice) { // normal array
@@ -869,10 +872,9 @@ LibraryManager.library = {
// You can also call this with a typed array instead of a url. It will then
// do preloading for the Image/Audio part, as if the typed array were the
// result of an XHR that you did manually.
- createPreloadedFile__deps: ['$PATH'],
createPreloadedFile: function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile) {
Browser.init();
- var fullname = PATH.join(parent, name).substr(1);
+ var fullname = FS.joinPath([parent, name], true);
function processData(byteArray) {
function finish(byteArray) {
if (!dontCreateFile) {
@@ -907,7 +909,7 @@ LibraryManager.library = {
$VFS__deps: ['$FS'],
$VFS: {
- mount: function (type, opts, mountpoint) {
+ mount: function(type, opts, mountpoint) {
var mount = {
type: type,
opts: opts,
@@ -933,11 +935,11 @@ LibraryManager.library = {
}
return root;
},
- lookup: function (parent, name) {
+ lookup: function(parent, name) {
return parent.node_ops.lookup(parent, name);
},
// generic function for all node creation
- mknod: function (path, mode, dev) {
+ mknod: function(path, mode, dev) {
var lookup = FS.lookupPath(path, { parent: true });
var parent = lookup.node;
var name = PATH.basename(path);
@@ -951,21 +953,21 @@ LibraryManager.library = {
return parent.node_ops.mknod(parent, name, mode, dev);
},
// helpers to create specific types of nodes
- create: function (path, mode) {
+ create: function(path, mode) {
mode &= {{{ cDefine('S_IALLUGO') }}};
mode |= {{{ cDefine('S_IFREG') }}};
return VFS.mknod(path, mode, 0);
},
- mkdir: function (path, mode) {
+ mkdir: function(path, mode) {
mode &= {{{ cDefine('S_IRWXUGO') }}} | {{{ cDefine('S_ISVTX') }}};
mode |= {{{ cDefine('S_IFDIR') }}};
return VFS.mknod(path, mode, 0);
},
- mkdev: function (path, mode, dev) {
+ mkdev: function(path, mode, dev) {
mode |= {{{ cDefine('S_IFCHR') }}};
return VFS.mknod(path, mode, dev);
},
- symlink: function (oldpath, newpath) {
+ symlink: function(oldpath, newpath) {
var lookup = FS.lookupPath(newpath, { parent: true });
var parent = lookup.node;
var newname = PATH.basename(newpath);
@@ -978,7 +980,7 @@ LibraryManager.library = {
}
return parent.node_ops.symlink(parent, newname, oldpath);
},
- rename: function (old_path, new_path) {
+ rename: function(old_path, new_path) {
var old_dirname = PATH.dirname(old_path);
var new_dirname = PATH.dirname(new_path);
var old_name = PATH.basename(old_path);
@@ -1060,7 +1062,7 @@ LibraryManager.library = {
FS.hashAddNode(old_node);
}
},
- rmdir: function (path) {
+ rmdir: function(path) {
var lookup = FS.lookupPath(path, { parent: true });
var parent = lookup.node;
var name = PATH.basename(path);
@@ -1078,7 +1080,7 @@ LibraryManager.library = {
parent.node_ops.rmdir(parent, name);
FS.destroyNode(node);
},
- unlink: function (path) {
+ unlink: function(path) {
var lookup = FS.lookupPath(path, { parent: true });
var parent = lookup.node;
var name = PATH.basename(path);
@@ -1098,7 +1100,7 @@ LibraryManager.library = {
parent.node_ops.unlink(parent, name);
FS.destroyNode(node);
},
- readlink: function (path) {
+ readlink: function(path) {
var lookup = FS.lookupPath(path, { follow: false });
var link = lookup.node;
if (!link.node_ops.readlink) {
@@ -1106,7 +1108,7 @@ LibraryManager.library = {
}
return link.node_ops.readlink(link);
},
- stat: function (path, dontFollow) {
+ stat: function(path, dontFollow) {
var lookup = FS.lookupPath(path, { follow: !dontFollow });
var node = lookup.node;
if (!node.node_ops.getattr) {
@@ -1114,10 +1116,10 @@ LibraryManager.library = {
}
return node.node_ops.getattr(node);
},
- lstat: function (path) {
+ lstat: function(path) {
return VFS.stat(path, true);
},
- chmod: function (path, mode, dontFollow) {
+ chmod: function(path, mode, dontFollow) {
var node;
if (typeof path === 'string') {
var lookup = FS.lookupPath(path, { follow: !dontFollow });
@@ -1133,17 +1135,17 @@ LibraryManager.library = {
timestamp: Date.now()
});
},
- lchmod: function (path, mode) {
+ lchmod: function(path, mode) {
VFS.chmod(path, mode, true);
},
- fchmod: function (fd, mode) {
+ fchmod: function(fd, mode) {
var stream = FS.getStream(fd);
if (!stream) {
throw new FS.ErrnoError(ERRNO_CODES.EBADF);
}
VFS.chmod(stream.node, mode);
},
- chown: function (path, uid, gid, dontFollow) {
+ chown: function(path, uid, gid, dontFollow) {
var node;
if (typeof path === 'string') {
var lookup = FS.lookupPath(path, { follow: !dontFollow });
@@ -1159,17 +1161,17 @@ LibraryManager.library = {
// we ignore the uid / gid for now
});
},
- lchown: function (path, uid, gid) {
+ lchown: function(path, uid, gid) {
VFS.chown(path, uid, gid, true);
},
- fchown: function (fd, uid, gid) {
+ fchown: function(fd, uid, gid) {
var stream = FS.getStream(fd);
if (!stream) {
throw new FS.ErrnoError(ERRNO_CODES.EBADF);
}
VFS.chown(stream.node, uid, gid);
},
- truncate: function (path, len) {
+ truncate: function(path, len) {
if (len < 0) {
throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
}
@@ -1198,7 +1200,7 @@ LibraryManager.library = {
timestamp: Date.now()
});
},
- ftruncate: function (fd, len) {
+ ftruncate: function(fd, len) {
var stream = FS.getStream(fd);
if (!stream) {
throw new FS.ErrnoError(ERRNO_CODES.EBADF);
@@ -1208,14 +1210,14 @@ LibraryManager.library = {
}
VFS.truncate(stream.node, len);
},
- utime: function (path, atime, mtime) {
+ utime: function(path, atime, mtime) {
var lookup = FS.lookupPath(path, { follow: true });
var node = lookup.node;
node.node_ops.setattr(node, {
timestamp: Math.max(atime, mtime)
});
},
- open: function (path, flags, mode, fd_start, fd_end) {
+ open: function(path, flags, mode, fd_start, fd_end) {
path = PATH.normalize(path);
flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
if ((flags & {{{ cDefine('O_CREAT') }}})) {
@@ -1279,7 +1281,7 @@ LibraryManager.library = {
}
return stream;
},
- close: function (stream) {
+ close: function(stream) {
try {
if (stream.stream_ops.close) {
stream.stream_ops.close(stream);
@@ -1290,19 +1292,19 @@ LibraryManager.library = {
FS.closeStream(stream.fd);
}
},
- llseek: function (stream, offset, whence) {
+ llseek: function(stream, offset, whence) {
if (!stream.seekable || !stream.stream_ops.llseek) {
throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
}
return stream.stream_ops.llseek(stream, offset, whence);
},
- readdir: function (stream) {
+ readdir: function(stream) {
if (!stream.stream_ops.readdir) {
throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
}
return stream.stream_ops.readdir(stream);
},
- read: function (stream, buffer, offset, length, position) {
+ read: function(stream, buffer, offset, length, position) {
if (length < 0 || position < 0) {
throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
}
@@ -1326,7 +1328,7 @@ LibraryManager.library = {
if (!seeking) stream.position += bytesRead;
return bytesRead;
},
- write: function (stream, buffer, offset, length, position) {
+ write: function(stream, buffer, offset, length, position) {
if (length < 0 || position < 0) {
throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
}
@@ -1354,7 +1356,7 @@ LibraryManager.library = {
if (!seeking) stream.position += bytesWritten;
return bytesWritten;
},
- allocate: function (stream, offset, length) {
+ allocate: function(stream, offset, length) {
if (offset < 0 || length <= 0) {
throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
}
@@ -1369,7 +1371,7 @@ LibraryManager.library = {
}
stream.stream_ops.allocate(stream, offset, length);
},
- mmap: function (stream, buffer, offset, length, position, prot, flags) {
+ mmap: function(stream, buffer, offset, length, position, prot, flags) {
// TODO if PROT is PROT_WRITE, make sure we have write acccess
if ((stream.flags & {{{ cDefine('O_A