~ubuntu-branches/debian/stretch/jfsutils/stretch

« back to all changes in this revision

Viewing changes to libfs/fssubs.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Hornburg (Racke)
  • Date: 2006-08-02 21:15:09 UTC
  • mfrom: (1.2.2 upstream) (2.1.3 breezy)
  • Revision ID: james.westby@ubuntu.com-20060802211509-eoqwjtlgla5tu9dt
* new upstream release fixing stack buffer overflow (Closes: #343638)
* keep only reference to GPL in debian/copyright
* mark udeb package as such properly and create dependencies 
  (Closes: #381245, thanks to Frans Pop <fjp@debian.org> for the patch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 *   This program is free software;  you can redistribute it and/or modify
5
5
 *   it under the terms of the GNU General Public License as published by
6
 
 *   the Free Software Foundation; either version 2 of the License, or 
 
6
 *   the Free Software Foundation; either version 2 of the License, or
7
7
 *   (at your option) any later version.
8
 
 * 
 
8
 *
9
9
 *   This program is distributed in the hope that it will be useful,
10
10
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
11
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12
12
 *   the GNU General Public License for more details.
13
13
 *
14
14
 *   You should have received a copy of the GNU General Public License
15
 
 *   along with this program;  if not, write to the Free Software 
 
15
 *   along with this program;  if not, write to the Free Software
16
16
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
 */
18
 
#include "config.h"
19
 
 
 
18
#include <config.h>
20
19
#include <errno.h>
21
20
#include <fcntl.h>
22
21
#include <unistd.h>
97
96
        FILE *Mount_Records;    /* Pointer for system's mount records */
98
97
        struct mntent *Mount_Data;      /* Holds data for entry in mount list */
99
98
        int Mounted_RC = 0;     /* Holds return code.             */
100
 
        char Root_FS_Type[] = "0000000";
 
99
        int root_not_jfs = 0;
101
100
 
102
101
#define ROOT_DIR "/"
103
102
 
113
112
 
114
113
        /* Attempt to find specified device name in mount records */
115
114
        while ((Mount_Data = getmntent(Mount_Records)) != NULL) {
116
 
                /* save root file system type for later, if needed */
117
 
                if (strcmp(ROOT_DIR, Mount_Data->mnt_dir) == 0)
118
 
                        strcpy(Root_FS_Type, Mount_Data->mnt_type);
 
115
                /*
 
116
                 * There may be more than one entry for /.  Trust the
 
117
                 * latest one
 
118
                 */
 
119
                if (strcmp(ROOT_DIR, Mount_Data->mnt_dir) == 0) {
 
120
                        if (strcmp("jfs", Mount_Data->mnt_type) == 0)
 
121
                                root_not_jfs = 0;
 
122
                        else
 
123
                                root_not_jfs = 1;
 
124
                }
119
125
                if (strcmp(Device_Name, Mount_Data->mnt_fsname) == 0)
120
126
                        break;
121
127
        }
124
130
#ifndef __GNU__                 /* The GNU hurd is broken with respect to stat devices */
125
131
                struct stat st_root, st_file;
126
132
                /*
127
 
                   * If the specified device name was not found in the mount records, 
128
 
                   * do an extra check to see if this is the root device.  We can't 
129
 
                   * trust /etc/mtab, and /proc/mounts will only list /dev/root for 
130
 
                   * the root filesystem.  Argh.  Instead we will check if the given 
131
 
                   * device has the same major/minor number as the device that the 
 
133
                   * If the specified device name was not found in the mount records,
 
134
                   * do an extra check to see if this is the root device.  We can't
 
135
                   * trust /etc/mtab, and /proc/mounts will only list /dev/root for
 
136
                   * the root filesystem.  Argh.  Instead we will check if the given
 
137
                   * device has the same major/minor number as the device that the
132
138
                   * root directory is on.
133
139
                 */
134
140
                if (stat("/", &st_root) == 0 && stat(Device_Name, &st_file) == 0) {
141
147
                                 * Make a best effort to ensure that
142
148
                                 * the root file system type is jfs
143
149
                                 */
144
 
                                if ((strcmp(Root_FS_Type, "0000000") != '0') &&
145
 
                                    (strcmp(Root_FS_Type, "jfs") != 0))
 
150
                                if (root_not_jfs)
146
151
                                        /* is mounted, found type, is not type jfs */
147
152
                                        Mounted_RC = MSG_JFS_NOT_JFS;
148
153
                        }