Implement most of chmod