[syscall] Update VFS-related ioctls

Change-Id: Ic809cd53d15eb1ea294eb80ae4db751237cbdf94
diff --git a/src/syscall/mx/mxio/mxio.go b/src/syscall/mx/mxio/mxio.go
index 95533b3..35904c7 100644
--- a/src/syscall/mx/mxio/mxio.go
+++ b/src/syscall/mx/mxio/mxio.go
@@ -81,7 +81,7 @@
 const (
 	IoctlFamilyReserved = 0x00 // IOCTL_FAMILY_RESERVED
 	IoctlFamilyDevice   = 0x01 // IOCTL_FAMILY_DEVICE
-	IoctlFamilyDevmgr   = 0x02 // IOCTL_FAMILY_VFS, TODO rename to IoctlFamilyVFS
+	IoctlFamilyVFS      = 0x02 // IOCTL_FAMILY_VFS
 	IoctlFamilyDMCTL    = 0x03 // IOCTL_FAMILY_DMCTL
 	IoctlFamilyTest     = 0x04 // IOCTL_FAMILY_TEST
 )
@@ -92,17 +92,40 @@
 )
 
 var IoctlDeviceBind = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 0)
-var IoctlDeviceWatchDir = IoctlNum(IoctlKindGetHandle, IoctlFamilyDevice, 1)
-var IoctlDeviceGetEventHandle = IoctlNum(IoctlKindGetHandle, IoctlFamilyDevice, 2)
-var IoctlDeviceGetDriverName = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 3)
-var IoctlDeviceGetDeviceName = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 4)
-var IoctlDeviceDebugSuspend = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 5)
-var IoctlDeviceDebugResume = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 6)
-var IoctlDeviceSync = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 7)
+var IoctlDeviceGetEventHandle = IoctlNum(IoctlKindGetHandle, IoctlFamilyDevice, 1)
+var IoctlDeviceGetDriverName = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 2)
+var IoctlDeviceGetDeviceName = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 3)
+var IoctlDeviceSync = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 6)
+var IoctlDeviceDebugSuspend = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 7)
+var IoctlDeviceDebugResume = IoctlNum(IoctlKindDefault, IoctlFamilyDevice, 8)
 
-var IoctlDevmgrMountFS = IoctlNum(IoctlKindSetHandle, IoctlFamilyDevmgr, 0)
-var IoctlDevmgrUnmountFS = IoctlNum(IoctlKindDefault, IoctlFamilyDevmgr, 1)
-var IoctlDevmgrGetTokenFS = IoctlNum(IoctlKindGetHandle, IoctlFamilyDevmgr, 5)
+var IoctlVFSMountFS = IoctlNum(IoctlKindSetHandle, IoctlFamilyVFS, 0)
+var IoctlVFSUnmountFS = IoctlNum(IoctlKindDefault, IoctlFamilyVFS, 1)
+var IoctlVFSGetTokenFS = IoctlNum(IoctlKindGetHandle, IoctlFamilyVFS, 5)
+var IoctlVFSWatchDir = IoctlNum(IoctlKindSetHandle, IoctlFamilyVFS, 8) // NOTE: Actually v2
+
+type VFSWatchDirRequest struct {
+	H       mx.Handle
+	Mask    uint32
+	Options uint32
+}
+
+const (
+	VFSWatchEventDeleted = iota
+	VFSWatchEventAdded
+	VFSWatchEventRemoved
+	VFSWatchEventExisting
+	VFSWatchEventIdle
+)
+
+const (
+	VFSWatchMaskDeleted = 1 << iota
+	VFSWatchMaskAdded
+	VFSWatchMaskRemoved
+	VFSWatchMaskExisting
+	VFSWatchMaskIdle
+	VFSWatchMaskAll = 0x1F
+)
 
 type Vnattr struct {
 	Valid      uint32
diff --git a/src/syscall/mx/mxio/rio/rio_test.go b/src/syscall/mx/mxio/rio/rio_test.go
index fd2f283..fcf3723 100644
--- a/src/syscall/mx/mxio/rio/rio_test.go
+++ b/src/syscall/mx/mxio/rio/rio_test.go
@@ -76,9 +76,9 @@
 	// IN: Arg: Max length of "out", Arg2: Opcode (arbitrary), Data: Arbitrary bytes
 	// OUT: Retval: 0, Data: Arbitrary bytes
 	{rio.OpIoctl, rio.MessageChunkSize, 1337, []uint8{'i', 'n'}, 0, 0, []uint8{'o', 'u', 't'}, []mx.Handle{}},
-	// IN: Arg: Max length of "out", Arg2: Opcode (IoctlDevmgr)
+	// IN: Arg: Max length of "out", Arg2: Opcode (IoctlVFS)
 	// OUT: Retval: 0, Handles: Opened object (set elsewhere)
-	{rio.OpIoctl, rio.MessageChunkSize, int64(mxio.IoctlDevmgrMountFS), []uint8{}, 0, 0, []uint8{}, []mx.Handle{}},
+	{rio.OpIoctl, rio.MessageChunkSize, int64(mxio.IoctlVFSMountFS), []uint8{}, 0, 0, []uint8{}, []mx.Handle{}},
 	// IN: Nothing
 	// OUT: Nothing
 	{rio.OpClose, 0, 0, []uint8{}, 0, 0, []uint8{}, []mx.Handle{}},
@@ -145,7 +145,7 @@
 }
 
 func checkIoctl(client *rio.RemoteIO, opIndex int) {
-	if testData[opIndex].inArg2 == int64(mxio.IoctlDevmgrMountFS) {
+	if testData[opIndex].inArg2 == int64(mxio.IoctlVFSMountFS) {
 		// Create the expected return handle here, since dummy values would be rejected.
 		h0, _, err := mx.NewChannel(0)
 		if err != nil {
diff --git a/src/syscall/syscall_fuchsia.go b/src/syscall/syscall_fuchsia.go
index d7f4642..ec0ddcc 100644
--- a/src/syscall/syscall_fuchsia.go
+++ b/src/syscall/syscall_fuchsia.go
@@ -204,7 +204,7 @@
 	}
 	defer new.Close()
 
-	token, err := new.Ioctl(mxio.IoctlDevmgrGetTokenFS, nil, nil)
+	token, err := new.Ioctl(mxio.IoctlVFSGetTokenFS, nil, nil)
 	if err != nil {
 		return err
 	}