diff --git a/utils/fsctl.py b/utils/fsctl.py index f42beaa..cca3b20 100755 --- a/utils/fsctl.py +++ b/utils/fsctl.py @@ -503,6 +503,48 @@ class fseditCmd(cmd.Cmd): print 'File copied from /%s to /%s/%s' % (src, dstparent, dstname) + def do_chown(self, args): + '''Change file ownership''' + arg_list = args.split() + + if len(arg_list) != 2: + print "Incorrect number of arguments.\nUsage: chown " + return + + uid = arg_list[0] + target_path = resolve_reference(self.pwd, arg_list[1]) + + if not exists(self.fs, target_path): + print "File '%s' doesn't exist." % target_path + return + + target_object = getpath(self.fs, target_path) + olduid = target_object[A_UID] + target_object[A_UID] = int(uid) + print "former UID: " + str(olduid) + ". New UID: " + str(uid) + + + def do_chgrp(self, args): + '''Change file ownership''' + arg_list = args.split() + + if len(arg_list) != 2: + print "Incorrect number of arguments.\nUsage: chgrp " + return + + gid = arg_list[0] + target_path = resolve_reference(self.pwd, arg_list[1]) + + if not exists(self.fs, target_path): + print "File '%s' doesn't exist." % target_path + return + + target_object = getpath(self.fs, target_path) + oldgid = target_object[A_UID] + target_object[A_UID] = int(gid) + print "former GID: " + str(oldgid) + ". New GID: " + str(gid) + + def do_file(self, args): '''Identifies file types.\nUsage: file ''' arg_list = args.split()