Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Porting fs to the browser / process.binding('fs') & process.binding('constants')
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Adam Crabtree  
View profile  
 More options May 19 2012, 10:00 pm
From: Adam Crabtree <atcrabt...@gmail.com>
Date: Sat, 19 May 2012 19:00:49 -0700
Local: Sat, May 19 2012 10:00 pm
Subject: Porting fs to the browser / process.binding('fs') & process.binding('constants')

Howdy all,

(Let me know if this isn't appropriate for nodejs-dev.)

I'm attempting to porting fs to the browser in browserify via the
FileSystem API, and it looks like the fastest route is to shim the
appropriate process.binding('fs') and process.binding('constants'), which
includes:

// from process.binding('fs')
[ 'Stats',
  'close',
  'open',
  'read',
  'fdatasync',
  'fsync',
  'rename',
  'truncate',
  'rmdir',
  'mkdir',
  'sendfile',
  'readdir',
  'stat',
  'lstat',
  'fstat',
  'link',
  'symlink',
  'readlink',
  'unlink',
  'write',
  'chmod',
  'fchmod',
  'chown',
  'fchown',
  'utimes',
  'futimes',
  'StatWatcher' ]

// from process.binding('constants')
{
O_RDONLY: 0,
  O_WRONLY: 1,
  O_RDWR: 2,
  S_IFMT: 61440,
  S_IFREG: 32768,
  S_IFDIR: 16384,
  S_IFCHR: 8192,
  S_IFBLK: 24576,
  S_IFIFO: 4096,
  S_IFLNK: 40960,
  S_IFSOCK: 49152,
  O_CREAT: 512,
  O_EXCL: 2048,
  O_NOCTTY: 131072,
  O_TRUNC: 1024,
  O_APPEND: 8,
  O_DIRECTORY: 1048576,
  O_NOFOLLOW: 256,
  O_SYNC: 128,
  O_SYMLINK: 2097152

}

The fs bindings seem pretty straightforward, not sure if they'll all
translate to the FileSystem API, but mostly if anyone would be be willing
to give information on the constants I'd be very thankful.

Also, are these documented outside of the source?

Cheers,
Adam Crabtree

--
Better a little with righteousness
       than much gain with injustice.
Proverbs 16:8


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Schlueter  
View profile  
 More options May 19 2012, 10:03 pm
From: Isaac Schlueter <i...@izs.me>
Date: Sat, 19 May 2012 23:03:23 -0300
Local: Sat, May 19 2012 10:03 pm
Subject: Re: [node-dev] Porting fs to the browser / process.binding('fs') & process.binding('constants')
The O_* constants are documented in `man 2 open`.  The S_* constants
are documented in `man 2 stat`.

Note that they're also platform-dependent.  For example, O_SYMLINK
only exists on BSD systems.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Shinnick  
View profile  
 More options May 19 2012, 11:06 pm
From: Thomas Shinnick <tshin...@gmail.com>
Date: Sat, 19 May 2012 20:06:43 -0700 (PDT)
Local: Sat, May 19 2012 11:06 pm
Subject: Re: [node-dev] Porting fs to the browser / process.binding('fs') & process.binding('constants')

For example... (Just the other day I was just reviewing/comparing Linux vs.
Windows nodes, what was _actually_ defined in runtime values versus what is
mentioned in the constants source)

  diff constants_*linux*.s constants_*windows*.s

        157d122
        <   S_IFBLK: 24576,
        160,161d124
        <   S_IFIFO: 4096,
        <   S_IFLNK: 40960,
        164,176c127,184
        <   S_IFSOCK: 49152,
        <   S_IRGRP: 32,
        <   S_IROTH: 4,
        <   S_IRUSR: 256,
        <   S_IRWXG: 56,
        <   S_IRWXO: 7,
        <   S_IRWXU: 448,
        <   S_IWGRP: 16,
        <   S_IWOTH: 2,
        <   S_IWUSR: 128,
        <   S_IXGRP: 8,
        <   S_IXOTH: 1,
        <   S_IXUSR: 64,

        81,86c78,80
        <   O_APPEND: 1024,
        <   O_CREAT: 64,
        <   O_DIRECTORY: 65536,
        <   O_EXCL: 128,
        <   O_NOCTTY: 256,
        <   O_NOFOLLOW: 131072,
        ---
        >   O_APPEND: 8,
        >   O_CREAT: 256,
        >   O_EXCL: 1024,
        88d81
        <   O_SYNC: 4096,

You see a whole bunch of S_* constants not defined under Windows.  And
fewer O_* constants under Windows.  And for the same O_* constant names,
different values, like O_CREAT is either 0x0040 or 0x0100

So a question is - after which runtime, Windows, Linux, BSD, would you
model your available names and then their values?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam Crabtree  
View profile  
 More options May 20 2012, 12:15 am
From: Adam Crabtree <atcrabt...@gmail.com>
Date: Sat, 19 May 2012 21:15:45 -0700
Local: Sun, May 20 2012 12:15 am
Subject: Re: [node-dev] Porting fs to the browser / process.binding('fs') & process.binding('constants')

Isaac, awesome. That's exactly what I was hoping for.

Thomas, I'm assuming (it looks like) the code is not using the constants to
platform sniff (so to speak) but instead is feature detecting, so I'll be
setting them to whatever the browser FileSystem API supports. For instance,
the FileSystem API doesn't support symbolic links, etc...

Looks like in the process I'm going to be tripping over a lot of the
boundaries of browserify too. =) (SlowBuffer.byteLength... hmm...)

Cheers,
Adam

--
Better a little with righteousness
       than much gain with injustice.
Proverbs 16:8

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »