This file is indexed.

/usr/lib/python2.7/dist-packages/ocfs2interface/ls.py is in ocfs2console 1.6.4-3.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# OCFS2Console - GUI frontend for OCFS2 management and debugging
# Copyright (C) 2005 Oracle.  All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.

import stat
import pwd
import grp
import time

import ocfs2

from classlabel import class_label

class Field(object):
    def __init__(self, dentry, dinode):
        self.dentry = dentry
        self.dinode = dinode

    def real_get_text(self):
        return str(getattr(self.dinode, self.dinode_member))

    def get_text(self):
        return self.real_get_text()

    text = property(get_text)

    label = class_label

    right_justify = False

file_type = {
    ocfs2.FT_UNKNOWN  : '?',
    ocfs2.FT_REG_FILE : '-',
    ocfs2.FT_DIR      : 'd',
    ocfs2.FT_CHRDEV   : 'c',
    ocfs2.FT_BLKDEV   : 'b',
    ocfs2.FT_FIFO     : 'p',
    ocfs2.FT_SOCK     : 's',
    ocfs2.FT_SYMLINK  : 'l',
}

class Mode(Field):
    width_chars = 10

    def real_get_text(self):
        text = ['-'] * 10

        text[0] = file_type[self.dentry.file_type]

        mode = self.dinode.i_mode
        pos = 0

        for t in 'USR', 'GRP', 'OTH':
            for b in 'R', 'W', 'X':
                pos += 1

                if mode & getattr(stat, 'S_I%s%s' % (b, t)):
                    text[pos] = b.lower()

        pos = 0

        for t, b in (('UID', 'S'), ('GID', 'S'), ('VTX', 'T')):
            pos += 3

            if mode & getattr(stat, 'S_IS%s' % t):
                if text[pos] == 'x':
                    text[pos] = b
                else:
                    text[pos] = b.lower()

        return ''.join(text)

class Links(Field):
    label = '# Links'
    dinode_member = 'i_links_count'
    right_justify = True
    width_chars = 5

class ID2Name(Field):
    width_chars = 8

    def real_get_text(self):
        idnum = getattr(self.dinode, self.dinode_member)

        try:
            return self.get_name(idnum)[0]
        except KeyError:
            return str(idnum)

class Owner(ID2Name):
    dinode_member = 'i_uid'
    get_name = pwd.getpwuid

class Group(ID2Name):
    dinode_member = 'i_gid'
    get_name = grp.getgrgid

class Size(Field):
    dinode_member = 'i_size'
    width_chars = 15

class AllocSize(Field):
    width_chars = 15

    def real_get_text(self):
        return str(self.dinode.i_clusters * self.dinode.fs.fs_clustersize)

class Timestamp(Field):
    width_chars = 12

    # Ported from GNU coreutils ls
    time_formats = ('%b %e  %Y', '%b %e %H:%M')

    def real_get_text(self):
        when = self.dinode.i_mtime
        when_local = time.localtime(when)

        current_time = long(time.time())

        six_months_ago = current_time - 31556952 / 2
        recent = (six_months_ago <= when and when < current_time)
        fmt = self.time_formats[recent]  

        return time.strftime(fmt, when_local)

class Name(Field):
    def real_get_text(self):
        return self.dentry.name
    
fields = (Mode, Links, Owner, Group, Size, AllocSize, Timestamp)

def main():
    import sys

    fs = ocfs2.Filesystem(sys.argv[1])

    dentries = []

    def walk(dentry, offset, blocksize):
        dentries.append(dentry)

    fs.dir_iterate(walk)

    try:
        dentry = dentries[int(sys.argv[2])]
    except (IndexError, ValueError):
        try:
            dentry = dentries[0]
        except IndexError:
            return

    dinode = fs.read_cached_inode(dentry.inode)

    for field_type in fields:
        field = field_type(dentry, dinode) 

        print '%s: %s' % (field.label, field.text)

if __name__ == '__main__':
    main()