Home | History | Annotate | Download | only in cpio
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one
      3  * or more contributor license agreements.  See the NOTICE file
      4  * distributed with this work for additional information
      5  * regarding copyright ownership.  The ASF licenses this file
      6  * to you under the Apache License, Version 2.0 (the
      7  * "License"); you may not use this file except in compliance
      8  * with the License.  You may obtain a copy of the License at
      9  *
     10  * http://www.apache.org/licenses/LICENSE-2.0
     11  *
     12  * Unless required by applicable law or agreed to in writing,
     13  * software distributed under the License is distributed on an
     14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     15  * KIND, either express or implied.  See the License for the
     16  * specific language governing permissions and limitations
     17  * under the License.
     18  */
     19 package org.apache.commons.compress.archivers.cpio;
     20 
     21 /**
     22  * All constants needed by CPIO.
     23  *
     24  * based on code from the jRPM project (jrpm.sourceforge.net)
     25  *
     26  */
     27 public interface CpioConstants {
     28     /** magic number of a cpio entry in the new format */
     29     String MAGIC_NEW = "070701";
     30 
     31     /** magic number of a cpio entry in the new format with crc */
     32     String MAGIC_NEW_CRC = "070702";
     33 
     34     /** magic number of a cpio entry in the old ascii format */
     35     String MAGIC_OLD_ASCII = "070707";
     36 
     37     /** magic number of a cpio entry in the old binary format */
     38     int MAGIC_OLD_BINARY = 070707;
     39 
     40     // These FORMAT_ constants are internal to the code
     41 
     42     /** write/read a CpioArchiveEntry in the new format */
     43     short FORMAT_NEW = 1;
     44 
     45     /** write/read a CpioArchiveEntry in the new format with crc */
     46     short FORMAT_NEW_CRC = 2;
     47 
     48     /** write/read a CpioArchiveEntry in the old ascii format */
     49     short FORMAT_OLD_ASCII = 4;
     50 
     51     /** write/read a CpioArchiveEntry in the old binary format */
     52     short FORMAT_OLD_BINARY = 8;
     53 
     54     /** Mask for both new formats */
     55     short FORMAT_NEW_MASK = 3;
     56 
     57     /** Mask for both old formats */
     58     short FORMAT_OLD_MASK = 12;
     59 
     60     /*
     61      * Constants for the MODE bits
     62      */
     63 
     64     /** Mask for all file type bits. */
     65     int S_IFMT   = 0170000;
     66 
     67  // http://www.opengroup.org/onlinepubs/9699919799/basedefs/cpio.h.html
     68  // has a list of the C_xxx constatnts
     69 
     70     /** Defines a socket */
     71     int C_ISSOCK = 0140000;
     72 
     73     /** Defines a symbolic link */
     74     int C_ISLNK  = 0120000;
     75 
     76     /** HP/UX network special (C_ISCTG) */
     77     int C_ISNWK  = 0110000;
     78 
     79     /** Defines a regular file */
     80     int C_ISREG  = 0100000;
     81 
     82     /** Defines a block device */
     83     int C_ISBLK  = 0060000;
     84 
     85     /** Defines a directory */
     86     int C_ISDIR  = 0040000;
     87 
     88     /** Defines a character device */
     89     int C_ISCHR  = 0020000;
     90 
     91     /** Defines a pipe */
     92     int C_ISFIFO = 0010000;
     93 
     94 
     95     /** Set user ID */
     96     int C_ISUID  = 0004000;
     97 
     98     /** Set group ID */
     99     int C_ISGID  = 0002000;
    100 
    101     /** On directories, restricted deletion flag. */
    102     int C_ISVTX  = 0001000;
    103 
    104 
    105     /** Permits the owner of a file to read the file */
    106     int C_IRUSR  = 0000400;
    107 
    108     /** Permits the owner of a file to write to the file */
    109     int C_IWUSR  = 0000200;
    110 
    111     /** Permits the owner of a file to execute the file or to search the directory */
    112     int C_IXUSR  = 0000100;
    113 
    114 
    115     /** Permits a file's group to read the file */
    116     int C_IRGRP  = 0000040;
    117 
    118     /** Permits a file's group to write to the file */
    119     int C_IWGRP  = 0000020;
    120 
    121     /** Permits a file's group to execute the file or to search the directory */
    122     int C_IXGRP  = 0000010;
    123 
    124 
    125     /** Permits others to read the file */
    126     int C_IROTH  = 0000004;
    127 
    128     /** Permits others to write to the file */
    129     int C_IWOTH  = 0000002;
    130 
    131     /** Permits others to execute the file or to search the directory */
    132     int C_IXOTH  = 0000001;
    133 
    134     /** The special trailer marker */
    135     String CPIO_TRAILER = "TRAILER!!!";
    136 
    137     /**
    138      * The default block size.
    139      *
    140      * @since 1.1
    141      */
    142     int BLOCK_SIZE = 512;
    143 }
    144