Skip to content

Instantly share code, notes, and snippets.

View prashanthpai's full-sized avatar

Prashanth Pai prashanthpai

View GitHub Profile
@prashanthpai
prashanthpai / json2toml.py
Created February 23, 2022 05:01
Convert a json file to toml file using Python
#!/usr/bin/env python
# Prerequisite:
# pip install toml
import json
import sys
import toml
@prashanthpai
prashanthpai / freeotp_backup.md
Created September 24, 2018 04:15 — forked from kontez/freeotp_backup.md
A guide to back up and recover 2FA tokens from FreeOTP (Android)

Backing up and recovering 2FA tokens from FreeOTP

Backing up FreeOTP

Using adb, create a backup of the app using the following command:

adb backup -f freeotp-backup.ab -apk org.fedorahosted.freeotp
[ppai@gd2-1 xlator-sym-go]$ ./main /usr/local/lib/glusterfs/3.12dev
/usr/local/lib/glusterfs/3.12dev/auth/addr.so
auth.addr.*.allow
auth.addr.*.reject
auth.ip.*.allow
/usr/local/lib/glusterfs/3.12dev/auth/login.so
auth.login.*.allow
auth.login.*.password
Testing presentation from gist
Go Go Go
14:00 9 Mar 2017
Gopher
* Title of slide or section (must have asterisk)
Some Text
@prashanthpai
prashanthpai / python_getdents.py
Last active August 11, 2020 04:51
Python wrapper for getdents/getdents64() syscall
#!/usr/bin/env python
import os
import sys
import ctypes
import struct
from ctypes.util import find_library
# struct linux_dirent64 {
# ino64_t d_ino; /* 64-bit inode number */
# off64_t d_off; /* 64-bit offset to next structure */
digraph swiftonfile {
"swiftonfile" -> "memcached"
"swiftonfile" -> "openssl"
"swiftonfile" -> "openstack-swift"
"swiftonfile" -> "openstack-swift-account"
"swiftonfile" -> "openstack-swift-container"
"swiftonfile" -> "openstack-swift-object"
"swiftonfile" -> "openstack-swift-proxy"
"swiftonfile" -> "python-gluster"
"swiftonfile" -> "python-prettytable"

DiskFile API call flow for different requests

GET

disk_file = self.get_diskfile(...)
with disk_file.open():
    metadata = disk_file.get_metadata()
    response = Response(app_iter=disk_file.reader, ...)
[root@hummingbird ~]# curl -v -X PUT http://localhost:8080/v1/AUTH_test/c1/o4 -d'hello'
[root@hummingbird gfapi]# ltrace -T -ff -p 28906

[pid 28908] malloc(17, 0xc820000f00, 0xc82004afa8, 0xc82004aff8)                                                                                   = 0x7f28f80008c0 <0.021299>
[pid 28908] __errno_location(0xc82004b080, 0xc820000f00, 0xc82004aff0, 0xc82004b080)                                                               = 0x7f291ce45640 <0.006508>
[pid 28908] glfs_stat(0x1ad2550, 0x7f28f80008c0, 0xc82017bd40, 0xc82004b080)                                                                       = 0xffffffff <0.015113>
[pid 28908] free(0x7f28f80008c0, 0xc820000f00, 0xc82004b018, 0xc82004b080)                                                                         = 0 <0.003132>
[pid 28908] malloc(14, 0xc820000f00, 0xc82004aee0, 0xc82004af30)                                                                                   = 0x7f28f80008c0 <0.002026>
[pid 28908] __errno_loca
diff --git a/swiftonfile/swift/common/utils.py b/swiftonfile/swift/common/utils.py
index c7ad8bf..5cb30ae 100644
--- a/swiftonfile/swift/common/utils.py
+++ b/swiftonfile/swift/common/utils.py
@@ -292,7 +292,7 @@ def _get_etag(path_or_fd):
return etag
-def get_object_metadata(obj_path_or_fd, stats=None):
+def get_object_metadata(obj_path_or_fd, stats=None, etag=None):
root# python
Python 2.7.5 (default, Jun 25 2014, 10:19:55) 
[GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from swift.common.utils import O_TMPFILE
>>> os.open("/mnt/test/", os.O_WRONLY | O_TMPFILE)
Traceback (most recent call last):
 File "", line 1, in