0

I am developing a Mysql based file system for Linux system. I have developed python code to implement basic linux terminal command like cd,ls,pwd,find and grep.

As a part of ls command ,I want to implement ls -l extension.

I have stored st_mode value for all files in database.Now I need to interpret the mode results just as below result and print them.

drwxr-xr-x 31 sai sai 4096 Apr 2 10:31 sai

Example : the octal value of st_mode = 0o0400 .Now I need to retrive/obtain drwxr-xr-x from the octal value.

I reffered to using masking but did not understand how to obtain the results in the format I want using python.

Please suggest ways to achieve my requirement.

Sai Teja
  • 153
  • 1
  • 8

1 Answers1

2

Got it.

Converted the octal value to binary using bin() and then referred to final 9 bits of the binary number to get permission bits.

Sai Teja
  • 153
  • 1
  • 8