2011-8-3 16:27:21

来源:互联网 发布:苹果平板淘宝网打不开 编辑:程序博客网 时间:2024/05/02 17:56
 

 

 

2011-8-3 16:27:21


int
find_exec_pid (const char *file)
{
  char fullname[512];
  struct stat file_buf, exe_buf;

  if (stat (file, &file_buf) < 0)
    {
      perror (file);
      exit (2);
    }

  DIR *d = opendir ("/proc");
  if (d)
    {
      struct dirent *e;
      while ((e = readdir (d)))
 {
   strcpy (fullname, "/proc/");
   strcat (fullname, e->d_name);
   strcat (fullname, "/exe");
   if (stat (fullname, &exe_buf) >= 0)
     {
       if (file_buf.st_dev == exe_buf.st_dev
    && file_buf.st_ino == exe_buf.st_ino)
  {
    int pid = atoi (e->d_name);
    closedir (d);
    return pid;
  }
     }
 }
      closedir (d);
    }

  return -1;
}

对应的进程启动了没有


int
main (int argc, char **argv)
{
 
  FILE *f;
  GtkWidget *dialog;
  xexp *rescue_xexp = NULL;
  int rescue_success = 1;

  /* Check UFILE_BOOT flag file */
  f = user_file_open_for_read (UFILE_BOOT);
  if (f == NULL)
    {
      if (errno != ENOENT)
 perror (UFILE_BOOT);
      return 0;
    }
  fclose (f);
  user_file_remove (UFILE_BOOT);

  /* Check rescue mode last result */
  rescue_xexp = xexp_read_file (RESCUE_RESULT_FILE);
  if (rescue_xexp && xexp_is_text (rescue_xexp)
      && xexp_is (rescue_xexp, "success"))
    {
      rescue_success = xexp_text_as_int (rescue_xexp);
    }
  xexp_free (rescue_xexp);

  /* Show success banner only on success. Pretty logical, isn't it? */
  if (rescue_success)
    {
      hildon_gtk_init (&argc, &argv);

      /* For the OS update, make sure the icon will blink after reboot
         by deleting user files related to tapped and seen states */
      user_file_remove (UFILE_SEEN_UPDATES);
      user_file_remove (UFILE_TAPPED_UPDATES);

      dialog = hildon_note_new_information
        (NULL, _("ai_ni_system_update_installed"));

      gtk_widget_show_all (dialog);
      gtk_dialog_run (GTK_DIALOG (dialog));
      gtk_widget_destroy (dialog);
    }

  return 0;
}


gchar *
user_file_get_state_dir_path ()
{
  gchar *required_dir = NULL;

  required_dir = g_strdup_printf ("%s/%s",
      getenv ("HOME"),
      HAM_STATE_DIR);

  if (mkdir (required_dir, 0777) && errno != EEXIST)
    return NULL;

  return required_dir;
}

获取状态文件目录

  /* Check UFILE_BOOT flag file */
  f = user_file_open_for_read (UFILE_BOOT);
  if (f == NULL)
    {
      if (errno != ENOENT)
 perror (UFILE_BOOT);
      return 0;
    }
  fclose (f);
  user_file_remove (UFILE_BOOT);
 
  读取boot文件 移除boot文件
 
 


Introduction
------------

This is the architecture description of the Application Installer
application and its supporting components.

The supporting components are apt and GnuPG.  This document considers
them to be part of the subsystem and not as external dependencies.
The end-user oriented GUI program that these components are supporting
is termed "the GUI" in the following.

 

System context
--------------

* Functionality provided by the subsystem

The Application Installer allows the end-user to browse a externally
provided catalog of software components, to install those components
to the device filesystem, and to browse/upgrade/remove components that
have been installed in that way.  The Application Installer does not
aim to manage all software components that make up the Internet Tablet
2006 OS.  This is reflected in the design of the GUI, but dpkg and apt
are not restricted in any way.


* Software context

The Appliction Installer is not used by other components in the
system.

The GUI is a regular hildonized program with no unusual dependencies.
It is a mime handler for .deb files and listens for events on D-BUS
for this.  It appears in the "Others" menu in the Task Navigator and
is started as a D-BUS service.

监听dbus事件, 作为一个dbus服务来启动

For some access to local files, GnomeVFS might be used.

Part of the GUI runs as root and is started via "sudo".

The actual package management is ultimately carried out by dpkg.

部分以root的权限来执行


不小心更改了/usr/的权限.
在执行sudo 的时候出现 sudo: must be setuid root这个提示,
网上搜了下,解决了.特记录.

ls -l  /usr/bin/sudo

chown root:root /usr/bin/sudo

chmod 4755 /usr/bin/sudo

reboot

 

 

原创粉丝点击