ot_u8 GFB_chmod_su( ot_u8 id, ot_u8 mod ) { # if ( GFB_HEAP_BYTES > 0 ) return vl_chmod(VL_GFB_BLOCKID, id, mod, NULL); # else return ~0; # endif }
ot_int sub_fileperms( alp_tmpl* alp, id_tmpl* user_id, ot_u8 respond, ot_u8 cmd_in, ot_int data_in ) { ot_int data_out = 0; vlBLOCK file_block = (vlBLOCK)((cmd_in >> 4) & 0x07); ot_u8 file_mod = ((cmd_in & 0x02) ? VL_ACCESS_W : VL_ACCESS_R); /// Loop through all the listed file ids and process permissions. while ((data_in > 0) && sub_qnotfull(respond, 2, alp->outq)) { ot_u8 file_id = q_readbyte(alp->inq); ot_bool allow_write = respond; vaddr header; data_in--; // one for the file id if (file_mod == VL_ACCESS_W ) { /// run the chmod and return the error code (0 is no error) data_in--; // two for the new mod file_mod = vl_chmod(file_block, file_id, q_readbyte(alp->inq), user_id); } else if (allow_write) { /// Get the header address and return mod (offset 5). The root user /// (NULL) is used because this is only for reading filemod. /// Note: This is a hack that is extremely optimized for speed allow_write = (ot_bool)(vl_getheader_vaddr(&header, file_block, file_id, \ VL_ACCESS_R, NULL) == 0); if (allow_write) { Twobytes filemod; filemod.ushort = vworm_read(header + 4); //shortcut to idmod, hack-ish but fast file_mod = filemod.ubyte[1]; } } if (allow_write) { /// load the data onto the output, if response enabled q_writebyte(alp->outq, file_id); q_writebyte(alp->outq, file_mod); data_out += 2; } } /// return number of bytes put onto the output (always x2) //alp->BOOKMARK_IN = (void*)sub_testchunk(data_in); return data_out; }
ot_u8 ISF_chmod_su( ot_u8 id, ot_u8 mod ) { return vl_chmod(VL_ISFS_BLOCKID, id, mod, NULL); }