Saturday, August 15, 2015

Installing vmware-view client on Ubuntu 14.10 on 64 bit systems.

 Here are the instructions (along with the error messages) to install vmware-view client on ubuntu 64 bit systems.

Short version: If you don't have time to read below. Copy following script, and run it from folder where you had downloaded  the client.
#!/bin/bash
sudo dpkg --add-architecture i386
sudo apt-get install libxml2:i386
sudo apt-get install libssl1.0.0:i386
sudo apt-get install libXtst6:i386
sudo apt-get install libudev1:i386
sudo apt-get install libpcsclite1:i386
sudo apt-get install libtheora0:i386
sudo apt-get install libv4l-0:i386
sudo apt-get install libpulse0:i386
sudo ln -sf /lib/i386-linux-gnu/libudev.so.1 /lib/i386-linux-gnu/libudev.so.0
sudo ln -sf /lib/i386-linux-gnu/libssl.so.1.0.0 /lib/i386-linux-gnu/libssl.so.1.0.1
sudo ln -sf /lib/i386-linux-gnu/libcrypto.so.1.0.0 /lib/i386-linux-gnu/libcrypto.so.1
sudo apt-get install libncurses5-dev:i386
sudo apt-get install libcanberra-gtk-module:i386
sudo apt-get install libxss-dev:i386
sudo apt-get install libxml2-dev:i386
sudo apt-get install lib32stdc++6
chmod a+x VMware-Horizon-Client-3.4.0-2769709.x86.bundle
sudo ./VMware-Horizon-Client-3.4.0-2769709.x86.bundle
vmware-view &



Longer version:

/tmp> uname -a
Linux devils-den 3.16.0-44-generic #59-Ubuntu SMP Tue Jul 7 02:07:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
/tmp> sudo ./VMware-Horizon-Client-3.4.0-2769709.x86.bundle
VMWare Horizon Client is an x86 application but you are trying to install it to an x64 Linux.
To run this installation, you may need to install 32-bit runtime libraries. Do you want to proceed? (yes/no)yes
Extracting VMware Installer...done.
/tmp/vmis.jIqCaw/install/vmware-installer/vmware-installer: line 57: /tmp/vmis.jIqCaw/install/vmware-installer/vmis-launcher: No such file or directory

/tmp> sudo dpkg --add-architecture i386
/tmp>  sudo apt-get install libxml2:i386
/tmp> sudo apt-get install libssl1.0.0:i386
/tmp> sudo apt-get install libXtst6:i386
/tmp> sudo apt-get install libudev1:i386
/tmp> sudo apt-get install libpcsclite1:i386
/tmp> sudo apt-get install libtheora0:i386
/tmp> sudo apt-get install libv4l-0:i386
/tmp> sudo apt-get install libpulse0:i386
/tmp> sudo ln -sf /lib/i386-linux-gnu/libudev.so.1 /lib/i386-linux-gnu/libudev.so.0
/tmp> sudo ln -sf /lib/i386-linux-gnu/libssl.so.1.0.0 /lib/i386-linux-gnu/libssl.so.1.0.1
/tmp> sudo ln -sf /lib/i386-linux-gnu/libcrypto.so.1.0.0 /lib/i386-linux-gnu/libcrypto.so.1


/tmp> sudo ./VMware-Horizon-Client-3.4.0-2769709.x86.bundle
VMWare Horizon Client is an x86 application but you are trying to install it to an x64 Linux.
To run this installation, you may need to install 32-bit runtime libraries. Do you want to proceed? (yes/no)yes
Extracting VMware Installer...done.
User interface initialization failed.  Exiting.  Check the log for details.

/tmp> sudo apt-get install libncurses5-dev:i386
/tmp> sudo apt-get install libcanberra-gtk-module:i386

/tmp> sudo ./VMware-Horizon-Client-3.4.0-2769709.x86.bundle
/tmp> vmware-view &

[1]    11398
/tmp> /usr/lib/vmware/view/bin/vmware-view: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
/tmp> sudo apt-get install libxss-dev:i386

/tmp> vmware-view & 
                     
[1]    14472
/tmp> /usr/lib/vmware/view/bin/vmware-view: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory
/tmp> sudo apt-get install libxml2-dev:i386

/tmp> vmware-view &
                       
[1]    16845
/tmp> /usr/lib/vmware/view/bin/vmware-view: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
/tmp> sudo apt-get install lib32stdc++6


/tmp> vmware-view &                        



After this, vmware-view client works for me. Njoy !

Sunday, February 24, 2013

Here is a simple web remote you can use with your roku player. Chances are that it won't work directly from the blog. Unfortunately blogspot doesn't have a place to add a download link, so right click on the page, select "view source" and save it as a html file on your local disk. And then open the html, also make sure the input IP address provided is correct for your roku device.

Roku Web Remote

Roku IP :

<= Home
^
< Select >
v
Repeat Info
<< >|| >>
Backspace InstantReplay Search

Sunday, February 10, 2013

Communicating with roku box without remote

It is bound to happen ! Some day you will lose your roku remote and start looking for alternatives. I was trying to re-configure my roku box, and happily did a factory reset by pressing the reset button at the back of the box and then realized...oops, I don't have a remote. Now the hunt for remote started which was nowhere to be seen. The next obvious choice to control roku is an iphone or android, but I don't possess any of apple products (because I love my freedom) and my android was with my wife in a foreign country. All I had was a 3 yr old IBM thinkpad with ubuntu 12.10. Thankfully there are two more choices available. Apparently there are couple of ports open by default on roku box (8060 and 8080-8085) through which you can communicate.
All the settings were gone due to factory reset, so had to connect my Roku-XD with an ethernet cable and by logging into the router got the ip address of the device.
Telnet to ipaddr:8080 succeeded first time and by mistake I quit the console, and after that even after repeated attempts I kept getting connection refused. Searching through net I came across a python script which had a GUI to control, but I couldn't get it to work because telnet to port 8080 wasn't succeeding even though I was able to ping the ip address.
Next was to try the HTTP port, tried few commands and they seemed to go through..bingo ! That was all I needed. Next 10 mins. were spent writing a shell script and I had a reasonable command line remote for controlling the roku box.  You can start the below shell script using the command "roku <ipaddr>" on your command line. Without the ipaddr parameter it connects to 192.168.1.66 by default.

I couldn't figure out how to configure wireless using command line, because it just gets stuck once you select the SSID and the http request doesn't return for you to enter the next command.

Below is the shell script, if this post or the shell script below helped you, I would like to know so please drop me a line. And because blogspot won't allow me to upload the script, its in plain text below. Just copy paste it to your local file, change execute permissions (chmod a+x <filename>) and run.

# Simple script to communicate with your roku box.
#Written by Manish Katiyar 
# Date : 2/9/2013

#Enter your roku IP address here
ipaddr=192.168.1.66

[ ! -z "$1" ] && ipaddr=$1

echo "++++++++++++++++++++++++++++++++++++++++++++++"
echo "Sending commands to roku box ($ipaddr)"
echo "++++++++++++++++++++++++++++++++++++++++++++++"


runcmd() {
   wget -O /dev/null --post-data "" "http://$ipaddr:8060/keypress/$cmd" 2> /dev/null
}

help() {
 echo "Command Usage : $0 [ipaddr]"
 echo "Subcommands :"
 printf "\tHome - [Hh]\n"
 printf "\tRev - [Rr]ev\n"
 printf "\tFwd - [Ff]\n"
 printf "\tPlay - [Pp]\n"
 printf "\tSelect - [Ss]\n"
 printf "\tLeft - [Ll]\n"
 printf "\tRight [Rr]\n"
 printf "\tDown - [Dd]\n"
 printf "\tUp - [Uu]\n"
 printf "\tBack - [Bb]\n"
 printf "\tInstantReplay - Ir\n"
 printf "\tInfo - [Ii]nf\n"
 printf "\tBackspace - bs\n"
 printf "\tSearch - srch\n"
 printf "\tEnter - [Ee]\n"
 printf "\tInput - [Ii]\n"
 printf "\tQuit - [Qq]\n"
 printf "\t? help\n"
}

getinput() {
 echo "Enter your phrase below"
 read word
 wordlen=`echo $word|wc -c`
 wordlen=`expr $wordlen - 1`
 for i in `seq 1 $wordlen`
 do
  char=`echo $word|cut -c $i`
  cmd=Lit_$char
  sleep 0.3
  runcmd
done
}

while [ 1 ]
do
    printf "Enter roku command (?) > "
    read a
    case $a in
      [Hh]) cmd=Home && runcmd ;;
      [Rr]ev) cmd=Rev && runcmd ;;
      [Ff]) cmd=Fwd && runcmd ;;
      [Pp]) cmd=Play && runcmd ;;
      [Ss]) cmd=Select && runcmd ;;
      [Ll]) cmd=Left && runcmd ;;
      [Rr]) cmd=Right && runcmd ;;
      [Uu]) cmd=Up && runcmd ;;
      [Dd]) cmd=Down && runcmd ;;
      [Bb]) cmd=Back && runcmd ;;
      [Ii]r]) cmd=InstantReplay && runcmd ;;
      [Ii]nf) cmd=Info && runcmd ;;
      bs) cmd=Backspace && runcmd ;;
      srch) cmd=Search && runcmd ;;
      [Ee]) cmd=Enter && runcmd ;;
      [Ii]) getinput;;
      [Qq]) exit -1;;
      ?) help;;
     esac
done

Monday, July 30, 2012

Caricatures

Have been trying to sketch on the WACOM bamboo tablet. Seems nice so far. Let's see how it goes.







Sunday, April 1, 2012

Applying filter to results in cscope

I had always wanted cscope to be a little more intelligent and let me specify the range of search results, which may be very handy when you are browsing a large project and want to look into a particular file instead of whole project. Of course one way is to put the results in a file and use your shell scripting skills (but do you really want to do that ??).

Googling didn't give any useful results, so I decided to spend my Sunday to do some useful work, and added support in cscope to apply filters to search. Here is what it can do currently.

a) Apply filename filter to your "Find C symbols"
b) You can tell cscope to not include the patterns from a particular file.
c) It supports logical OR (I didn't try other regex)

Snapshots below.

=> Search of i_nlink in linux codebase 500 instances like below



 => But I'm really interested in the places where its accessed in vfs_code. (Notice the message "(Filtered with : vfs)" at top.



 
=> Soon I realize, I was only interested in looking at header files (look at filter string at the top of screen)



=> Or not so, actually in only 'C' files.

 

=> I want all references from directory and lock files.



Download the source code from here and compile it as below.

a) ./configure
b) make
c) src/cscope -R

Njoy !!

Saturday, July 2, 2011

Committing a journal transaction in jbd


Journal's transaction commit consists of 8 phases, with the journal's state transitions mentioned as below in each of the phase.

The main function which does the journal commit is journal_commit_transaction(). When we decide to commit the transaction, journal is in running state. (T_RUNNING)

Lock the transaction for new updates. ===> T_LOCKED
---> Wait for any existing handles in the transaction to complete the updates.
---> Discard buffers from reserved list. (t_reserved_list).

If any buffer is part of next transaction, it is transferred to appropriate list of next transanction, otherwise dropped from journal's list.
---> Drop write-back buffers from checkpoint list.(t_checkpoint_list). Unless the buffers belong to the running or commiting transaction, the corresponding transaction will also be freed up.

Phase 1 start

---> Change transaction state to T_FLUSH
---> Switch the revoke tables.
---> At this point there is no running transaction, it is changed to a commiting
transaction.

Phase 2 start

/* Flushing starts now */
---> Data buffers are flushed first. (t_sync_datalist)
---> Write out revoke records from the revoke hash list and flush to the descriptor blocks in journal.
---> Change transaction state to T_COMMIT

Phase 3 start

---> Flush metadata buffers (present on t_buffers list). See journal_write_metadata_buffer()

Phase 4 start

---> Wait for all the IO submitted buffers above. Wait for metadata buffers which are present on t_iobuf_list. The dummy buffer heads created for metadata buffers are released. The original metadata buffer which was put on shadow list is released, but put into t_forget list.

Phase 5 start

---> Wait for the submitted revoke record and descriptor buffers to complete and written out. This is done by waiting for buffers on t_log_list.

Phase 6 start

---> Change transaction state to T_COMMIT_RECORD
---> IO for data is complete now. Write the commit record in journal.
 
Phase 7 start

 ---> Walk the journal's t_forget list to get rid of buffers till there are no more buffers on it. As each buffer is examined, we check if it was on the checkpoint io list of previous transaction. If it is, its removed and if required (in case its dirty) its transferred to the checkpoint list of the committing transaction. See __journal_insert_checkpoint()

Phase 8 start

--> We are done committing the transaction now.
---> Change transaction state to T_FINISHED
---> Set committing transaction = NULL.
---> Calculate average commit time for future use.
---> Setup the checkpointing transaction.

Journalling layer in ext3 (jbd)

Terminology
Journal handle - A handle pointer each of which represents a single atomic filesystem operation. It tracks all the modifications done as part of one atomic operation.
Transaction - A single atomic sequence of events which guarantees filesytem consistency. It can consist of a single handle or multiple handles for batching efficiency.
Transaction commit - Flushing the in-memory contents of journal to appropriate blocks in journal along with writing a commit record on disk in journal.
Transaction checkpoint - Flushing the contents from journal to their actual location on disk. This is done periodically to make journal space reusable.

Typically journalling a filesystem operation consists of following three steps :-

a) Starting a handle - journal_start(). We need to specify how many fs blocks this op can potentially modify. This is required to ensure that there would be enough space in the journal to completely write contents of this operation.
The number of blocks required is the total number of blocks, including the data which is going to change, metadata blocks, quota blocks if any etc. As an example see EXT3_DATA_TRANS_BLOCKS. These are called buffer credits for the handle.

b) After getting a handle, next step is to associate the modified blocks with the journal handle, so that journal knows that it has to write these blocks in journal. This is done via following APIs journal_get_write_access(handle, bh) which tells the journal that this buffer is going to be modified. A buffer which is of interest to journalling layer has BH_JBD set on it and has a non-zero b_count. At this point a "journal_head" is attached to the buffer. A journal_head can only be part of 1 transaction.

journal_get_write_access(handle, bh) {
    journal_add_journal_head(bh);
    do_get_write_access(handle, jh, 0);
    journal_put_journal_head(bh);
}

journal_add_journal_head(bh) {
     jh = journal_alloc_journal_head();
         set_buffer_jbd(bh);
         bh->b_private = jh;
         jh->b_bh = bh;
     jh->b_jcount++;
}

PS: A buffer is already part of a transaction if its journal_head's b_transaction or b_next_transaction is set. Most of the times, only b_transaction is set. b_next_transaction will be set incase the buffer is getting committed from previous transaction and we are changing it for the current transaction. The b_next_transaction tells journal that this buffer is going in next transaction. In this case a copy on write is performed and the frozen copy is stored in jh->b_frozen_data.
NB : Buffer's b_transaction will only be set if its part of running or committing transaction and not if it resides on some other list like checkpoint list etc.

c) Stop the handle - journal_stop() : As the name suggests, journal stop marks the completion of an op wrt to journal. It returns any left over unused buffer credits to the transaction, drops appropriate references and frees the handle pointer.
If the filesystem requested this op in sync mode, we also need to start committing the transaction to the journal on completion of handle. However in the current code there are some optimizations built around it to figure it out whether it is beneficial to start writing to disk immediately, or based on the op rate wait for sometime and let other op do it.

See the following code as example.

int journal_stop(handle_t *handle)
{
    ...............
    if (trans_time < commit_time) {
        ktime_t expires = ktime_add_ns(ktime_get(),
                commit_time);
        set_current_state(TASK_UNINTERRUPTIBLE);
        schedule_hrtimeout(&expires, HRTIMER_MODE_ABS);
    }    
    ...............
}
Each journal_start/stop pair ie...each handle consists of one atomic filesystem operation. Some fs operations may be atomic in itself but still may not be sufficient enough to have the filesystem in a consistent state. An example of such an op is write which requires a quota update. Nested journal handles will be required to have such atomic op.

Typical sequence would be
a) Start journal handle for write
b) Start journal handle for quota update
c) Stop journal handle for quota update
d) Stop journal handle for write.

Its only after step (d) that the op can be committed to disk.

NB : A buffer is a "journalled" buffer, only if it has a journal head attached to it.


A journal transaction consists of various lists where buffers of interest can reside. Buffers end up on one of the list depending on what flag/state it has. Below is the buffer state to list mapping. See the function __journal_file_buffer() to see how buffers are moved across lists.

List type => buffer state flag
transaction->t_sync_datalist =>  BJ_SyncData
transaction->t_buffers => BJ_Metadata
transaction->t_forget => BJ_Forget
transaction->t_iobuf_list => BJ_IO
transaction->t_shadow_list => BJ_Shadow
transaction->t_log_list => BJ_LogCtl
transaction->t_reserved_list => BJ_Reserved
transaction->t_locked_list => BJ_Locked