~ubuntu-branches/ubuntu/maverick/util-linux/maverick-proposed

« back to all changes in this revision

Viewing changes to mount/swapon.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2010-03-22 17:35:40 UTC
  • mfrom: (1.6.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100322173540-sm083tdtvne1wa5w
Tags: 2.17.2-0ubuntu1
* Merge from Debian experimental, remaining changes:
  - Since udev is required in Ubuntu, the hwclock.sh init script is
    not called on startup and the hwclockfirst.sh init script is
    removed.
  - Use wildcards for symbols file, since they use versioned symbols
    properly.
  - Remove /etc/adjtime on upgrade if it was not used.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - No lsb_release call in mount.preinst since we'd need Pre-Depends
    (LP: #383697).
  - Do not install initramfs hook, since our initramfs already handles
    including blkid.
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.

* For the case where mount is called with a directory to mount, look
  that directory up in mountall's /lib/init/fstab if we couldn't find
  it mentioned anywhere else.  This means "mount /proc", "mount /sys",
  etc. work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
static int numSwaps;
121
121
static char **swapFiles;        /* array of swap file and partition names */
122
122
 
 
123
#define DELETED_SUFFIX          "\\040(deleted)"
 
124
#define DELETED_SUFFIX_SZ       (sizeof(DELETED_SUFFIX) - 1)
 
125
 
123
126
static void
124
127
read_proc_swaps(void) {
125
128
        FILE *swaps;
126
129
        char line[1024];
127
130
        char *p, **q;
 
131
        size_t sz;
128
132
 
129
133
        numSwaps = 0;
130
134
        swapFiles = NULL;
152
156
                 * This will fail with names with embedded spaces.
153
157
                 */
154
158
                for (p = line; *p && *p != ' '; p++);
155
 
                *p = 0;
 
159
                *p = '\0';
 
160
 
 
161
                /* the kernel can use " (deleted)" suffix for paths
 
162
                 * in /proc/swaps, we have to remove this junk.
 
163
                 */
 
164
                sz = strlen(line);
 
165
                if (sz > DELETED_SUFFIX_SZ) {
 
166
                       p = line + (sz - DELETED_SUFFIX_SZ);
 
167
                       if (strcmp(p, DELETED_SUFFIX) == 0)
 
168
                               *p = '\0';
 
169
                }
156
170
 
157
171
                q = realloc(swapFiles, (numSwaps+1) * sizeof(*swapFiles));
158
172
                if (q == NULL)
354
368
                        pagesize / 1024,
355
369
                        flip ? _("different") : _("same"));
356
370
 
357
 
        return (last_page + 1) * pagesize;
 
371
        return ((unsigned long long) last_page + 1) * pagesize;
358
372
}
359
373
 
360
374
static int